Bird
0
0

What will happen if a fixture does not include a yield statement but calls driver.quit() at the end?

medium📝 Predict Output Q5 of 15
Selenium Python - Test Framework Integration (pytest)
What will happen if a fixture does not include a yield statement but calls driver.quit() at the end?
AThe browser will stay open until the test finishes.
BThe browser will close immediately after setup, before the test runs.
CThe test will fail with a syntax error.
DThe fixture will run twice for each test.
Step-by-Step Solution
Solution:
  1. Step 1: Understand fixture without yield

    Without yield, the fixture runs all code before the test starts, including driver.quit().
  2. Step 2: Effect on browser lifecycle

    Calling driver.quit() immediately closes the browser before the test can use it.
  3. Final Answer:

    The browser will close immediately after setup, before the test runs. -> Option B
  4. Quick Check:

    Without yield, teardown runs too early [OK]
Quick Trick: Use yield to separate setup and teardown [OK]
Common Mistakes:
  • Assuming browser stays open without yield
  • Expecting syntax error without yield
  • Thinking fixture runs multiple times due to missing yield

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes