[英]How to set options for chromium Edge() in Selenium?
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.我一直在关注教程,我想到了 Firefox,并使用
Options()
,我可以在定义浏览器时设置无头模式 ( browser = Firefox(options=opts)
),但仅适用于Firefox 。 I downloaded the driver for the new chromium Edge, but I cannot seem to set the options=
keyword in Edge()
.我下载了新的 chromium Edge 的驱动程序,但我似乎无法在
Edge()
中设置options=
关键字。 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对于 Edge Chromium 需要安装 msedge-selenium-tools package for python 然后就可以初始化驱动了
from msedge.selenium_tools import EdgeOptions
options = EdgeOptions()
options.use_chromium = True
driver = Edge(options)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.