• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

解决 super(WebDriver, self).__init__(DesiredCapabilities.CHROME[‘browserName‘], “goog“,.....问题

武飞扬头像
正在吞噬的世界
帮助1

运行selesium代码学新通

出现下面bug详细信息如下:

PS C:\Users\16179> & D:/Work/Python/Python310/python.exe e:/Work/vscode/Untitled-1.py
Traceback (most recent call last):
  File "e:\Work\vscode\Untitled-1.py", line 4, in <module>
    driver = webdriver.Chrome()
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__  
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
    RemoteWebDriver.__init__(
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
    self.start_session(capabilities, browser_profile)
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
    self.error_handler.check_response(response)
  File "D:\Work\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64)

学新通

解决方法

如下

1.先打开chrome 输入 “chrome://version/”来查看chrome版本 如图我的是97
学新通
2.然后访问此网站
http://chromedriver.storage.谷歌apis.com/index.html

然后选择合适版本的driver
学新通
我这边是windows版本的系统所以下载 win32版本的压缩包
学新通
解压后里面是个这个东西

学新通
3. 把解压后的 chromedriver.exe 文件放入 python 替换现有的chromedriver.exe
学新通
4. 之后再运行代码问题解决了

PS C:\Users\16179> & D:/Work/Python/Python310/python.exe e:/Work/vscode/Untitled-1.py

DevTools listening on ws://127.0.0.1:49642/devtools/browser/91816ccf-1832-4937-812c-9d166caca2fb
e:\Work\vscode\Untitled-1.py:8: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
  driver.find_element_by_id("kw").send_keys("selenium")
e:\Work\vscode\Untitled-1.py:10: DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
  driver.find_element_by_id("su").click()

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfjhkk
系列文章
更多 icon
同类精品
更多 icon
继续加载