TypeError: __init__() got an unexpected keyword argument 'options' while using EdgeOptions

11.9k Views Asked by At

Hi I trying to run the below code for Edge Driver version Version 90.0.818.42 which is Chromium Based:

from selenium import webdriver
from msedge.selenium_tools import EdgeOptions

dirpath = os.getcwd()

edge_driver_path_used = dirpath + r'/features/resources/drivers/msedgedriver.exe'

my_edge_option = EdgeOptions()
my_edge_option.use_chromium = True
my_edge_option.binary_location = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
edge_driver = webdriver.Edge(options=my_edge_option)

edge_driver.get('My URL Here')

Upon running this code I am getting the below exception:

edge_driver = webdriver.Edge(options=my_edge_option)
TypeError: __init__() got an unexpected keyword argument 'options'

I don't seem to miss any import, then why am I getting this Exception? Kindly help me out

1

There are 1 best solutions below

3
On

Seems like here's solution to your question: How to run Microsoft Edge headless with Selenium Python?

  options = EdgeOptions()
  options.use_chromium = True

install the addition package like:

pip install msedge-selenium-tools

and initialize driver with:

from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge

# Edge in headless mode
edge_options = EdgeOptions()
edge_options.use_chromium = True
driver = Edge(executable_path='your_driver_path', options=edge_options)

Here's official docs: https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=python