-
-
Save AutomatedTester/273702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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