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?
JavaScript
x
8
1
from selenium.webdriver import Edge
2
from selenium.webdriver.edge.options import Options
3
4
opts = Options()
5
opts.headless = True
6
browser = Edge(options=opts)
7
# ^^^^^
8
It seems there is no options keyword, and I get an error:
JavaScript
1
5
1
Traceback (most recent call last):
2
File ".tutorial.py", line 6, in <module>
3
browser = Edge(options=opts)
4
TypeError: __init__() got an unexpected keyword argument 'options'
5
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
JavaScript
1
7
1
from msedge.selenium_tools import EdgeOptions
2
3
options = EdgeOptions()
4
options.use_chromium = True
5
6
driver = Edge(options)
7