[英]Python Selenium Internet Explorer scripts don't work
If I make a simple script like this:如果我制作一个像这样的简单脚本:
from selenium import webdriver
from selenium.webdriver.ie.service import Service
import os
from pathlib import Path
path = Path().absolute()
path = os.path.join(path, 'IEDriverServer')
driver = webdriver.Ie(executable_path=path)
driver.get('https://www.google.com/')
print("ANYTHINGGG")
Selenium opens the Edge on IE mode (no problem), opens google, but after that it stops... don't print "ANYTHINGGG" and I cannot program anything after driver.get('https://www.google.com/')
. Selenium 在 IE 模式下打开 Edge(没问题),打开谷歌,但之后它停止了......不要打印“ANYTHINGGG”并且我无法在driver.get('https://www.google.com/')
。
This problem seems to be in any site.这个问题似乎在任何网站。
Anyone has a clue of what can solve that?任何人都知道什么可以解决这个问题?
(I am using windows 10, python 3.7.9) (我用的是windows 10、python 3.7.9)
Just expect that the code do not stops on driver.get('https://www.google.com/')
只是希望代码不会在driver.get('https://www.google.com/')
上停止
If you want to automate Edge IE mode with IEDriver, you need to:如果你想用 IEDriver 自动化 Edge IE 模式,你需要:
Inte.netExplorerOptions
with additional properties that point to the Microsoft Edge browser.使用指向 Microsoft Edge 浏览器的附加属性定义Inte.netExplorerOptions
。Inte.netExplorerDriver
and pass it Inte.netExplorerOptions
.启动Inte.netExplorerDriver
的一个实例并传递给它Inte.netExplorerOptions
。 IEDriver launches Microsoft Edge and then loads your web content in IE mode. IEDriver 启动 Microsoft Edge,然后在 IE 模式下加载您的 web 内容。You also need to meet the Required Configuration .您还需要满足Required Configuration 。 For detailed information about using Inte.net Explorer Driver to automate IE mode in Edge, you can refer to this doc .有关使用 Inte.net Explorer 驱动程序在 Edge 中自动化 IE 模式的详细信息,您可以参考此文档。
Your code seems not right, you can refer to the following code, it works well (change the path in the code to your owns):你的代码好像不对,你可以参考下面的代码,效果不错(把代码里的路径改成你自己的):
from selenium import webdriver
from selenium.webdriver.ie.service import Service
ser = Service("E:\\webdriver\\IEDriverServer.exe")
ieOptions = webdriver.IeOptions()
ieOptions.add_additional_option("ie.edgechromium", True)
ieOptions.add_additional_option("ie.edgepath",'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')
driver = webdriver.Ie(service = ser, options=ieOptions)
driver.get('https://www.google.com/')
print("ANYTHINGGG")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.