【发布时间】:2016-09-19 08:57:39
【问题描述】:
嗨!
我目前在 Windows 7 操作系统上使用带有 Selenium 的 Chrome,我尝试使用 --no-startup-windowwith。但是,此选项使 Selenium 崩溃并出现以下错误:
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 27, in initChromeWebDriver
driver = webdriver.Chrome("C:\\chromedriver.exe", chrome_options=chrome_options)
File "c:\opt\project\env\lib\site-packages\selenium\webdriver\chrome\webdriver.p
y", line 67, in __init__
desired_capabilities=desired_capabilities)
File "c:\opt\project\env\lib\site-packages\selenium\webdriver\remote\webdriver.p
y", line 91, in __init__
self.start_session(desired_capabilities, browser_profile)
File "c:\opt\project\env\lib\site-packages\selenium\webdriver\remote\webdriver.p
y", line 173, in start_session
'desiredCapabilities': desired_capabilities,
File "c:\opt\project\env\lib\site-packages\selenium\webdriver\remote\webdriver.p
y", line 233, in execute
self.error_handler.check_response(response)
File "c:\opt\project\env\lib\site-packages\selenium\webdriver\remote\errorhandle
r.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to st
art: exited normally
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platfo
rm=Windows NT 6.1.7601 SP1 x86_64)
这是我的一段代码:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--no-startup-window")
driver = webdriver.Chrome("C:\\chromedriver.exe", chrome_options=chrome_options)
如果没有这个选项,如果我评论该行,Chrome 就可以启动。
关于这个问题的任何想法?
【问题讨论】:
-
嗨,你能解决这个问题吗?
-
@pratibha:不幸的是,我放弃了。我想您可能需要为他们的 Web 驱动程序打开一张 Chrome 的票...如果您在研究后找到解决方案,请发布答案,我会很感兴趣 :)
标签: python google-chrome selenium