python

[Python] Pytest fixture example with cleanup and teardown

# Deafult scope=function
@pytest.fixture
def browser():
    # Initialize Chrome driver
    driver = Chrome()

    # Wait implicitly for elements to be ready before attempting interactions
    driver.implicitly_wait(10)

    # Return the driver object at the end of setup
    yield driver

    # For cleanup, quit the driver
    driver.quit()
Was this helpful?