Bird
0
0

Which combined approach best solves this problem?

hard📝 Application Q15 of 15
Selenium Python - CI/CD Integration
You want to run Selenium tests in headless mode on a CI server using Chrome, but your tests intermittently fail because some elements are not interactable. Which combined approach best solves this problem?
AEnable headless mode with '--headless=new', add '--disable-gpu', and set a window size with options.add_argument('--window-size=1920,1080')
BUse headless mode without window size and rely on default browser size
CDisable headless mode and run tests with visible browser windows on CI
DAdd '--incognito' mode only without changing headless or window size
Step-by-Step Solution
Solution:
  1. Step 1: Understand headless mode limitations

    Headless mode can cause layout differences; setting window size helps elements render correctly.
  2. Step 2: Use modern headless flag and disable GPU

    Using '--headless=new' enables the latest headless mode in Chrome, and '--disable-gpu' avoids GPU issues in CI.
  3. Step 3: Combine all options for stable tests

    Adding '--window-size=1920,1080' ensures consistent viewport, preventing element interaction failures.
  4. Final Answer:

    Enable headless mode with '--headless=new', add '--disable-gpu', and set a window size with options.add_argument('--window-size=1920,1080') -> Option A
  5. Quick Check:

    Use new headless, disable GPU, and set window size for stable CI tests [OK]
Quick Trick: Set window size and use new headless mode for stable CI tests [OK]
Common Mistakes:
  • Ignoring window size causing element not interactable errors
  • Using old headless mode without '--headless=new'
  • Disabling headless mode defeats CI automation purpose

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes