{"id":6830,"library":"pytest-selenium","title":"pytest-selenium","description":"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.","status":"active","version":"4.1.0","language":"en","source_language":"en","source_url":"https://github.com/pytest-dev/pytest-selenium","tags":["pytest","selenium","testing","browser-automation","qa","webqa"],"install":[{"cmd":"pip install pytest-selenium","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core testing framework that pytest-selenium extends.","package":"pytest","optional":false},{"reason":"Provides WebDriver API for browser automation.","package":"selenium","optional":false}],"imports":[{"note":"The 'selenium' fixture is automatically discovered and provided by the plugin; no explicit import statement from 'pytest_selenium' is typically needed in test files.","symbol":"selenium (fixture)","correct":"def test_example(selenium): ..."},{"note":"Used to mark tests that do not make destructive changes, avoiding accidental skipping in sensitive environments.","symbol":"pytest.mark.nondestructive","correct":"import pytest\n\n@pytest.mark.nondestructive\ndef test_something_nondestructive(selenium): ..."}],"quickstart":{"code":"import pytest\n\ndef test_example_opens_website(selenium):\n    \"\"\"A simple test that opens a website using the selenium fixture.\"\"\"\n    selenium.get('http://www.example.com')\n    assert \"Example Domain\" in selenium.title\n\n# To run: pytest --driver Firefox -v","lang":"python","description":"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."},"warnings":[{"fix":"Migrate cloud provider credentials to new, separate configuration files (e.g., `.saucelabs`, `.browserstack`). Refer to the official documentation for specific file names and formats. Environment variables remain an unaffected method for credential management.","message":"Cloud testing provider credentials were moved from generic configuration files (e.g., `pytest.ini`) to dedicated provider-specific files for improved security in versions 4.0.0/4.0.1.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"To prevent skipping, explicitly mark nondestructive tests with `@pytest.mark.nondestructive` or configure the `sensitive_url` regular expression in `pytest.ini` to exclude your non-sensitive test environments.","message":"By default, `pytest-selenium` assumes all tests are 'destructive' and all environments are 'sensitive' (matching any URL), causing tests to be skipped.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Download the appropriate WebDriver executable for your browser and operating system, then add its directory to your system's PATH. Alternatively, you can use tools like `webdriver-manager` with direct Selenium WebDriver initialization or configure specific driver paths if `pytest-selenium` allows for it (often handled by `pytest-selenium`'s underlying Selenium setup).","message":"Selenium WebDriver requires browser driver executables (e.g., `chromedriver`, `geckodriver`) to be available in the system's PATH or explicitly configured, otherwise browser launch will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When directly specifying browser capabilities, use browser-specific `Options` classes (e.g., `selenium.webdriver.ChromeOptions`, `selenium.webdriver.FirefoxOptions`) instead of `DesiredCapabilities`.","message":"With Selenium 4, the `DesiredCapabilities` class is deprecated in favor of browser-specific `Options` classes (e.g., `ChromeOptions`, `FirefoxOptions`) for configuring browser capabilities. While `pytest-selenium` abstracts some of this, direct interaction with capabilities may be affected.","severity":"deprecated","affected_versions":"Selenium 4 and later (indirectly affects pytest-selenium users)"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}