Skip to main content

Setup Selenium for automation testing

Project description

setup-selenium-testing

I get tired of having to rewrite the setup logic for selenium drivers in every project. Time to consolidate.

License PyPI Supported Versions Checked with mypy Code style: black Imports: isort Ruff

Issues

Build Status Build Status Build Status Build Status

Basic usage

from setup_selenium import Browser, SetupSelenium

driver = SetupSelenium.create_driver(browser=Browser.CHROME, headless=True)

Advanced usage

from setup_selenium import Browser, SetupSelenium

driver = SetupSelenium.create_driver(
    browser=Browser.CHROME,
    headless=True,
    enable_log_performance=False,
    enable_log_console=False,
    enable_log_driver=False,
    log_dir="./logs",
    binary="/usr/bin/chromium",
    driver_path="/usr/bin/chromedriver",
)

[!NOTE] It is possible to enable the performance and console logging but only for chrome based browsers. This only enables the browser ability. It is up to the tester to handle logging the messages.

Driver installation

from setup_selenium import Browser, SetupSelenium

driver_path, browser_path = SetupSelenium.install_driver(Browser.CHROME, "118.0.5993.70")

Custom logger

import logging
from setup_selenium import Browser, SetupSelenium, set_logger

set_logger(logging.getLogger("your_custom_logger"))
driver = SetupSelenium.create_driver(browser=Browser.CHROME, headless=True)

Instantiating SetupSelenium

While it is possible to use the class directly caution is advised; as the class will create the driver upon instantiation.

from setup_selenium import SetupSelenium

s = SetupSelenium(headless=True)
assert s.driver.service.is_connectable()

Automatic driver and browser installation

This package not only handles setup of the webdriver but also will automatically install the webdriver and/or browser depending on your configuration.

If you do not provide a driver_path argument to create_driver the package will utilize selenium-manager to install the webdriver for the browser type selected.

If the selenium-manager cannot find the install path for the browser type (which is usually in the native install path) it will download a version of the browser and use that.

Passing a valid binary_path will not trigger any download of the browser. Passing a valid driver_path will not trigger any download of the webdriver.

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

setup_selenium_testing-0.1.6.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

setup_selenium_testing-0.1.6-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file setup_selenium_testing-0.1.6.tar.gz.

File metadata

File hashes

Hashes for setup_selenium_testing-0.1.6.tar.gz
Algorithm Hash digest
SHA256 24974796b52b05776ad2037fa99604545cdc008c17634c1353375552fde750de
MD5 9053ac832a236eb9547ca665fe62a4a6
BLAKE2b-256 a70f69ed8c03840c4dad11ec86fad4cd876c798c952c065f39ecc4d1f3e58edd

See more details on using hashes here.

File details

Details for the file setup_selenium_testing-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for setup_selenium_testing-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 460b241f5e84e5c201e3b868d9323cee439f599a2b06e9a5debb45533548b4fe
MD5 62b1a058b4f57fbc27c04f2649d44bee
BLAKE2b-256 d1b316d495d5b34b2b73b573826424837bacedf7e7b8e0ea654d8d5018d58b90

See more details on using hashes here.

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