Bird
0
0

Which of the following is the correct way to add headless mode to Chrome using Selenium in Python?

easy📝 Syntax Q12 of 15
Selenium Python - Cross-Browser Testing
Which of the following is the correct way to add headless mode to Chrome using Selenium in Python?
Aoptions.add_argument('--headless')
Boptions.set_headless(True)
Coptions.add_argument('headless')
Doptions.headless = True
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct syntax for headless argument

    In Selenium, Chrome headless mode is enabled by adding the argument '--headless' with two dashes.
  2. Step 2: Check each option's correctness

    options.add_argument('headless') misses dashes, options.set_headless(True) and D are invalid methods or attributes for Chrome Options.
  3. Final Answer:

    options.add_argument('--headless') -> Option A
  4. Quick Check:

    Headless argument needs '--' prefix [OK]
Quick Trick: Use '--headless' with add_argument() for headless mode [OK]
Common Mistakes:
  • Omitting dashes in argument string
  • Using non-existent methods like set_headless()
  • Assigning headless attribute directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes