I am having difficulty with Selenium RC. When trying to run scripts in Python, I see the message “Cannot import name webdriver”.
I’m likely missing something very basic. Let me explain every step I’ve taken (better to be too granular than too vague…):
-
Download and set up Java Development Kit and set Paths. The command ‘Java -version’ yields “1.6.0_26”
-
Download the Selenium RC standalone server.
-
Started the server
-
Downloaded and installed Python 2.6 32-bit version
-
Downloaded the Python bindings from http://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip. From the zip file, I have copied selenium.py into my Python27\Libs directory.
-
Created a script in Selenium IDE. Exported for Python.
When I try to run the script from IDLE, I see the message “ImportError: cannot import name webdriver”. The script I’m using starts
from selenium import webdriver
I see no definition of a function named ‘webdriver’ in selenium.py. Is this the wrong file? I am quite confused.
Scripts that don’t refer to ‘import webdriver’ work just fine.
Googling is very unhelpful, and most tutorials are either incomplete or assume a Linux environment (I’m using Windows).
Is this an issue with Selenium 1 vs Selenium 2? Do I need Selenium 2 bindings? Are they different to mine?
Any assistance is appreciated.
WebDriver is part of Selenium 2. You are installing the Selenium 1 bindings and then trying to run WebDriver. That won’t work.
Furthermore, WebDriver API eliminates the need for the Server component (WebDriver is different than Selenium-RC). To use WebDriver, All you need are the Python bindings for Selenium 2.
The easiest way to install them is with pip or easy_install
or