简体   繁体   English

Python Selenium Inte.net Explorer 模式下的 Edge 浏览器

[英]Python Selenium Edge Browser in Internet Explorer mode

I got a website which is just compatible with Inte.net Explorer.我有一个与 Inte.net Explorer 兼容的网站。 We activated the Edge Inte.net Explorer Mode Option, but im unable to handle the website with Selenium. Is there any way to use IE-Mode with Edge in Selenium?我们激活了 Edge Inte.net Explorer Mode 选项,但我无法使用 Selenium 处理网站。有什么方法可以在 Selenium 中使用 Edge 的 IE 模式吗?

You need to download the recommended version of IE Driver Server from this link then refer to the code below to use Edge IE mode in Selenium in Python: Python Selenium中需要使用IE Driver Server推荐版本,然后参考以下代码使用Edge IE模式:

from selenium import webdriver

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(executable_path='E:\webdriver\IEDriverServer.exe', options=ieOptions)

driver.maximize_window()
driver.get('https://www.google.com/')

Note: Change the paths in the code to your owns.注意:将代码中的路径更改为您自己的。

Result:结果:

在此处输入图像描述

at the moment there is no Edge browser IE Mode option for Python but there is an option in C#目前没有用于 Python 的 Edge 浏览器 IE 模式选项,但 C# 中有一个选项

if you are familiar with C# you can follow steps below如果您熟悉 C#,您可以按照以下步骤操作

Download the latest version of IEDriverServer from the Selenium site .Selenium 站点下载最新版本的 IEDriverServer。

Create a C# console project using Visual Studio.使用 Visual Studio 创建一个 C# 控制台项目。

Install Selenium.WebDriver 3.141.0 NuGet package from Nuget package manager.从 Nuget package 管理器安装 Selenium.WebDriver 3.141.0 NuGet package。

Add the code below to the project and modify the paths.将下面的代码添加到项目中并修改路径。

static void Main(string[] args) 
{ 
    var dir = "{FULL_PATH_TO_IEDRIVERSERVER}"; 
    var driver = "IEDriverServer.exe"; 
    if (!Directory.Exists(dir) || !File.Exists(Path.Combine(dir, driver))) 
    { 
        Console.WriteLine("Failed to find {0} in {1} folder.", dir, driver); 
        return; 
    } 

    var ieService = InternetExplorerDriverService.CreateDefaultService(dir, driver); 
    var ieOptions = new InternetExplorerOptions{}; 
    ieOptions.AddAdditionalCapability("ie.edgechromium", true); 
    ieOptions.AddAdditionalCapability("ie.edgepath", "{FULL_PATH_TO_MSEDGE.EXE}"); 

    var webdriver = new InternetExplorerDriver(ieService, ieOptions, TimeSpan.FromSeconds(30)); 
    webdriver.Url = "http://Your_Site_URL_here..."; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 python 和 selenium 在 Internet Explorer(IE)模式下打开 Microsoft Edge? - How to open Microsoft Edge in Internet Explorer(IE) Mode using python and selenium? 使用 Selenium Python 在私有模式下打开 Internet Explorer - Opening Internet Explorer in Private Mode with Selenium Python 如何使用python selenium获取Internet Explorer的浏览器控制台日志 - How to get the browser console logs of internet explorer using python selenium Selenium 在 Inte.net Explorer 中用 Python 测试 - Selenium test with Python in Internet Explorer 在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 如何使用Selenium和Python查找元素Internet Explorer - How to find element Internet Explorer, using selenium and Python 无法通过Selenium WebDriver python绑定启动Internet Explorer - Unable to launch Internet Explorer through Selenium WebDriver python bindings Python Selenium Internet explorer 找不到 css 选择器,或 Z3D788FA62D7C74105A1BEE4C91 - Python Selenium Internet explorer not able to find css selector, or xpath Python / Selenium; 无法通过 class 在 Inte.net Explorer 中找到元素 - Python / Selenium ; Unable to find element by class in Internet Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM