简体   繁体   English

Python Selenium Inte.net Explorer 脚本不工作

[英]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 模式,你需要:

  1. Define Inte.netExplorerOptions with additional properties that point to the Microsoft Edge browser.使用指向 Microsoft Edge 浏览器的附加属性定义Inte.netExplorerOptions
  2. Start an instance of 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.

相关问题 为什么在Internet Explorer中使用python中的Selenium时单击事件不起作用? - Why click event doesn't work in Internet Explorer using Selenium in python? 我使用 selenium 的 python 脚本不再工作了。 Chrome驱动版本问题 - My python scripts using selenium don't work anymore. Chrome driver version problem Selenium 在 Inte.net Explorer 中用 Python 测试 - Selenium test with Python in Internet Explorer 设置硒以与Internet Explorer一起使用 - Setting up selenium to work with internet explorer Python 脚本在没有 python -m 的情况下不起作用 - Python scripts don't work without python -m 使用 Selenium Python 在私有模式下打开 Internet Explorer - Opening Internet Explorer in Private Mode with Selenium Python Python Selenium Inte.net Explorer 模式下的 Edge 浏览器 - Python Selenium Edge Browser in Internet Explorer mode 硒+ Python + Internet Explorer +公司代理+ PAC文件+凭据 - Selenium + Python + Internet Explorer + Firm Proxy + PAC file + Credentials 在Internet Explorer(Python)中使用Selenium绕过SSL认证 - Using Selenium to By-pass SSL Certification In Internet Explorer (Python) 无法使用Selenium Python绑定打开Internet Explorer 11 - Not able to open Internet Explorer 11 with Selenium Python bindings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM