Page Object Elements
Project description
Page Object Elements
Dist: pypi.org
Installation
pip install page-object-elements
Aspect Logger
To customize behaviour of poe logger, poe.ini should be in the root of project (or in some child dirs). If not
present or some of the values aren't set in poe.ini (e.g logs_absolute_path) default values will be applied.
poe.ini
[LOGGER]
level = DEBUG
log_name = log
stdout = True
logs_absolute_path = C:\Users\<username>\workspace\<project>
Example of use
locators.py
@aspect.log
class LetsCodeItLocators(object):
# 1st section
FIRST_SECTION = (By.XPATH, '//*[@id="page"]/div[2]/div[2]/div/div/div/div/div[1]')
CAR_SELECT = (By.ID, 'carselect')
BMV_CB = (By.ID, 'bmwcheck')
# 2nd section
SECOND_SECTION = (By.XPATH, '//*[@id="page"]/div[2]/div[2]/div/div/div/div/div[2]')
SWITCH_TAB_EXAMPLE_LBL = (By.XPATH, '//legend[contains(text(), "Switch Tab Example")]')
OPEN_TAB_BTN = (By.ID, 'opentab')
ENTER_YOUR_NAME_INPUT = (By.CSS_SELECTOR, '[placeholder="Enter Your Name"]')
# 3rd section
THIRD_SECTION = (By.XPATH, '//*[@id="table-example-div"]')
WEB_TABLE = (By.XPATH, '//tbody//tr')
page.py
@aspect.log
class FirstSection(SectionElement):
car_select = SelectElement(LetsCodeItLocators.CAR_SELECT, True)
bmw_cb = CheckBoxElement(locator=LetsCodeItLocators.BMV_CB, enabled_check=True)
@aspect.log
class SecondSection(SectionElement):
open_tab_btn = ScreenElement()
switch_tab_example_lbl = LabelElement(locator=LetsCodeItLocators.SWITCH_TAB_EXAMPLE_LBL)
enter_your_name_input = InputElement(locator=LetsCodeItLocators.ENTER_YOUR_NAME_INPUT)
@aspect.log
class ThirdSection(SectionElement):
class RowModel(TableElement.TableRowModel):
def __init__(self, container):
super().__init__(container)
@property
def author(self):
return self.column_cell(1)
@property
def course(self):
return self.column_cell(2)
@property
def price(self):
return self.column_cell(3)
web_table = TableElement(LetsCodeItLocators.WEB_TABLE, RowModel)
@aspect.log
class LetsCodeIt(BasePage):
first_section = FirstSection(locator=LetsCodeItLocators.FIRST_SECTION)
second_section = SecondSection(locator=LetsCodeItLocators.SECOND_SECTION)
third_section = ThirdSection(locator=LetsCodeItLocators.THIRD_SECTION)
def visit(self):
self.driver.get('https://courses.letskodeit.com/practice')
test_letscodeid.py
def test_letscodeit(chrome):
page = LetsCodeIt(chrome)
page.visit()
'''LABEL'''
label_text = page.second_section.switch_tab_example_lbl
print(label_text)
'''INPUT'''
page.second_section.enter_your_name_input = 'LetsCodeIt'
'''SELECT'''
page.first_section.car_select = 'Benz'
print(page.first_section.car_select.text)
print(page.first_section.car_select.enabled)
print(page.first_section.car_select())
'''CHECKBOX'''
page.first_section.bmw_cb = True
print(page.first_section.bmw_cb.checked)
print(page.first_section.bmw_cb.enabled)
print(page.first_section.bmw_cb())
'''TABLE'''
web_table = page.third_section.web_table
# print headers
for row in web_table.headers:
print(row.author.text, '\t|', row.course.text, '\t|', row.price.text)
# print rows
for row in web_table.rows:
print(row.author.text, '\t|', row.course.text, '\t|', row.price.text)
# filter rows by specific value
for row in web_table.filter_rows_by('course', 'JavaScript Programming Language'):
print(row.price.text)
'''BUTTON'''
page.second_section.open_tab_btn.set_locator(LetsCodeItLocators.OPEN_TAB_BTN)
page.second_section.open_tab_btn.click()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file page-object-elements-0.4.1.tar.gz.
File metadata
- Download URL: page-object-elements-0.4.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdd39a7b71486b96cdc0f002194df46be880dc2a387be8887899c7e3d35cead3
|
|
| MD5 |
7172797fdd93baf845737785aaa167d3
|
|
| BLAKE2b-256 |
f88822631e920983b2ecfac9bd5bf4d5cba4eb6e9e320e6dcef38395ceac30f7
|
File details
Details for the file page_object_elements-0.4.1-py3-none-any.whl.
File metadata
- Download URL: page_object_elements-0.4.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3e9696396c2a50dd30657c65e8085ef036097f1e8cd1a2247113f10330ea8f4
|
|
| MD5 |
394343e75a061b5ed80ce947ab295c5d
|
|
| BLAKE2b-256 |
cd211b3dd9d99b1443fa57da2a432cdc4f6fe467d9949501b5946fd0b13609a6
|