Bird
0
0

You want to run Selenium tests in parallel on Chrome and Firefox browsers in your CI pipeline using Python. Which approach correctly sets up parallel execution for both browsers?

hard📝 framework Q15 of 15
Selenium Python - CI/CD Integration
You want to run Selenium tests in parallel on Chrome and Firefox browsers in your CI pipeline using Python. Which approach correctly sets up parallel execution for both browsers?
ARun tests sequentially by switching browser drivers inside a single test function.
BUse ThreadPoolExecutor to run a test function twice, each time initializing a different browser driver inside the function.
CUse a single WebDriver instance shared by all tests to save memory.
DRun tests in parallel but initialize browsers outside the test functions to avoid overhead.
Step-by-Step Solution
Solution:
  1. Step 1: Understand parallel testing with multiple browsers

    Each test must create its own browser driver instance to avoid conflicts.
  2. Step 2: Use ThreadPoolExecutor to run tests in parallel

    Running test functions in parallel, each initializing its own browser, allows simultaneous testing on Chrome and Firefox.
  3. Final Answer:

    Use ThreadPoolExecutor to run a test function twice, each time initializing a different browser driver inside the function. -> Option B
  4. Quick Check:

    Separate drivers per thread = correct parallel setup [OK]
Quick Trick: Initialize browser inside each parallel test function [OK]
Common Mistakes:
  • Sharing one WebDriver instance across threads
  • Switching browsers sequentially defeats parallelism
  • Initializing browsers outside test functions causes conflicts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes