Selenium WebDriver python bindings


Question

I can't make python bindings for webdriver workable. Here is tutorial for installing.

easy_install webdriver

Won't find webdriver package so I have to install it manually from sources. I've downloaded source from trunk, set WEBDRIVER and PYTHONPATH variables and installed webdriver:

   ~$ cd ~
   ~$ svn checkout http://selenium.googlecode.com/svn/trunk/ selenium-read-only
   ~$ cd selenium-read-only
   ~# python setup.py install
   ~$ env |grep PYT
   ~$> PYTHONPATH=:/home/ockonal/selenium-read-only/../../../firefox/lib-src:/home/ockonal/selenium-read-only/..
   ~$ env |grep WEB
   ~$> WEBDRIVER=/home/ockonal/selenium-read-only

Here is output of setup.py script.

Then I downloaded RemoteDriverServer.jar and ran it:

java -jar RemoteDriverServer.jar 8888

Now I want to include webdriver module in python script:

from selenium.firefox.webdriver import WebDriver

ImportError: No module named firefox.webdriver

1
3
7/20/2017 11:38:46 AM

Accepted Answer

Try this.

I'm guessing that selenium was installed to:

/usr/local/lib/python2.6/

In either the site-packages or dist-packages folder.

Since the link to your setup.py output is broken I can't see the results so I'm going to make some assumptions based on a 'normal' setup.py install

One of these folders should exist:

/usr/local/lib/python2.6/dist-packages/selenium/firefox/

or

/usr/local/lib/python2.6/site-packages/selenium/firefox/

This is the folder where the python library should exist based on the setup.py how the packages are defined in setup.py.

Now go back to the folder where you downloaded the source and navigate to.

./firefox/source/py/

Copy the all of the source files to whichever one of these two files exist.

/usr/local/lib/python2.6/dist-packages/selenium/firefox/

or

/usr/local/lib/python2.6/site-packages/selenium/firefox/

This is the equivalent to a 'manual install'. Although I'm not sure why you'd need to because the firefox parts of the package are clearly specified in the setup.py source.

...

'selenium.firefox': 'firefox/src/py',
...

If there is nothing for selenium under the site-packages or dist-packages folders the 'setup.py install' may not have installed correctly because it didn't have the required permissions.

Be sure to run 'setup.py install' with sudo if you haven't already. Since, root permissions are necessary to modify/add anything under '/usr'.

6
6/11/2010 8:37:28 AM

the latest selenium (which includes webdriver) bindings should be pip installable:

pip install selenium

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon