2016-09-19 50 views
2

嗨!沒有啓動窗口選項不能在Windows上工作

我目前在Windows 7操作系統上使用Selenium的Chrome瀏覽器,並試圖使用--no-startup-window。但是這個選項墜毀的硒,出現以下錯誤:

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可以推出,如果我的評論就行了。

有關此問題的任何想法?

+0

嗨,你能解決這個問題嗎? – pratibha

+0

@pratibha:不幸的是,我放棄了。我想你可能需要爲他們的網絡驅動程序打開Chrome的門票......如果你在研究之後找到解決方案,請發表一個答案,我將非常感興趣:) – toshiro92

回答

0

Chrome 59帶有「 - 無頭」選項。我將它與Python 2.7和Selenium 3一起使用。像魅力一樣工作。只是嘗試「 - 無頭」代替「 - 無啓動窗口」

+0

好吧,我會盡快爲Chrome 59提高:) – toshiro92