Selenium for Python
Introduction
This package is a library designed to simplify your work with Selenium WebDriver and based on py-selenium-auto-core solution.
Supported browsers
- Chrome
Note: Support for popular browsers will be expanded in the future
Supported Python Versions
- Python 3.7-3.12
Installation
If you have pip on your system, you can simply install or upgrade the Python bindings:
pip install -U py-selenium-auto
Alternately, you can download the source distribution from PyPI, unarchive it, and run:
python setup.py install
Template
To start the project using this solution, you can look into py-selenium-auto-template .
Quick start
- Add the dependency in your project
- Create conftest.py file and add the following code:
@pytest.fixture(scope="session", autouse=True)
def setup_session(request):
# TODO: workaround to set calling root path, because pytest runs from the root dir
work_dir = RootPathHelper.current_root_path(__file__)
os.chdir(work_dir)
It's necessary to set root dir for your test directory. It is assumed that your project structure will look like this:
src/
__init__.py
some_code/
tests/ # Any name
__init__.py
resources/
some_code/
- Create instance of Browser in your test:
browser = BrowserServices.Instance.browser
- Use Browser's methods directly for general actions, such as navigation, window resize, scrolling and alerts handling:
browser.maximize()
browser.go_to("https://google.com")
browser.wait_for_page_to_load()
- Use ElementFactory class's methods to get an instance of each element:
my_text_box = BrowserServices.Instance.service_provider.element_factory().get_text_box(Locator.by_xpath("XPATH"), "Name")
Or you can inherit a class from Form class and use existing ElementFactory:
self.my_text_box = self._element_factory.get_text_box(Locator.by_xpath("XPATH"), "Name")
- Call element's methods to perform action with element:
my_text_box.type("example@email.com")
- Quit browser at the end:
browser.quit()
Configuration
This file is used to configure your browser settings, as well as other settings.By default, your solution will use the file from this project.
Copy the following file to your solution in tests/resources to configure it yourself
License
Library's source code is made available under the Apache 2.0 license.
Metadata
Release files for py-selenium-auto 0.4.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_selenium_auto-0.4.7.tar.gz | 37.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_selenium_auto-0.4.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.2 kB
Release files / py_selenium_auto-0.4.7.tar.gz
| Download URL | py_selenium_auto-0.4.7.tar.gz |
|---|---|
| Size | 37.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c228c5e632176a6dfc7ef3d73fd540422fc6c99bc2896722f8229ad8ad05c4fd
|
|
BLAKE2b-256 checksum How to use checksums |
7d07db393290f81e05c0069ad77f21b4288874ce82fef2b5007aefae3d582459
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / py_selenium_auto-0.4.7-py3-none-any.whl
| Download URL | py_selenium_auto-0.4.7-py3-none-any.whl |
|---|---|
| Size | 59.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5ae881ca458d5a915213d0cc6161cd99c0090087a7bd60ee877dbb6a28850e4
|
|
BLAKE2b-256 checksum How to use checksums |
6c5fb470023a034bae91358413cea262e15f440db2ba28a3bffea54ba054b097
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|