Skip to main content
Help us improve Python packaging – donate today!

Python bindings for Selenium

Project Description

Introduction

Python language bindings for Selenium WebDriver.

The selenium package is used automate web browser interaction from Python.

Home: http://www.seleniumhq.org
Docs: selenium package API
Dev: https://code.google.com/p/selenium/
PyPI: https://pypi.python.org/pypi/selenium
IRC: #selenium channel on freenode

Several browsers/drivers are supported (Firefox, Chrome, Internet Explorer, PhantomJS), as well as the Remote protocol.

Supported Python Versions

  • Python 2.6, 2.7
  • Python 3.2, 3.3

Installing

If you have pip on your system, you can simply install or upgrade the Python bindings:

pip install -U selenium

Alternately, you can download the source distribution from PyPI (e.g. selenium-2.41.tar.gz), unarchive it, and run:

python setup.py install

Note: both of the methods described above install selenium as a system-wide package That will require administrative/root access to ther machine. You may consider using a virtualenv to create isolated Python environments instead.

Example 0:

  • open a new Firefox browser
  • load the page at the given URL
from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')

Example 1:

  • open a new Firefox browser
  • load the Yahoo homepage
  • search for “seleniumhq”
  • close the browser
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()

browser.get('http://www.yahoo.com')
assert 'Yahoo!' in browser.title

elem = browser.find_element_by_name('p')  # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)

browser.quit()

Example 2:

Selenium WebDriver is often used as a basis for testing web applications. Here is a simple example uisng Python’s standard unittest library:

import unittest

class GoogleTestCase(unittest.TestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()
        self.addCleanup(self.browser.quit)

    def testPageTitle(self):
        self.browser.get('http://www.google.com')
        self.assertIn('Google', self.browser.title)

if __name__ == '__main__':
    unittest.main(verbosity=2)

Selenium Server (optional)

For normal WebDriver scripts (non-Remote), the Java server is not needed.

However, to use Selenium Webdriver Remote or the legacy Selenium API (Selenium-RC), you need to also run the Selenium server. The server requires a Java Runtime Environment (JRE).

Download the server separately, from: http://selenium-release.storage.googleapis.com/2.41/selenium-server-standalone-2.41.0.jar

Run the server from the command line:

java -jar selenium-server-standalone-2.41.0.jar

Then run your Python client scripts.

Release history Release notifications

History Node

3.11.0

History Node

3.10.0

History Node

3.9.0

History Node

3.8.1

History Node

3.8.0

History Node

3.7.0

History Node

3.6.0

History Node

3.5.0

History Node

3.4.3

History Node

3.4.2

History Node

3.4.1

History Node

3.4.0

History Node

3.3.3

History Node

3.3.2

History Node

3.3.1

History Node

3.3.0

History Node

3.0.2

History Node

3.0.1

History Node

3.0.0

History Node

3.0.0b3

History Node

3.0.0b2

History Node

3.0.0b1

History Node

2.53.6

History Node

2.53.5

History Node

2.53.4

History Node

2.53.3

History Node

2.53.2

History Node

2.53.1

History Node

2.53.0

History Node

2.52.0

History Node

2.51.1

History Node

2.51.0

History Node

2.50.1

History Node

2.50.0

History Node

2.49.2

History Node

2.49.1

History Node

2.49.0

History Node

2.48.0

History Node

2.47.3

History Node

2.47.2

History Node

2.47.1

History Node

2.47.0

History Node

2.46.1

History Node

2.46.0

History Node

2.45.0

History Node

2.44.0

History Node

2.43.0

History Node

2.42.1

History Node

2.42.0

This version
History Node

2.41.0

History Node

2.40.0

History Node

2.39.0

History Node

2.38.4

History Node

2.38.3

History Node

2.38.2

History Node

2.38.1

History Node

2.38.0

History Node

2.37.2

History Node

2.37.1

History Node

2.37.0

History Node

2.36.0

History Node

2.35.0

History Node

2.34.0

History Node

2.33.0

History Node

2.32.0

History Node

2.31.0

History Node

2.30.0

History Node

2.29.0

History Node

2.28.0

History Node

2.27.0

History Node

2.26.0

History Node

2.25.0

History Node

2.24.0

History Node

2.23.0

History Node

2.22.1

History Node

2.22.0

History Node

2.21.3

History Node

2.21.2

History Node

2.21.1

History Node

2.21.0

History Node

2.20.0

History Node

2.19.1

History Node

2.19.0

History Node

2.18.1

History Node

2.17.0

History Node

2.16.0

History Node

2.15.0

History Node

2.14.0

History Node

2.13.1

History Node

2.13.0

History Node

2.12.1

History Node

2.12.0

History Node

2.11.1

History Node

2.11.0

History Node

2.10.0

History Node

2.9.0

History Node

2.8.1

History Node

2.8.0

History Node

2.7.0

History Node

2.6.0

History Node

2.5.0

History Node

2.4.0

History Node

2.3.0

History Node

2.2.0

History Node

2.1.0

History Node

2.0.1

History Node

2.0.0

History Node

2.0rc3

History Node

2.0rc2

History Node

2.0rc1

History Node

2.0b4dev

History Node

2.0b3

History Node

2.0b3dev

History Node

2.0b2

History Node

2.0a5

History Node

2.0-dev-9429

History Node

2.0-dev-9341

History Node

2.0-dev-9340

History Node

2.0-dev-9338

History Node

2.0-dev-9310

History Node

2.0-dev-9307

History Node

2.0-dev-9306

History Node

2.0-dev-9284

History Node

2.0-dev-9231

History Node

2.0-dev-9212

History Node

2.0-dev-9138

History Node

2.0dev6

History Node

2.0dev5

History Node

2.0dev4

History Node

2.0dev3

History Node

2.0dev2

History Node

2.0dev1

History Node

2.0-dev

History Node

1.0.3

History Node

1.0.1

History Node

0.9.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
selenium-2.41.0.tar.gz (2.5 MB) Copy SHA256 hash SHA256 Source None Mar 28, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page