在chrome中運行Selenium WebDriver python綁定我在使用Selenium時遇到了問題。對于我的項目,我必須使用Chrome。但是,在使用Selenium啟動它后,我無法連接到該瀏覽器。出于某種原因,Selenium無法單獨找到Chrome。當我嘗試在不包含路徑的情況下啟動Chrome時會發(fā)生這種情況:Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome() # Get local session of chrome
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__
self.service.start()
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 58, in start and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'為了解決這個問題,我在啟動Chrome的代碼中包含了Chromium路徑。但是,解釋器無法找到要連接的套接字:Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of chrome
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__
self.service.start()
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 64, in start raise WebDriverException("Can not connect to the ChromeDriver")selenium.common.exceptions.WebDriverException: Message: 'Can not connect to the ChromeDriver'我也嘗試通過啟動chrome來解決問題:鉻--remote-shell-port = 9222但是,這也不起作用。PS。這是關(guān)于我的系統(tǒng)的一些信息:www-client:chromium 15.0.874.121 dev-lang:python 2.7.2-r3 Selenium 2.11.1 操作系統(tǒng):GNU / Linux Gentoo內(nèi)核3.1.0-gentoo-r1
在chrome中運行Selenium WebDriver python綁定
慕桂英3389331
2019-08-15 15:24:57