'Allow sites to be reloaded in Internet Explorer mode

I need to use Selenium to start up Edge and allow sites to be opened in IE mode (with Selenium).

I did do settings -> default browser -> and selected Allow and restarted. Problem is, Edge starts up fresh every time, so the setting is no longer there. There should be some sort of EdgeOptions or ExtraCapabilities to set at startup to make this happen (similar to this which sets the unexpected alert handling:

 capabilities.setCapability("unexpectedAlertBehaviour", "ignore");

Google search did not really find anything. It found the Capabilties class, etc, but not what the individual values you can actually set. Has anyone done this and can help me?



Solution 1:[1]

From your description, I understand that you want to open a site in the IE mode using Edge Selenium automation code. Correct me if I misunderstand anything.

You could try the sample JAVA code below.

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;

public class IEDriverSample {
    public static void main(String[] args) {        
        InternetExplorerOptions ieOptions = new InternetExplorerOptions();
        ieOptions.attachToEdgeChrome();
        ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
        
        WebDriver driver = new InternetExplorerDriver(ieOptions);

        driver.get("http://www.bing.com");
        WebElement elem = driver.findElement(By.id("sb_form_q"));
        elem.sendKeys("WebDriver", Keys.RETURN);

        driver.close();
    }
}

Reference:

Use Internet Explorer Driver to automate IE mode in Microsoft Edge

Let me know if you have questions.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1