hugs (owner)

Revisions

gist: 60740 Download_button fork
public
Description:
Getting Started with Selenium 2.0 (WebDriver)
Public Clone URL: git://gist.github.com/60740.git
Embed All Files: show embed
selenium2.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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/webdriver/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()