What is a fixture in the context of Selenium testing with Python?
A fixture is a setup function that prepares the browser environment before tests run and cleans up after tests finish, ensuring tests start with a fresh browser state.
Click to reveal answer
beginner
Why use fixtures for browser setup and teardown in Selenium tests?
Fixtures help avoid repeating browser setup code in every test, make tests cleaner, and ensure the browser closes properly after tests to free resources.
Click to reveal answer
intermediate
How do you define a fixture in pytest for Selenium browser setup?
Use the @pytest.fixture decorator on a function that creates a browser instance, yields it for tests, and then closes the browser after tests complete.
Click to reveal answer
intermediate
What does the 'yield' keyword do in a pytest fixture for Selenium?
The 'yield' pauses the fixture to run the test using the browser, then resumes to perform cleanup like closing the browser after the test finishes.
Click to reveal answer
beginner
Show a simple pytest fixture example for opening and closing a Chrome browser with Selenium.