Skip to content

Instantly share code, notes, and snippets.

@AutomatedTester
Forked from hugs/selenium2.py
Created January 10, 2010 19:16
Show Gist options
  • Save AutomatedTester/273702 to your computer and use it in GitHub Desktop.
Save AutomatedTester/273702 to your computer and use it in GitHub Desktop.
# Using Selenium 2 and its native Python bindings for the first time...
# On Ubuntu 8.04 and Python 2.5.2
"""
# Checkout
$ svn checkout http://selenium.googlecode.com/svn/trunk/ webdriver
# Build the code
$ cd webdriver
$ sudo python setup.py build
# Some hacking until the Python bindings are packaged as a real Python library
$ export WEBDRIVER=.
$ export PYTHONPATH=$PYTHONPATH:firefox/lib-src:build/lib
# Let's sling some code
$ python
"""
# Some imports
from webdriver_firefox.webdriver import WebDriver
# Create a "driver" object that will do all the real work.
driver = WebDriver()
# Open a web page
driver.get("http://google.com")
# Find the search box
search_box = driver.find_element_by_name("q")
search_box.send_keys("Hello, World!")
# Submit the query...
search_button = driver.find_element_by_name("btnG")
search_button.click()
# Say goodbye
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment