TypeError: __init__() got an unexpected keyword argument #39;options#39; while using EdgeOptions(TypeError:__init__()在使用EdgeOptions时获得意外的关键字参数)
本文介绍了TypeError:__init__()在使用EdgeOptions时获得意外的关键字参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我正在尝试运行基于Chromium的Edge驱动程序版本90.0.818.42的以下代码:
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)MicrosoftEdgeApplicationmsedge.exe"
edge_driver = webdriver.Edge(options=my_edge_option)
edge_driver.get('My URL Here')
运行此代码后,我收到以下异常:
edge_driver = webdriver.Edge(options=my_edge_option)
TypeError: __init__() got an unexpected keyword argument 'options'
我似乎没有错过任何导入,那么为什么我会得到这个例外?请帮帮我
推荐答案
似乎是您问题的解决方案: How to run Microsoft Edge headless with Selenium Python?
options = EdgeOptions()
options.use_chromium = True
安装附加程序包,如下所示:
pip install msedge-selenium-tools
并使用以下命令初始化驱动程序:
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)
以下是官方文档: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=python
这篇关于TypeError:__init__()在使用EdgeOptions时获得意外的关键字参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
编程基础网
本文标题为:TypeError:__init__()在使用EdgeOptions时获得意外的关键字参数
基础教程推荐
猜你喜欢
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
