Expanded Selenium WebDriver
Project description
xDriver
Expanded Selenium WebDriver.
Setup & Examples of Usage
- Install the package using the
pip install xdrivercommand. - Create a pytest function scope fixture that will start/close the webdriver before/after each test
conftest.py - Create a test that will use the driver provided by the before-mentioned fixture
test_example.py
Example tests directory structure:
tests/
│
├── conftest.py
└── test_example.py
conftest.py file content:
@pytest.fixture(scope='function')
def driver() -> Driver:
"""
Starts the Driver before test and closes it afterward
"""
driver = Driver(webdriver_type="chromedriver")
yield driver
driver.quit()
test_example.py file content:
from selenium.webdriver.common.by import By
def test_example(driver):
"""
Tests if the example page has the h1 WebElement
"""
driver.get("https://example.com/")
assert driver.check_if_element_exists((By.CSS_SELECTOR, "h1")), "h1 element was not found!"
Additional Information
All available methods can be found in the webdriver.py file. Some examples:
get_element()
get_clickable_element()
check_if_element_exists()
check_if_clickable_element_exists()
hover_over_element()
...
If you ever need to use the default selenium webdriver use driver.driver:
from selenium.webdriver.common.by import By
def test_example_default_webdriver(driver):
"""
Example of default Selenium WebDriver usage
Tests if h1 element is displayed
"""
driver.get("https://example.com/")
h1 = driver.driver.find_element(By.CSS_SELECTOR, "h1")
assert h1.is_displayed(), "h1 element was not displayed!"
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
xdriver-1.2.3.tar.gz
(5.0 kB
view details)
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 xdriver-1.2.3.tar.gz.
File metadata
- Download URL: xdriver-1.2.3.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4d3daea31e46578d4cf637b8cdebe6017df1d7b02913f2b88e3b5ac90dcedd7
|
|
| MD5 |
ea68a3a7720431bd3916b568fbc82bfc
|
|
| BLAKE2b-256 |
2f5405573b7d3ff2788a2a8b93f5e4c23d61b7fca80bad485958fdc13d6f05df
|
File details
Details for the file xdriver-1.2.3-py3-none-any.whl.
File metadata
- Download URL: xdriver-1.2.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d598913680694894d68f0dfe3b8f6b57fc3e88c71139f226421f1bf900291e7
|
|
| MD5 |
e1c89a94102a525206676b58d21cd6e1
|
|
| BLAKE2b-256 |
1f1725e2cadc6424fb5e3e6678fb891a8a43164313a051c39d2373e708c7b9a5
|