βœ…py

The main Pylenium fixture

Usage

The py fixture is the recommended way to use Pylenium because it gives each test its own instance of Pylenium which makes it easy to scale and parallelize.

from pylenium.driver import Pylenium

def test_element_should_be_visible(py: Pylenium):
    py.visit("https://demoqa.com/buttons")
    assert py.contains("Click Me").should().be_visible()

Import Pylenium and add the type hint to your test (as shown above) so you get intellisense and autocomplete when writing tests πŸ’ͺ

Arguments

  • none

Yields

  • Pylenium - an instance of Pylenium driver that interacts with the web

py_config

When using py, an instance of PyleniumConfig is also created and can be managed per test. You can access py_config as a fixture or directly from py.config

Access by Fixture

from pylenium.driver import Pylenium
from pylenium.config import PyleniumConfig

def test_element_should_be_visible(py: Pylenium, py_config: PyleniumConfig):
    # Only this test will be against firefox
    py_config.driver.browser = "firefox"
    py.visit("https://demoqa.com/buttons")
    assert py.contains("Click Me").should().be_visible()

Recommended because it's fewer lines of code and you already have access via Pylenium

from pylenium.driver import Pylenium

def test_element_should_be_visible(py: Pylenium):
    # Only this test will be against firefox
    py.config.driver.browser = "firefox"
    py.visit("https://demoqa.com/buttons")
    assert py.contains("Click Me").should().be_visible()

Last updated