WebDriverException:消息:Chrome无法长时间访问 [英] WebDriverException: Message: chrome not reachable after long time
问题描述
这是代码:
driver = webdriver.Chrome()
while True:
#do thing that require hours
#then i use selenium once
driver.get(link)
我需要先打开硒,然后做一些需要几个小时的事情,因为当我打开硒时,我需要准备好并且要速度.如果将 driver = webdriver.Chrome()
放在下面,则会降低所有速度我不知道它是否相关,但是我使用 nohup
命令运行此代码.
I need to open first selenium and then make things that require hours because when i open selenium i need to be ready and speed. If put driver = webdriver.Chrome()
below the while, it would slow everything down
i don't know if it is relevant but i run this code with nohup
command.
跟踪:
Traceback (most recent call last):
File "Scraper.py", line 84, in <module>
main()
File "Scraper.py", line 74, in main
waitForSomething()
File "Scraper.py", line 54, in waitForSomething
fillForm(str(link)[2:-2])
File "Scraper.py", line 30, in fillForm
driver.get(link)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_resp$
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: chrome=192.168.0.0)
(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.9.0-9-amd64 x$
推荐答案
最初,我问自己和@GregBurghardt在评论中一直问的问题相同,直到我分析了详细的错误堆栈跟踪.
Initially I had asked myself the same questions as @GregBurghardt had been asking in the comments till I analyzed the detailed error stack trace.
是,在标记为 #do事需要几个小时
的步骤中,发生了一些令人惊奇的事情.因此,无需将 Chrome 浏览器版本显示为 chrome = 76.0
, chrome = 75.0
>或 chrome = 74.0
,它显示:
Yes, there is somehting amazing happening in those steps marked as #do thing that require hours
. Hence, instaed of showing Chrome browser version as chrome=76.0
, chrome=75.0
or chrome=74.0
it shows:
(Session info: chrome=192.168.0.0)
这真是令人惊讶.
直到和除非您向我们更新 Chrome 版本更改为这样的值的原因和方式,否则几乎不可能分析该问题.
It would be almost impossible to analyze the issue until and unless you update us why and how the Chrome version gets changed to such value.
话虽如此,可能您的主要问题是正在使用的二进制文件版本之间的不兼容性.
Having said that, possibly your main issue is the incompatibility between the version of the binaries you are using.
- 您正在使用 chromedriver = 2.36
- chromedriver = 2.36 的发行说明明确提到以下内容:
支持 Chrome v63-65
- 大概您正在使用最新的 chrome = 76.0
- ChromeDriver v76.0 明确提到以下内容:
- 您不知道您的 Selenium Client 版本.
- 硒已升级到当前级别版本3.141.59 .
- ChromeDriver 已更新为当前的ChromeDriver v76.0 级别.
- Chrome 已更新为当前的 Chrome版本76.0 级别.(根据 ChromeDriver v76.0发行说明) 通过 IDE
- 清理您的项目工作区和重建您的项目,并且仅具有必需的依赖项.
- 如果您的基本 Web客户端版本太旧,则将其卸载并安装最新版本的 Web客户端 GA.
- 进行系统重启.
- 以非root用户用户的身份执行
@Test
. - 始终在
tearDown(){}
方法中调用driver.quit()
以关闭&优雅地销毁 WebDriver 和 Web Client 实例. - Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v76.0 level.
- Chrome is updated to current Chrome Version 76.0 level. (as per ChromeDriver v76.0 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Test
as non-root user. - Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully. - Python selenium WebDriverException:无法访问chrome在打开ChromeDriver时
- selenium.common.exceptions.WebDriverException:消息:在ChromeDriver中使用find_element_by_id Selenium时,chrome无法访问错误
- org.openqa.selenium.WebDriverException:无法访问chrome-尝试启动新会话时
支持 Chrome 76版
因此 ChromeDriver v2.36 与 Chrome浏览器v76.0
确保:
这篇关于WebDriverException:消息:Chrome无法长时间访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!