Bird
0
0

Identify the error in the following Edge driver setup code:

medium📝 Debug Q14 of 15
Selenium Python - Cross-Browser Testing
Identify the error in the following Edge driver setup code:
from selenium import webdriver
from selenium.webdriver.edge.options import Options

options = Options()
options.add_argument('--headless')
driver = webdriver.Edge(options=options, executable_path='msedgedriver.exe')
AMissing import for Service class
BOptions() cannot be used with headless argument
CUsing 'executable_path' parameter is deprecated; should use Service()
DDriver initialization syntax is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check driver initialization parameters

    The executable_path parameter is deprecated in recent Selenium versions for Edge.
  2. Step 2: Use Service() to specify driver location

    The correct way is to create a Service object with the driver path and pass it via the service parameter.
  3. Final Answer:

    Using 'executable_path' parameter is deprecated; should use Service() -> Option C
  4. Quick Check:

    Use Service() for driver path, not executable_path [OK]
Quick Trick: Use Service() for driver path, not executable_path [OK]
Common Mistakes:
  • Using deprecated executable_path parameter
  • Not importing Service class
  • Thinking Options() disallows headless

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes