Skip to main content

Selenium for Python

Project description

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.

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

py_selenium_auto-0.4.7.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_selenium_auto-0.4.7-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

Details for the file py_selenium_auto-0.4.7.tar.gz.

File metadata

  • Download URL: py_selenium_auto-0.4.7.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for py_selenium_auto-0.4.7.tar.gz
Algorithm Hash digest
SHA256 c228c5e632176a6dfc7ef3d73fd540422fc6c99bc2896722f8229ad8ad05c4fd
MD5 dbc990ce2bd39fe2147737739dc10d3d
BLAKE2b-256 7d07db393290f81e05c0069ad77f21b4288874ce82fef2b5007aefae3d582459

See more details on using hashes here.

File details

Details for the file py_selenium_auto-0.4.7-py3-none-any.whl.

File metadata

File hashes

Hashes for py_selenium_auto-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ae881ca458d5a915213d0cc6161cd99c0090087a7bd60ee877dbb6a28850e4
MD5 498f7d214544b598c92fabd6df85dd3f
BLAKE2b-256 6c5fb470023a034bae91358413cea262e15f440db2ba28a3bffea54ba054b097

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page