pytest-selenium

4.1.0 · active · verified Wed Apr 15

pytest-selenium is a pytest plugin that provides seamless integration for running Selenium-based tests. It offers a function-scoped `selenium` fixture, allowing easy browser automation within pytest tests. The library is currently at version 4.1.0 and is actively maintained with regular updates and improvements, building upon the `pytest` and `selenium` ecosystems.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic pytest test using the `selenium` fixture. The fixture automatically provides a WebDriver instance. To run, specify your desired browser (e.g., Firefox or Chrome) via the `--driver` command-line option. Ensure the corresponding WebDriver executable (e.g., `geckodriver`, `chromedriver`) is in your system's PATH.

import pytest

def test_example_opens_website(selenium):
    """A simple test that opens a website using the selenium fixture."""
    selenium.get('http://www.example.com')
    assert "Example Domain" in selenium.title

# To run: pytest --driver Firefox -v

view raw JSON →