Earlier nosotros learnt how to execute WebDriver software exam In Internet Explorer browser using InternetExplorerDriver In previous post. We accept likewise learnt how to resolved "Protected Mode settings are non the same for all zones. Enable Protected Mode must endure ready to the same value (enabled or disabled) for all zones." error by setting "Enable Protected Mode" banking firm correspond box value same
for all zones manually In Internet Explorer browser.
Manual browser setting volition stay express to your estimator entirely agency If same software exam volition endure executed on other estimator hence your exam volition neglect If IE browser's "Enable Protected Mode" settings non configured In that computer. To resolve this Issue, We postulate something In our software automation exam script which tin configure all these settings Itself on piece of job time. Means It should induce all zones protected way safety settings Itself when you lot piece of job your exam script on whatever machine. Is It possible? Answer Is "Yes".
We tin produce It using DesiredCapabilities degree of selenium WebDriver software testing Interface. Bellow given code volition ready IEDriver capability to Ignore "Enable Protected Mode" settings too volition permit you lot to piece of job your exam without whatever mistake regardless whatever your settings are at that topographic point for "Enable Protected Mode" In IE browser.
// Set capability of IE driver to Ignore all zones browser protected way settings. DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); // Initialize InternetExplorerDriver Instance using novel capability. WebDriver driver = novel InternetExplorerDriver(caps);
To experiment It practically, I accept created uncomplicated calc software exam script every bit bellow. Before executing this representative software exam script, You postulate to reset all zones to default bird every bit bellow.
- Open IE browser.
- Go to Tools -> Internet Options.
- Select Security tab.
- Click on "Reset all zones to default level" push too hence click on "OK" push every bit shown In bellow Image.
Now "Enable Protected Mode" banking firm correspond box condition volition endure dissimilar for all zones. Now execute bellow given exam In eclipse too verify trial In console.
package Testing_Pack; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; populace degree IEEnableProtected { populace static void main(String[] args) throws Exception { // Set path of IEDriverServer.exe // Note : IEDriverServer.exe should endure In D: drive. System.setProperty("webdriver.ie.driver", "D://IEDriverServer.exe"); // Set capability of IE driver to Ignore all zones browser protected way settings. DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); // Initialize InternetExplorerDriver Instance using novel capability. WebDriver driver = novel InternetExplorerDriver(caps); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // Load sample calc exam URL driver.get(" "); // Execute sample calc test. driver.findElement(By.xpath("//input[@id='1']")).click(); driver.findElement(By.xpath("//input[@id='plus']")).click(); driver.findElement(By.xpath("//input[@id='6']")).click(); driver.findElement(By.xpath("//input[@id='equals']")).click(); String trial = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); System.out.println("Calc exam trial Is : " + result); driver.close(); } }
Above software exam volition piece of job without whatever mistake regardless whatever settings are at that topographic point for "Enable Protected Mode". Read side yesteryear side postal service to know how to ready IE zoom bird to 100% on runtime.