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

Uploaded Source

Built Distribution

selenium_assist-0.3.4-py3-none-any.whl (5.8 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