Skip to main content

Functions to make life with Selenium easier.

Project description

webdrivertools

A Python library providing utility functions for simplifying interactions with Selenium, the popular web testing and automation framework.

webdrivertools exports three core functions:

  1. click_element_area
  2. find_element
  3. click

These functions can be imported using:

from webdrivertools import click_element_area, find_element, click

Requirements

  • Python 3.10+
  • Selenium

Installation

To install webdrivertools, simply run:

pip install webdrivertools

Functions

click_element_area

click_element_area(driver: WebDriver, element: WebElement) -> None

Click on the element area, even if it is covered by an overlay. This function is useful when dealing with elements obstructed by modal overlays or other overlapping elements, which may cause issues when attempting to interact with the intended element using Selenium.

find_element

find_element(driver: WebDriver | WebElement, value: str, by: str = By.CSS_SELECTOR, innerText: str | None = None) -> WebElement

Find a single HTML element within a webdriver page by attribute or criteria and optional inner text filtering, returning the matched WebElement.

click

click(driver: WebDriver, value: str, by: str = By.CSS_SELECTOR, innerText: str | None = None, retries: int = 3, sleep_between_retries: float = 1) -> None

Click on an element with an optional innerText filter. Number of retries and sleep between retries can be tweaked according to requirements.

Usage

from selenium import webdriver
from selenium.webdriver.common.by import By
from webdrivertools import click, find_element

# Instantiate a WebDriver instance
driver = webdriver.Chrome()

# Navigate to a webpage
driver.get("https://example.com")

# Find and click a button with a specific CSS selector and innerText
click(driver, ".button-class", By.CSS_SELECTOR, "Submit")

# Find an element using an xpath and optional innerText filtering
element = find_element(driver, '//div[contains(@class, "target-element")]', By.XPATH, "Target Text")

# Click on an area of the element even if it's covered by an overlay
click_element_area(driver, element)

# Close the webdriver instance
driver.quit()

License

MIT License

Contributing

Contributions are welcome. Please create a new issue or a pull request with your proposed changes.

Support

If you encounter any issues, please create a new issue on the GitHub repository.

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

webdrivertools-0.0.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

webdrivertools-0.0.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file webdrivertools-0.0.4.tar.gz.

File metadata

  • Download URL: webdrivertools-0.0.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for webdrivertools-0.0.4.tar.gz
Algorithm Hash digest
SHA256 17dd2d9f38fb36cd0a680ef702171537f8e96539ef3c255e27faa818d57703db
MD5 f4cb892e98ac8f49dfc69a4c31428175
BLAKE2b-256 fab51a5b351a66ad7416d936a7f19e69a030070c85d51956e5189e350b7e27b8

See more details on using hashes here.

File details

Details for the file webdrivertools-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for webdrivertools-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ac69a6d8728c2fb5930e8ab480836a4c8865e15d710048710c822006f2481bec
MD5 7589910bcb5ea1d232c066b4ef0160bc
BLAKE2b-256 efb58f0598bde201ec887c096351ed01df0db54a441a4f377fcd752e12cac172

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