Skip to main content

Page Objects for Python

Project description

Page Objects are a testing pattern for websites. Page Objects model a page on your site to provide accessors and methods for interacting with this page, both to reduce boilerplate and provide a single place for element locators.

This project is an implementation of this pattern for Python using Selenium webdriver. It is agnostic to test harnesses and designed to help you build up libraries of code to test your sites.


Quick Example

>>> from page_objects import PageObject, PageElement
>>> from selenium import webdriver
>>> class LoginPage(PageObject):
        username = PageElement(id_='username')
        password = PageElement(name='password')
        login = PageElement(css='input[type="submit"]')
>>> driver = webdriver.PhantomJS()
>>> driver.root_uri = ""
>>> page = LoginPage(driver)
>>> page.get("/login")
>>> page.username = 'secret'
>>> page.password = 'squirrel'
>>> assert page.username.text == 'secret'


$ pip install page_objects

Project History

This was originally part of the pkglib project at, it has been forked to retain history.

Release History

1.1.0 (2014-10-15)

  • Added feature: PageElements can now be contructed with context

  • Deprecated page_element and mutli_page_element factory methods

1.0.1 (2014-09-30)

  • Added PageObject.get(uri) method, based off of the page’s root_uri attribute.

1.0.0 (2014-09-29)

Project details

Download files

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

Source Distribution

page-objects-1.1.0.tar.gz (4.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page