Webdriver Extension with Page Object Wrapper
Project description
Citronella
Citronella is a selenium and/or appium webdriver extension with page object wrapper for create a tests a bit simple.
Example Test
Selenium
import pytest
from Pages.home.home_page import HomePage
class TestNavigationMenu:
def test_help_page(self, web):
web.driver.get('https://pypi.org/')
web.page_object(HomePage)
web.page.help_button.click()
assert 'Help' in web.driver.title
def test_sponsors_page(self, web):
web.page.sponsors_button.click()
assert 'Sponsors' in web.driver.title
def test_login_page(self, web):
web.page.login_button.click()
assert 'Log' in web.driver.title
def test_register_page(self, web):
web.page.register_button.click()
assert 'Create' in web.driver.title
Appium
import pytest
from Pages.api_demos_page import ApiDemosPage
class TestNavigationMenu:
def test_accessibility_page(self, web):
web.page_object(ApiDemosPage)
web.page.accessibility_button.click()
assert web.page.accessibility_node_provider_button.get_element().is_visible()
def test_animation_page(self, web):
web.back
web.page.animation_button.click()
assert web.page.cloning_button.get_element().is_visible()
def test_app_page(self, web):
web.back
web.page.app_button.click()
assert web.page.activity_button.get_element().is_visible()
def test_os_page(self, web):
web.back
web.page.os_button.click()
assert web.page.morse_code_button.get_element().is_visible()
Install Package
pip install citronella
Documentation
There's only 3 modules import in this package.
- first module for
conftest.py
Selenium
import pytest
from selenium import webdriver
from citronella import WebPage
@pytest.fixture(autouse=True, scope='class')
def web(request):
driver = webdriver.Chrome()
yield WebPage(driver)
driver.quit()
Appium
import pytest
import os
from appium import webdriver
from appium.options.android import UiAutomator2Options
from citronella import WebPage
@pytest.fixture(autouse='true', scope='class')
def web(request):
options = UiAutomator2Options()
options.platformName = 'Android'
options.app = os.getcwd() + '/APK/ApiDemos-debug.apk.zip'
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', options=options)
yield WebPage(driver)
driver.quit()
- second and third module for
Page Object Model
Selenium
from selenium.webdriver.common.by import By
from citronella import Ui, PlaceholderPage
from Pages.component.HeaderMenu import HeaderMenu
class HomePage(HeaderMenu):
def some_button(self):
return Ui(By.XPATH, '//a[@name="foo"]')
def search_input(self):
return Ui(By.ID, 'search')
def search_button(self):
from Pages.SearchPage import SearchPage
return Ui(By.NAME, 'search-button', SearchPage)
def link_to_somewhere_currently_dont_have_page_object(self):
return Ui(By.NAME, 'search-button', PlaceholderPage)
Appium
from appium.webdriver.common.appiumby import AppiumBy
from citronella import Ui, PlaceholderPage
from Pages.component.HeaderMenu import HeaderMenu
class HomePage(HeaderMenu):
def some_button(self):
return Ui(AppiumBy.XPATH, '//a[@name="foo"]')
def search_input(self):
return Ui(AppiumBy.ACCESSIBILITY_ID, 'search')
def search_button(self):
from Pages.SearchPage import SearchPage
return Ui(AppiumBy.ID, 'search-button', SearchPage)
def link_to_somewhere_currently_dont_have_page_object(self):
return Ui(AppiumBy.ACCESSIBILITY_ID, 'search-button', PlaceholderPage)
Usage
citronella.WebPage
Args:
- webdriver
Method Lists:
Method Name | Args* | Kwargs** | Note |
---|---|---|---|
driver | None | None | |
page_object | Page Object | get_start=(Bool) | Page Object must contain 'ACTIVITY' variable with URL value if using Kwargs** |
page | None | None | |
back | None | None | |
webdriver_wait | Number(sec) | None | |
ready_state | None | None | |
ready_state_toggle | None | None | |
get_window_size | None | None | |
sleep | Number(sec) | None |
citronella.Ui
Args:
- by
- value
- page_object (optional)
Method Lists:
Method Name | Args* | Kwargs** | Note |
---|---|---|---|
send_keys | String | clear=(Bool) | |
click | None | switch_page=(Bool) | |
is_located | None | None | |
get_attribute | String | None | |
get_element | None | None | |
get_elements | None | None | |
text | None | None |
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
citronella-0.0.4.tar.gz
(13.5 kB
view hashes)
Built Distribution
citronella-0.0.4-py3-none-any.whl
(13.0 kB
view hashes)
Close
Hashes for citronella-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f10e4bc3699d0344e79e08b267243a656752c4f85fd7df00861f91031417dd7 |
|
MD5 | 33483bfce9ee30d207aad7566e81962a |
|
BLAKE2b-256 | cbcd6328174455eaa5c96caba182bcecc51296900e7ac6701186fd960bfa9456 |