I have been following tutorials, and I came up on Firefox, and using Options()
, I could set headless mode while defining browser (browser = Firefox(options=opts)
), but for Firefox only. I downloaded the driver for the new chromium Edge, but I cannot seem to set the options=
keyword in Edge()
. Can anyone tell me how do I set the options while defining the browser?
from selenium.webdriver import Edge from selenium.webdriver.edge.options import Options opts = Options() opts.headless = True browser = Edge(options=opts) # ^^^^^
It seems there is no options keyword, and I get an error:
Traceback (most recent call last): File ".tutorial.py", line 6, in <module> browser = Edge(options=opts) TypeError: __init__() got an unexpected keyword argument 'options'
Any help will be appreciated. Thanks in advance!
Advertisement
Answer
For Edge Chromium you need to install msedge-selenium-tools package for python and then you can initialize the driver
from msedge.selenium_tools import EdgeOptions options = EdgeOptions() options.use_chromium = True driver = Edge(options)