0
您好!Chrome網絡驅動器無法連接到Windows上的服務chromedriver.exe
我目前在Windows 7上使用Selenium和Python,我嘗試使用Chrome webdriver作爲隱藏函數--no-startup-window
。我安裝了Chrome(86),複製chromedriver.exe後的路徑C:\Python27\Scripts\
,並添加它的PATH環境,我想通過下面的代碼來啓動它:
opt = Options()
opt.add_argument("--no-startup-window")
driver = webdriver.Chrome(chrome_options=opt)
不過,我有以下錯誤,當我執行它:
(env) c:\opt\project\auto\>python program_test.py
Traceback (most recent call last):
File "program_test.py", line 234, in <module>
main()
File "program_test.py", line 36, in main
initChromeWebDriver()
File "c:\opt\project\auto\common\driver.py", line 32, in initChromeWebDriver
service_log_path=)
File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\chrome\webdriver.p
y", line 61, in __init__
self.service.start()
File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\common\service.py"
, line 88, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver
注:我目前使用virtualenv
還,所以我也複製了他Scripts
文件夾中的chromedriver.exe。有關這個問題的任何想法嗎?
確定這一這裏解決了我的第一個問題,但是我現在有一個'未知錯誤:鉻失敗時,我用它來start' '--no-startup-window'。此外,Chrome在我評論此選項時正在啓動。我爲錯誤更新了我的帖子。 – toshiro92
@ toshiro92你爲什麼要在沒有啓動窗口的情況下打開chrome,你能解釋一下嗎? – Soorena
我只是需要它來避免一些錯誤的手動操作。 – toshiro92