Bird
0
0

You want to run multiple tests using the same browser instance to save time. How should you modify the fixture to achieve this?

hard📝 framework Q15 of 15
Selenium Python - Test Framework Integration (pytest)
You want to run multiple tests using the same browser instance to save time. How should you modify the fixture to achieve this?
AChange fixture scope to 'module' so browser opens once per module
BAdd driver.quit() before yield to close browser early
CRemove yield and return driver directly
DCreate a new fixture for each test to isolate browser
Step-by-Step Solution
Solution:
  1. Step 1: Understand fixture scopes

    Default scope is 'function' which runs fixture per test; 'module' runs once per file.
  2. Step 2: Apply scope to reuse browser

    Setting scope='module' opens browser once for all tests in module, saving time.
  3. Final Answer:

    Change fixture scope to 'module' so browser opens once per module -> Option A
  4. Quick Check:

    Fixture scope controls reuse [OK]
Quick Trick: Use scope='module' to share browser across tests [OK]
Common Mistakes:
  • Closing browser before tests run
  • Removing yield breaks setup/teardown
  • Creating new fixture per test wastes time

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes