Skip to main content

Helper functions for Selenium

Project description

selenium-assist

PyPI PyPI - License Code style: black

Python package for easy writing of Selenium scripts.

Implemented helper functions:

  • connect_webdriver
  • load_page
  • wait_for_presence
  • wait_for_visibility
  • click_element
  • send_keys
  • hoover_over_element
  • switch_to_iframe
  • get_table_data
  • get_element_text
  • execute_script

install

pip install selenium-assist

usage

import time
import selenium_assist as sa
from selenium.webdriver.common.keys import Keys
import logging


# setup and silence loggers
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("selenium.webdriver.remote.remote_connection").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)

# connect webdriver (use False for headless mode)
driver = sa.connect_webdriver(True)

# do stuff
sa.load_page("Loading initial webpage ...", "https://google.com/ncr", driver)
sa.wait_for_presence("Waiting for Accept all ...", '//*[@id="L2AGLb"]', driver, extra_timeout=1)
sa.click_element("Clicking Accept all ...", '//*[@id="L2AGLb"]', driver)
sa.wait_for_presence("Waiting for Google Search ...", '//*[@id="APjFqb"]', driver)
sa.click_element("Clicking search box ...", '//*[@id="APjFqb"]', driver)
sa.send_keys("Sending text ...", '//*[@id="APjFqb"]', "news" + Keys.ENTER, driver, skip_check=True)

# close webdriver
logging.debug("Done with webdriver, sleeping 3s and exiting ...")
time.sleep(3)
driver.close()

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

selenium_assist-0.3.3.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenium_assist-0.3.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file selenium_assist-0.3.3.tar.gz.

File metadata

  • Download URL: selenium_assist-0.3.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for selenium_assist-0.3.3.tar.gz
Algorithm Hash digest
SHA256 7f07b1d72bde46a891f3793ac492294547e0de1e8444c9b422e6f06391ae371c
MD5 83bf924f6d584faefcd82c2b3954c139
BLAKE2b-256 ac1f86cae5a17d4c2c807241ca8b884962acaae02258a1c3ebff14f8979c1df1

See more details on using hashes here.

File details

Details for the file selenium_assist-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for selenium_assist-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 df6e28b439f66d592defdb9d3043a21bbc15b04dc77cebf256e0f7869f27f3c1
MD5 97f2ef016069a2af9eec33709e892457
BLAKE2b-256 088d022e094064a58340562f3a0c855a6ce0b14ab75e958770ba52d87d8bb0d5

See more details on using hashes here.

Supported by

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