Skip to main content

Webdriver Extension with Page Object Wrapper

Reason this release was yanked:

up to date

Project description

Citronella

PyPI version Downloads

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):
        self.web.driver.get('https://pypi.org/')
        self.web.page_object(HomePage)

        self.web.page.help_button.click()
        assert 'Help' in self.web.driver.title

    def test_sponsors_page(self):
        self.web.page.sponsors_button.click()
        assert 'Sponsors' in self.web.driver.title

    def test_login_page(self):
        self.web.page.login_button.click()
        assert 'Log' in self.web.driver.title

    def test_register_page(self):
        self.web.page.register_button.click()
        assert 'Create' in self.web.driver.title

Appium

import pytest
from Pages.api_demos_page import ApiDemosPage


class TestNavigationMenu:

    def test_accessibility_page(self):
        self.web.page_object(ApiDemosPage)

        self.web.page.accessibility_button.click()
        assert self.web.page.accessibility_node_provider_button.get_element().is_visible()

    def test_animation_page(self):
        self.web.back
        self.web.page.animation_button.click()
        assert self.web.page.cloning_button.get_element().is_visible()

    def test_app_page(self):
        self.web.back
        self.web.page.app_button.click()
        assert self.web.page.activity_button.get_element().is_visible()

    def test_os_page(self):
        self.web.back
        self.web.page.os_button.click()
        assert self.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 browser(request):
    driver = webdriver.Chrome()
    web = WebPage(driver)
    request.cls.web = web
    yield
    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 init_driver(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)
    web = WebPage(driver)
    request.cls.web = web
    yield
    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 Selenium Appium
driver example example
page_object example example
page example example
back example example
webdriver_wait example example
ready_state example disabled
ready_state_toggle example disabled
get_window_size example example
sleep example example

citronella.Ui

Args:
  • by
  • value
  • page_object (optional)
Method Lists:
Method Name Selenium Appium
send_keys example example
click example example
is_located example example
get_attribute example example
get_element example example
get_elements example example
text example example

Project details


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.3.tar.gz (13.7 kB view hashes)

Uploaded Source

Built Distribution

citronella-0.0.3-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page