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!
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.