## Page Object Elements
Dist: [pypi.org](https://pypi.org/project/page-object-elements/)
### 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
```python
@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
```python
@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
```python
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()
```
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/page-object-elements/",
"name": "page-object-elements",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Ranisavljevic Milan",
"author_email": "ramdjaram@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f8/88/22631e920983b2ecfac9bd5bf4d5cba4eb6e9e320e6dcef38395ceac30f7/page-object-elements-0.4.1.tar.gz",
"platform": null,
"description": "## Page Object Elements\n\nDist: [pypi.org](https://pypi.org/project/page-object-elements/)\n\n### Installation\n\n`pip install page-object-elements`\n\n### Aspect Logger\n\nTo customize behaviour of **poe** logger, `poe.ini` should be in the root of project (or in some child dirs). If not\npresent or some of the values aren't set in `poe.ini` (**e.g** `logs_absolute_path`) default values will be applied.\n\n```\npoe.ini\n\n[LOGGER]\nlevel = DEBUG\nlog_name = log\nstdout = True\nlogs_absolute_path = C:\\Users\\<username>\\workspace\\<project>\n```\n\n## Example of use\n\nlocators.py\n\n```python\n@aspect.log\nclass LetsCodeItLocators(object):\n # 1st section\n FIRST_SECTION = (By.XPATH, '//*[@id=\"page\"]/div[2]/div[2]/div/div/div/div/div[1]')\n CAR_SELECT = (By.ID, 'carselect')\n BMV_CB = (By.ID, 'bmwcheck')\n\n # 2nd section\n SECOND_SECTION = (By.XPATH, '//*[@id=\"page\"]/div[2]/div[2]/div/div/div/div/div[2]')\n SWITCH_TAB_EXAMPLE_LBL = (By.XPATH, '//legend[contains(text(), \"Switch Tab Example\")]')\n OPEN_TAB_BTN = (By.ID, 'opentab')\n ENTER_YOUR_NAME_INPUT = (By.CSS_SELECTOR, '[placeholder=\"Enter Your Name\"]')\n\n # 3rd section\n THIRD_SECTION = (By.XPATH, '//*[@id=\"table-example-div\"]')\n WEB_TABLE = (By.XPATH, '//tbody//tr')\n```\n\npage.py\n\n```python\n@aspect.log\nclass FirstSection(SectionElement):\n car_select = SelectElement(LetsCodeItLocators.CAR_SELECT, True)\n bmw_cb = CheckBoxElement(locator=LetsCodeItLocators.BMV_CB, enabled_check=True)\n\n\n@aspect.log\nclass SecondSection(SectionElement):\n open_tab_btn = ScreenElement()\n switch_tab_example_lbl = LabelElement(locator=LetsCodeItLocators.SWITCH_TAB_EXAMPLE_LBL)\n enter_your_name_input = InputElement(locator=LetsCodeItLocators.ENTER_YOUR_NAME_INPUT)\n\n\n@aspect.log\nclass ThirdSection(SectionElement):\n class RowModel(TableElement.TableRowModel):\n\n def __init__(self, container):\n super().__init__(container)\n\n @property\n def author(self):\n return self.column_cell(1)\n\n @property\n def course(self):\n return self.column_cell(2)\n\n @property\n def price(self):\n return self.column_cell(3)\n\n web_table = TableElement(LetsCodeItLocators.WEB_TABLE, RowModel)\n\n\n@aspect.log\nclass LetsCodeIt(BasePage):\n first_section = FirstSection(locator=LetsCodeItLocators.FIRST_SECTION)\n second_section = SecondSection(locator=LetsCodeItLocators.SECOND_SECTION)\n third_section = ThirdSection(locator=LetsCodeItLocators.THIRD_SECTION)\n\n def visit(self):\n self.driver.get('https://courses.letskodeit.com/practice')\n```\n\ntest_letscodeid.py\n\n```python\ndef test_letscodeit(chrome):\n page = LetsCodeIt(chrome)\n page.visit()\n\n '''LABEL'''\n label_text = page.second_section.switch_tab_example_lbl\n print(label_text)\n\n '''INPUT'''\n page.second_section.enter_your_name_input = 'LetsCodeIt'\n\n '''SELECT'''\n page.first_section.car_select = 'Benz'\n print(page.first_section.car_select.text)\n print(page.first_section.car_select.enabled)\n print(page.first_section.car_select())\n\n '''CHECKBOX'''\n page.first_section.bmw_cb = True\n print(page.first_section.bmw_cb.checked)\n print(page.first_section.bmw_cb.enabled)\n print(page.first_section.bmw_cb())\n\n '''TABLE'''\n web_table = page.third_section.web_table\n # print headers\n for row in web_table.headers:\n print(row.author.text, '\\t|', row.course.text, '\\t|', row.price.text)\n # print rows\n for row in web_table.rows:\n print(row.author.text, '\\t|', row.course.text, '\\t|', row.price.text)\n # filter rows by specific value\n for row in web_table.filter_rows_by('course', 'JavaScript Programming Language'):\n print(row.price.text)\n\n '''BUTTON'''\n page.second_section.open_tab_btn.set_locator(LetsCodeItLocators.OPEN_TAB_BTN)\n page.second_section.open_tab_btn.click()\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Page Object Elements",
"version": "0.4.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "394343e75a061b5ed80ce947ab295c5d",
"sha256": "c3e9696396c2a50dd30657c65e8085ef036097f1e8cd1a2247113f10330ea8f4"
},
"downloads": -1,
"filename": "page_object_elements-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "394343e75a061b5ed80ce947ab295c5d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10035,
"upload_time": "2022-12-12T16:57:01",
"upload_time_iso_8601": "2022-12-12T16:57:01.375570Z",
"url": "https://files.pythonhosted.org/packages/cd/21/1b3dd9d99b1443fa57da2a432cdc4f6fe467d9949501b5946fd0b13609a6/page_object_elements-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "7172797fdd93baf845737785aaa167d3",
"sha256": "cdd39a7b71486b96cdc0f002194df46be880dc2a387be8887899c7e3d35cead3"
},
"downloads": -1,
"filename": "page-object-elements-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "7172797fdd93baf845737785aaa167d3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9092,
"upload_time": "2022-12-12T16:57:02",
"upload_time_iso_8601": "2022-12-12T16:57:02.584212Z",
"url": "https://files.pythonhosted.org/packages/f8/88/22631e920983b2ecfac9bd5bf4d5cba4eb6e9e320e6dcef38395ceac30f7/page-object-elements-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-12 16:57:02",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "page-object-elements"
}