[](https://travis-ci.org/jenterkin/selenium-page-elements)
[](https://codecov.io/gh/jenterkin/selenium-page-elements)
[](https://badge.fury.io/py/selenium-page-elements)
## 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.
```python
# Page Object
from selenium.webdriver.common.by 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):
self.driver.get(LoginPage.url)
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
self.login_button.click()
```
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()`
```python
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.
```python
assert login_page.username.is_displayed()
assert login_page.username.value() == 'mmario'
```
Metadata
Release files for selenium-page-elements 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| selenium_page_elements-0.1.6.tar.gz | 4.2 kB | Without provenance | Details for selenium_page_elements-0.1.6.tar.gz |
Release files / selenium_page_elements-0.1.6.tar.gz
| Download URL | selenium_page_elements-0.1.6.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3806e9e598ebc2f69ca2064581a146416715aab71a14a729c142ba52b43a2cd4
|
|
BLAKE2b-256 checksum How to use checksums |
c72d773bbc15d9e5c3b1450423f958be53ba087a558a58e740802bfcc7d48e88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for selenium-page-elements 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.