Skip to main content

EasySelenium

Table of Contents

  1. Overview
  2. Configuration
  3. Usage
    1. Web Driver Class
    2. Automatically Updating Chromedriver
  4. Contributing

Overview

The EasySelenium project is designed to make the Selenium module a little bit easier to use. It supports automatic chromedriver updates, and shorter syntax for finding_elements.

Modules

The two main funtions of the module can be imported using

from seleniumeasy import WebDrvier
from seleniumeasy import update_driver

Configuration

To easily download all repo code onto your local machine download the selenium-easy module from pip

pip install seleniumeasy

Usage

WebDriver Class Usage

The WebDriver class is designed to simplify Selenium programming by reducing tedious syntax. Below are the usage instructions and examples.

Initialization

from seleniumeasy import WebDriver

# Initialize WebDriver with default settings
driver = WebDriver()

# Initialize WebDriver in headless mode
driver = WebDriver(headless=True)

# Initialize WebDriver with a custom memory structure
driver = WebDriver(memory_structure={})

#Initialize WebDriver, using the specified chromedriver service
driver = WebDriver(headless = True, CHROMEDRIVER_PATH=/c/some/path/to/chromedriver.exe)

Parameters

  • headless: A boolean to determine whether the opened page will be visible. If True, the browser will run in headless mode (no GUI). Defaults to False.
  • memory_structure: A data structure to hold values for later use. Defaults to an empty list.
  • CHROMEDRIVER_PATH: The path to your chromedriver.exe, by default will assume the current working directory.

Methods

find_element_by_id

element = driver.find_element_by_id('element_id', wait=10, errors='raise')
  • id: The ID of the element to find.
  • wait: Time in seconds to wait for the element to be present. Defaults to None.
  • errors: Error handling strategy. If 'raise', an exception will be raised on error. If 'coerce', the error will be printed and the program will continue.

find_elements_by_id

elements = driver.find_elements_by_id('element_id', wait=10, errors='raise')
  • id: The ID of the elements to find.
  • wait: Time in seconds to wait for the elements to be present. Defaults to None.
  • errors: Error handling strategy. If 'raise', an exception will be raised on error. If 'coerce', the error will be printed and the program will continue.

EasySelenium can also be used to search by class, css selector, and by xpath with similar syntax, using:

  • find_element_by_class and find_elements_by_class to search by class
  • find_element_by_css and find_elements_by_cssto search by css selector
  • find_element_by_xpath and find_elements_by_xpath to search by xpath

get_soup

#Returns a BeautifulSoup html parser of the JS-rendered page. 
soup = driver.get_soup()

Example Usage

from seleniumeasy import WebDriver

with WebDriver(headless=True) as driver:
    driver.get('https://example.com')

    #This may not exist on the website, so in that case we'll just log that it wasn't found instead of halting the program
    element = driver.find_element_by_id('example_id', wait=10, errors='coerce')
    print(element.text if element else "Element not found")

    #This is essential for the program to run, raise an error if not found
    elements = driver.find_elements_by_class('example_class', wait=10, errors='raise')
    for elem in elements:
        print(elem.text)
    #Create a BeautifulSoup parser of the driver (post JS-rendering)
    soup = driver.get_soup()

Updating Chromedriver

The update_driver function allows you to automatically download the most recent version of the chromedriver for an input Operating System.

Platforms

The available platforms are:

  • linux64
  • mac-arm64
  • mac-x64
  • win32
  • win64

Example Usage

from seleniumeasy import update_driver

# Update chromedriver for Windows 64-bit
update_driver('win64')

# Update chromedriver for macOS ARM64
update_driver('mac-arm64')

This will download the most recent chromedriver for the specified platform to the current working directory. It is an intended future update to customize the driver download/launch locations for each project.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Metadata

Release files for seleniumeasy 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seleniumeasy 0.1.2
File Size Uploaded Provenance
seleniumeasy-0.1.2.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for seleniumeasy 0.1.2
File Interpreter ABI Platform
seleniumeasy-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / seleniumeasy-0.1.2.tar.gz

Download URL seleniumeasy-0.1.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
894d85f021e1d6799022c972c174bd0a5f2b10d2504963636752a54e1020b3c8
BLAKE2b-256 checksum
How to use checksums
9c248ef5d966eded41544dfbc396fdcfe278729c3c5b3866cad4e59071bb6cce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / seleniumeasy-0.1.2-py3-none-any.whl

Download URL seleniumeasy-0.1.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c5aa7c90cb15269a918a9be70e12a2a7af476717fdc6d954c17b1626072a2b0
BLAKE2b-256 checksum
How to use checksums
006600c390602ad2c6fdcbe0070a10d8d50e7432fd53b4fbbcc51c86e48a74d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Security for seleniumeasy 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page