2016-07-22 24 views
1

這是我用了如何在Python中的自定義配置文件使用硒打開谷歌瀏覽[操作系統:Ubuntu的]

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=/home/user_name/.config/google-chrome/") 
browser=webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=options) 
browser.get('https://www.google.co.in/') 

代碼上面的代碼將打開所需的配置文件的瀏覽器,但隨後的行沒有執行(WebDriverException被拋出),如果webdriver.Chrome()內部的參數被刪除,瀏覽器會加載'google.co.in'。

編輯:顯示的錯誤信息是:

Traceback (most recent call last): 
    File "test.py", line 30, in <module> 
    browser = webdriver.Chrome(executable_path= '/usr/local/bin/chromedriver',chrome_options=options) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__ 
desired_capabilities=desired_capabilities) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__ 
    self.start_session(desired_capabilities, browser_profile) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session 
    response = self.execute(Command.NEW_SESSION, capabilities) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute 
    self.error_handler.check_response(response) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response 
    raise exception_class(message, screen, stacktrace) 
    selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally 
(Driver info: chromedriver=2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad),platform=Linux 4.4.0-31-generic x86_64) 
+0

你可以發佈整個異常消息嗎? – Greg

+0

嗨格雷格,我已經粘貼了異常消息。 –

回答

相關問題