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

1

0

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

Retrace answered 21/4, 2021 at 8:55 Comment(0)
E
2

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

Eskisehir answered 21/4, 2021 at 9:20 Comment(3)
@UmangBhatia pleased to hear it and it's up to you entirely, you should use driver = Edge(executable_path='your_driver_path', options=edge_options)Eskisehir
thanks, i was using the wrong Edge class. The issue is resolved nowRetrace
@UmangBhatia please mark the answer like confirmed, and update question a bit to get the upvoteEskisehir

© 2022 - 2024 — McMap. All rights reserved.