簡體   English   中英

chromedriver的python-selenium綁定錯誤

[英]Error in python-selenium bindings for chromedriver

我正在嘗試通過查看此處的帖子成功安裝chrome驅動程序后創建chrome驅動程序的實例。 如帖子所示,我為python下載了chrome-driver 64-bit 我將chromedriver可執行文件移動到/usr/bin ,並嘗試了以下代碼

 from selenium import webdriver
 driver = webdriver.Chromedriver()

結果

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/local/user/<ipython console> in <module>()

AttributeError: 'module' object has no attribute 'Chromedriver'

也嘗試以下時

 from selenium import webdriver
 driver = webdriver.Firefox()

結果:

WebDriverException                        Traceback (most recent call last)

/home/local/<ipython console> in <module>()

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout)
     49         RemoteWebDriver.__init__(self,
     50             command_executor=ExtensionConnection("127.0.0.1", self.profile,
---> 51             self.binary, timeout),
     52             desired_capabilities=DesiredCapabilities.FIREFOX)
     53 

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/extension_connection.pyc in __init__(self, host, firefox_profile, firefox_binary, timeout)
     45         self.profile.add_extension()
     46 
---> 47         self.binary.launch_browser(self.profile)
     48         _URL = "http://%s:%d/hub" % (HOST, PORT)
     49         RemoteConnection.__init__(

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.pyc in launch_browser(self, profile)
     42 
     43         self._start_from_profile_path(self.profile.path)
---> 44         self._wait_until_connectable()
     45 
     46     def kill(self):

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.pyc in _wait_until_connectable(self)
     79                 raise WebDriverException("The browser appears to have exited "
     80                       "before we could connect. The output was: %s" %
---> 81                       self._get_firefox_output())
     82             if count == 30:
     83                 self.kill()

WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: *** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: Opening database\n*** LOG addons.xpi: No changes found\nFailed to dlopen /usr/lib/libX11.so.6\ndlerror says: /usr/lib/libX11.so.6: wrong ELF class: ELFCLASS32\n' 

我不知道這里發生了什么,以及為什么chrome和firefox web驅動程序都無法正常工作。

它的webdriver.Chrome() 不是 webdriver.Chromedriver()

並且您可以通過將可執行文件的路徑指定為參數來避免復制/ usr / bin ..etc中的可執行文件

webdriver.Chrome(executable_path='...')

這樣你可以避免一個額外的步驟,並將驅動程序檢入您的源控制目錄等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM