Skip to main content

Selenium for Python

Latest Version License Supported Python versions Build Status Coverage Status Supported Python implementations Code Style

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

  1. Add the dependency in your project
  2. 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/
  1. Create instance of Browser in your test:
browser = BrowserServices.Instance.browser
  1. 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()
  1. 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")
  1. Call element's methods to perform action with element:
my_text_box.type("example@email.com")
  1. 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)

Source distribution for py-selenium-auto 0.4.7
File Size Uploaded
py_selenium_auto-0.4.7.tar.gz 37.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-selenium-auto 0.4.7
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.4.7 This release

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

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