Bird
0
0

You want to run Selenium tests headlessly but also capture screenshots. Which approach is correct?

hard📝 Application Q8 of 15
Selenium Python - Cross-Browser Testing
You want to run Selenium tests headlessly but also capture screenshots. Which approach is correct?
AEnable headless mode and use driver.save_screenshot('file.png')
BHeadless mode disables screenshots, so run with UI
CUse driver.get_screenshot() instead of save_screenshot()
DScreenshots only work with Firefox, not Chrome headless
Step-by-Step Solution
Solution:
  1. Step 1: Check if screenshots work in headless mode

    Headless browsers can capture screenshots using save_screenshot method.
  2. Step 2: Evaluate options

    Enable headless mode and use driver.save_screenshot('file.png') correctly enables headless and uses save_screenshot. Others are false or incorrect.
  3. Final Answer:

    Enable headless mode and use driver.save_screenshot('file.png') -> Option A
  4. Quick Check:

    Headless supports save_screenshot() [OK]
Quick Trick: Use save_screenshot() even in headless mode [OK]
Common Mistakes:
  • Thinking screenshots fail in headless
  • Using wrong screenshot method
  • Believing only Firefox supports screenshots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes