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.
Instantiating SetupSelenium
This will automatically handle any downloading of drivers or browsers via SeleniumManager
from setup_selenium import SetupSelenium
s = SetupSelenium(headless=True)
assert s.driver.service.is_connectable()
Advanced usage:
from setup_selenium import Browser, SetupSelenium
s = SetupSelenium(Browser.FIREFOX, headless=True, driver_version="118.0.5993.70")
s = SetupSelenium(Browser.CHROME, headless=True, driver_version="118.0.5993.70",
driver_path="/path/to/webdriver"
)
[!NOTE] Version and path arguments follow the logic of SeleniumManager. Caution is advised in cases where version and path do not match. See their documentation.
Install Driver only
from setup_selenium import Browser, SetupSelenium
driver_path, browser_path = SetupSelenium.install_driver(Browser.CHROME, driver_version="118.0.5993.70")
Create driver only
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.
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)
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.
CHANGELOG
version 1.0.5
- updated throttling functions
version 1.0.2
- removed python 3.8 support
version 1.0.1
- removed
--remote-debugging-pipefrom default chrome options (causes older chrome to crash)
version 1.0.0
- official release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file setup_selenium_testing-1.0.5.tar.gz.
File metadata
- Download URL: setup_selenium_testing-1.0.5.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
474b59008ad6c6efb83c53a7f4f785d5b7871567f501e8dfd07762d2e8fad0ca
|
|
| MD5 |
839b8730f6b84ba2ba3551e845554088
|
|
| BLAKE2b-256 |
26a8f6a75e62da324f259faef61ce71965a16e6adb4d1533c40c4ce9f848c319
|
Provenance
The following attestation bundles were made for setup_selenium_testing-1.0.5.tar.gz:
Publisher:
publish.yml on bandophahita/setup_selenium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setup_selenium_testing-1.0.5.tar.gz -
Subject digest:
474b59008ad6c6efb83c53a7f4f785d5b7871567f501e8dfd07762d2e8fad0ca - Sigstore transparency entry: 337766346
- Sigstore integration time:
-
Permalink:
bandophahita/setup_selenium@57a70f7191585324ee717c68bfd0dbd8ef3b24f2 -
Branch / Tag:
refs/tags/1.0.5 - Owner: https://github.com/bandophahita
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57a70f7191585324ee717c68bfd0dbd8ef3b24f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file setup_selenium_testing-1.0.5-py3-none-any.whl.
File metadata
- Download URL: setup_selenium_testing-1.0.5-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80ff44cd22de04d02d5a691f445b5ed2c1a5871f3b56328a180b680fc049677
|
|
| MD5 |
a32d72167d09509a0c4aa6d7bec799c9
|
|
| BLAKE2b-256 |
ccc270df6113c6157a30db3c6cd148dc544c7d4bf56b7df4b240aeab71856a5c
|
Provenance
The following attestation bundles were made for setup_selenium_testing-1.0.5-py3-none-any.whl:
Publisher:
publish.yml on bandophahita/setup_selenium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
setup_selenium_testing-1.0.5-py3-none-any.whl -
Subject digest:
e80ff44cd22de04d02d5a691f445b5ed2c1a5871f3b56328a180b680fc049677 - Sigstore transparency entry: 337766364
- Sigstore integration time:
-
Permalink:
bandophahita/setup_selenium@57a70f7191585324ee717c68bfd0dbd8ef3b24f2 -
Branch / Tag:
refs/tags/1.0.5 - Owner: https://github.com/bandophahita
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57a70f7191585324ee717c68bfd0dbd8ef3b24f2 -
Trigger Event:
push
-
Statement type: