[英]Why does python.exe crash when I run this Selenium/WebDriver code using IE as the driver?
[英]Using IE selenium driver with python
我试图定义 IE Web 驱动程序以使用 python,但我有一些我无法理解的错误。 可能我必须在 Internet Explorer 中更改一些安全设置? 我有 Internet Explorer 版本 11,谢谢。
from selenium import webdriver
driver = webdriver.Ie(executable_path=r"C:\Users\cohe\PycharmProjects\Testing\IEDriverServer.exe")
i got some errors:
Traceback (most recent call last):
File "C:/Users/cohe/PycharmProjects/Testing/Shrepoint.py", line 3, in <module>
driver = webdriver.Ie(executable_path=r"C:\Users\cohe\PycharmProjects\Testing\IEDriverServer.exe")
File "C:\Users\cohe\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\ie\webdriver.py", line 54, in __init__
warnings.warn('executable_path has been deprecated, please pass in a Service object',
NameError: name 'warnings' is not defined
注意:我使用的是硒 4.0.0a1
你用的是什么版本的硒?
如果您在此处查看 python selenium 绑定:
您可以看到 2 个关键部分:
- executable_path - Deprecated: path to the executable. If the default is used it assumes the executable is in the $PATH
和
if executable_path != 'IEDriverServer.exe':
warnings.warn('executable_path has been deprecated, please pass in a Service object',
DeprecationWarning, stacklevel=2)
这些在selenium 4 alpha 1 绑定中被删除了。
您的第一个也是最好的选择:
假设您拥有最新的 v4 selenium - 这是在 alpha 测试中,可能会进一步频繁更改。 除非您需要尖端功能,否则您可能希望将您的版本回滚到最新的稳定版。 那应该再次允许可执行路径。
下一个选项:错误/警告仅在您尝试指定路径时才会抛出。 线索在你的错误中:
'executable_path 已被弃用,请传入一个 Service 对象'
因此,不要指定它:-)
你可以试试:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.