IE Browser set preferences
How to run webdriver in IE browser?
package com.test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class TestIEBrowser {
static String driverPath = "IE driver path";
public WebDriver driver;
@BeforeClass
public void setUp() {
System.out.println("*******************");
System.out.println("launching IE browser");
System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
}
@Test
public void testGooglePageTitleInIEBrowser() {
driver.navigate().to("http://www.google.com");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
}
@AfterClass
public void tearDown() {
if(driver!=null) {
System.out.println("Closing IE browser");
driver.quit();
}
}
}
When ever working with Internet explorer browser for Selenium webdriver, the below are the common issues that you may come across.
1. If see issue some thing like 'Unexpected error launching Internet Explorer' below, You have to set 'Enable protected mode' option in all levels with same value.
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 516 milliseconds
Please follow below steps to set:
1. Open Internet Explorer browser--> Select Internet Options from Tools menu
2. Select Security Tab --> Select Enable Protected Mode option -- > Check the default Zone level for 'Internet'. If you look at the screen shot below, security level for this zone is selected as 'Allowed level for this zone : Medium to High.' and 'Enable Protected Mode' option is Checked.
2. Select Security Tab --> Select Enable Protected Mode option -- > Check the default Zone level for 'Internet'. If you look at the screen shot below, security level for this zone is selected as 'Allowed level for this zone : Medium to High.' and 'Enable Protected Mode' option is Checked.
Now you need to make sure that, for the other Zones, such as 'Local Internet' and 'Trusted sites' is also selected as ABOVE. You may don't need to do anything with 'Restricted Site' option. We can leave the option as is and by default 'Enable Protected Mode' option will be Checked.
Now after changing the settings, please click on 'Apply' and 'Ok' button.
There is also an other alternative for setting the protected mode using desired capabilities as below: -
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
No comments:
Post a Comment