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