Ubuntu: How is “chromium-chromedriver” package used?



Question:

Firefox selenium driver seems to be crashing (perhaps because I'm on Firefox-beta ppa?):

>>> from selenium import webdriver  >>> webdriver.Firefox  <class 'selenium.webdriver.firefox.webdriver.WebDriver'>  >>> webdriver.Firefox()  Traceback (most recent call last):    File "<stdin>", line 1, in <module>    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__      self.binary, timeout),    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__      self.binary.launch_browser(self.profile)    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser      self._wait_until_connectable()    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 100, in _wait_until_connectable      raise WebDriverException("The browser appears to have exited "  selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.  

So I tried installing the chromium driver but it still fails with selenium:

>>> webdriver.Chrome()  Traceback (most recent call last):    File "<stdin>", line 1, in <module>    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 59, in __init__      self.service.start()    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/service.py", line 66, in start      "ChromeDriver executable needs to be available in the path. "  selenium.common.exceptions.WebDriverException: Message: ChromeDriver executable needs to be available in the path. Please download from http://chromedriver.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/ChromeDriver  

Am I missing something or is this package completely broken? I have both Chromium and Google Chrome installed for testing, if that matters.


Solution:1

  • The Firefox webdriver failed with this message:

    "The browser appears to have exited before we could connect"

    Which means that selenium managed to find it. I also believe that beta versions can be the root cause as it works out of the box for me using the repo version.

  • For Chromium, you have to install the following packages:

    sudo apt-get install python-selenium chromium-chromedriver  

    And fix the libui_base.so library path (See Chromedriver on Ubuntu 14.04 - error while loading shared libraries: libui_base.so)

  • To use the Chrome webdriver install the following dependency:

    sudo apt-get install python-selenium  

    And download the Chromedriver from here, select the one corresponding to your architecture e.g:

    http://chromedriver.storage.googleapis.com/2.14/chromedriver_linux64.zip or http://chromedriver.storage.googleapis.com/2.14/chromedriver_linux32.zip

    Extract the chromedriver file for example in your $HOME folder.

    Then to start the chromedriver from python, open a terminal and type:

    $ python  Python 2.7.6 (default, Mar 22 2014, 22:59:56)   [GCC 4.8.2] on linux2  Type "help", "copyright", "credits" or "license" for more information.  >>> import os  >>> from selenium import webdriver  >>> driver = webdriver.Chrome(os.path.expanduser('~/chromedriver'))  

Finally I'd recommend to use the package version of python-selenium available from the Ubuntu repositories to avoid installation in /usr/local/lib.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »