Skip to main content

Expanded Selenium WebDriver

Project description

xDriver

PyPI - Version PyPI - Python Version

Expanded Selenium WebDriver.

Setup & Examples of Usage

  • Install the package using the pip install xdriver command.
  • Create a pytest function scope fixture that will start/close the webdriver before/after each test conftest.py
  • Create a test that will use the driver provided by the before-mentioned fixture test_example.py

Example tests directory structure:

tests/
│
├── conftest.py
└── test_example.py

conftest.py file content:

@pytest.fixture(scope='function')
def driver() -> Driver:
    """
    Starts the Driver before test and closes it afterward
    """
    driver = Driver(webdriver_type="chromedriver")
    yield driver
    driver.quit()

test_example.py file content:

from selenium.webdriver.common.by import By


def test_example(driver):
    """
    Tests if the example page has the h1 WebElement
    """
    driver.get("https://example.com/")
    assert driver.check_if_element_exists((By.CSS_SELECTOR, "h1")), "h1 element was not found!"

Additional Information

All available methods can be found in the webdriver.py file. Some examples:

get_element()
get_clickable_element()
check_if_element_exists()
check_if_clickable_element_exists()
hover_over_element()
...

If you ever need to use the default selenium webdriver use driver.driver:

from selenium.webdriver.common.by import By


def test_example_default_webdriver(driver):
    """
    Example of default Selenium WebDriver usage 
    Tests if h1 element is displayed
    """
    driver.get("https://example.com/")
    h1 = driver.driver.find_element(By.CSS_SELECTOR, "h1")
    assert h1.is_displayed(), "h1 element was not displayed!"

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

xdriver-1.1.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

xdriver-1.1.1-py3-none-any.whl (4.7 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