views:

312

answers:

2

Hello, 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

+2  A: 

You need copy build/webdriver-extension.zip to your python installation folder. Just copy the build/webdriver-extension.zip to /usr/lib/pythonX.X/site-packages/selenium-2.0_dev-py2.6.egg/selenium/firefox. It's an extension that you manually install.

Tarantula
+1  A: 

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'.

Evan Plaice