【问题标题】:Can someone help me with this push button python script?有人可以帮我处理这个按钮 python 脚本吗?
【发布时间】:2020-08-26 04:45:09
【问题描述】:

谁能解释一下并帮我解决这个问题? 我正在尝试在撕裂(浏览器游戏)中自动进行健身房训练,在一些错误和调试之后,我再次陷入困境......我将发布错误消息和代码。

from selenium import webdriver

driver = webdriver.Chrome(executable_path='d:/Users/Usuario/Desktop/Python Training/drivers/81/chromedriver')
driver.get('https://www.torn.com/gym.php')
xpath = '//*[@id="gymroot"]/div/div[2]/div/ul/li[1]/div[2]/div[2]/button'
btn = driver.find_element_by_xpath(xpath)
btn.click()

错误:

Traceback (most recent call last):
  File "d:\Users\Usuario\Desktop\Python Training\projects\tornGymTrain.py", line 4, in <module>
    driver = webdriver.Chrome(executable_path='d:/Users/Usuario/Desktop/Python Training/drivers/81/chromedriver')
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
    RemoteWebDriver.__init__(
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

【问题讨论】:

标签: python selenium-webdriver browser-automation


【解决方案1】:

这是因为您没有正确给出可执行路径。

使用 .exe 文件更新路径。您刚刚停在路径位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-20
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2016-07-14
    • 2015-10-03
    • 1970-01-01
    相关资源
    最近更新 更多