Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A small library for simplifying page objects.

Project Description

# Selenium Page Elements

[![Build Status](](
[![PyPI version](](

## Installation
$ pip install selenium-page-elements

## Overview
Selenium Page Elements is a thin wrapper around the Selenium python library that aims to make Page Objects quick and easy to create and maintain by allowing you to define and interact with web elements like object attributes.

# Page Object
from import By
from page_elements import Element, InputField, CheckBox

class LoginPage:
url = "http://localhost/login"

# Define your elements in your class.
username = InputField(By.ID, 'username')
password = InputField(By.ID, 'password')
stay_signed_in = CheckBox(By.ID, 'stay-signed-in')
login_button = Element(By.XPATH, '//button[contains(text(), "Login")]')

def __init__(self, driver):
# Ensure that your page object has a Selenium webdriver in `self.driver`.
self.driver = driver

def open(self):

def login(self, username, password, stay_signed_in=True):
# Use your elements just as you would any Python variable.
self.username = username
self.password = password
self.keep_me_signed_in = stay_signed_in

The element classes take in a Selenium `By` object and a selector, so you can select any element you would be able to with Selenium.

To check the value of an element simply call the element with `.value()`
login_page = LoginPage(driver)
login_page.username = 'mmario'
print(login_page.username.value()) # prints 'mmario'

The reason you have to call `.value()` on the element is because Selenium Page Elements simply returns a monkey-patched Selenium `WebElement` instance. The reason for returning the monkey-patched instance is to give you the flexibility that the Selenium library already gives you, while giving you a shortcut for giving you what you want most of the time. For instance, you can check to make sure that an element is visible and then get the value.
assert login_page.username.is_displayed()
assert login_page.username.value() == 'mmario'

Release History

This version
History Node


History Node


History Node


History Node


History Node


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
(4.2 kB) Copy SHA256 Hash SHA256
Source None Feb 26, 2018

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate