Selenium web driver with Python: Need help to start executing test case(configuring test environment with python lib)

436 views
Skip to first unread message

Subba Rao M

unread,
Sep 27, 2011, 3:50:03 AM9/27/11
to Selenium Users
Hi All,

I'm new to automation testing. I'm trying to automate a product using
selenium. I have latest version of selenium web driver downloaded and
using python 3.1.

I want to test the product using IE 8/9 and Mozilla Firefox 3.6 and
Mozilla 6.0.

Please help me how to configure python library for selenium.

I have copied selenium folder which contains web driver and
selenium.py to Lib folder inside python folder.

Path: C:\Python31\Lib\selenium

The issue is on executing a sample codes getting error.

Traceback (most recent call last):
File "C:\Python31\selhq.py", line 1, in <module>
from selenium import webdriver
File "C:\Python31\lib\selenium\__init__.py", line 16, in <module>
from selenium import selenium
File "C:\Python31\lib\selenium\selenium.py", line 193
raise Exception, result
^
SyntaxError: invalid syntax

The example sample code is taken from selenium official website for
driver(and same error i'm getting for pyhton code generated using
selenium IDE for my product test case)

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available
since 2.4.0
import time
driver = webdriver.Firefox()

# go to the google home page
driver.get("http://www.google.com")

# find the element that's name attribute is q (the google search box)
inputElement = driver.find_element_by_name("q")

# type in the search
inputElement.send_keys("Cheese!")

# submit the form (although google automatically searches now without
submitting)
inputElement.submit()

# the page is ajaxy so the title is originally this:
print (driver.title)

try:
# we have to wait for the page to refresh, the last thing that
seems to be updated is the title
WebDriverWait(driver, 10).until(lambda driver :
driver.title.lower().startswith("cheese!"))

# You should see "cheese! - Google Search"
print (driver.title)

finally:
driver.quit()

Reference of above code : http://seleniumhq.org/docs/03_webdriver.html#internet-explorer-driver

Please help me to solve the above issue.

Thanks,
Subba Rao

Message has been deleted

Thomas CARPENTIER

unread,
Sep 27, 2011, 6:50:21 AM9/27/11
to seleniu...@googlegroups.com
Hi, 

Python bindings do not support python3.1 !
 on the page : http://code.google.com/p/selenium/wiki/PythonBindings , it's written that" Currently Selenium only supports Python 2.6 and Python 2.7"

Subba Rao M

unread,
Sep 27, 2011, 8:08:19 AM9/27/11
to Selenium Users
oK Thanks. I will check with Pyhton 2.6 or 2.7

On Sep 27, 3:50 pm, Thomas CARPENTIER <carpentier...@gmail.com> wrote:
> Hi,
>
> Python bindings do not support python3.1 !
>  on the page :http://code.google.com/p/selenium/wiki/PythonBindings, it's
Reply all
Reply to author
Forward
0 new messages