問題描述
這是代碼:
driver = webdriver.Chrome()
while True:
#do thing that require hours
#then i use selenium once
driver.get(link)
我需要先打開 selenium,然后制作需要數小時的東西,因為當我打開 selenium 時,我需要做好準備并加快速度.如果將 driver = webdriver.Chrome()
放在 while 下面,它會減慢一切我不知道它是否相關,但我使用 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 thing that require hours
的那些步驟中發生了令人驚奇的事情.因此,沒有將 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的發行說明/a> 明確提及以下內容:
- Presumably you are using the latest chrome= 76.0
- Release Notes of ChromeDriver v76.0 clearly mentions the following :
- 我們不知道您的 Selenium 客戶端 版本.
- Selenium 已升級到當前級別版本 3.141.59.
- ChromeDriver 已更新為當前 ChromeDriver v76.0 級別.
- Chrome 已更新至當前 Chrome 版本 76.0 級別.(根據 ChromeDriver v76.0 發行說明)
- 清理你的項目工作區通過你的IDE和重建你的項目只需要依賴.
- 如果您的基本 Web 客戶端 版本太舊,請卸載它并安裝最新的 GA 和發布版本的 Web 客戶端.
- 進行一次系統重啟.
- 以 非 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:消息:將 find_element_by_id Selenium 與 ChromeDriver 一起使用時出現 chrome 無法訪問錯誤
- org.openqa.selenium.WebDriverException: chrome 無法訪問 - 嘗試啟動新會話時
支持Chrome 76版
所以 ChromeDriver v2.36 和 Chrome 瀏覽器 v76.0
確保:
這篇關于WebDriverException:消息:長時間無法訪問 chrome的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!