Jannik Köster
Jannik Köster

Reputation: 33

Python Selenium Edge Browser in Internet Explorer mode

I got a website which is just compatible with Internet Explorer. We activated the Edge Internet Explorer Mode Option, but im unable to handle the website with Selenium. Is there any way to use IE-Mode with Edge in Selenium?

Upvotes: 3

Views: 5040

Answers (2)

Yu Zhou
Yu Zhou

Reputation: 12999

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:

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:

enter image description here

Upvotes: 4

CatChMeIfUCan
CatChMeIfUCan

Reputation: 569

at the moment there is no Edge browser IE Mode option for Python but there is an option in C#

if you are familiar with C# you can follow steps below

Download the latest version of IEDriverServer from the Selenium site.

Create a C# console project using Visual Studio.

Install Selenium.WebDriver 3.141.0 NuGet package from Nuget package manager.

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..."; 
}

Upvotes: 0

Related Questions