Bird
0
0

Which pytest decorator is used to define a fixture for browser setup and teardown?

easy📝 Conceptual Q2 of 15
Selenium Python - Test Framework Integration (pytest)
Which pytest decorator is used to define a fixture for browser setup and teardown?
A@pytest.browser
B@pytest.test
C@pytest.fixture
D@pytest.setup
Step-by-Step Solution
Solution:
  1. Step 1: Recall pytest fixture syntax

    Pytest uses the @pytest.fixture decorator to mark functions as fixtures.
  2. Step 2: Match the decorator to browser setup

    To create setup/teardown logic, the function must be decorated with @pytest.fixture.
  3. Final Answer:

    @pytest.fixture -> Option C
  4. Quick Check:

    Fixture decorator = @pytest.fixture [OK]
Quick Trick: Use @pytest.fixture to create setup/teardown functions [OK]
Common Mistakes:
  • Using @pytest.test instead of @pytest.fixture
  • Assuming @pytest.browser is valid
  • Confusing @pytest.setup with fixture decorator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes