If your IE browser zoom degree Is non laid upward to 100% thus you lot volition cash inwards one's chips an fault similar "Browser zoom degree was laid upward to XYZ%. It should hold upward laid upward to 100% ". Earlier nosotros learnt In THIS POST -> How to resolve this fault yesteryear setting IE browser's zoom degree to 100% manually earlier running software examination automation script. Now If you lot need
to operate your software examination script In dissimilar computers thus everywhere you lot ask to laid upward browser's zoom degree every fourth dimension manually earlier running your software spider web application's examination script. Otherwise your software automation examination script volition fail. As described In my previous post, We tin give the sack resolve "Enable Protected Mode For All Zones" fault run-time. So tin give the sack nosotros create same affair for browser zoom level? Answer Is Yes. We tin give the sack apply or thus extra code In our software automation examination script to laid upward browser zoom degree 100% run-time automatically.
Here nosotros volition purpose same shape DesiredCapabilities of WebDriver Interface which nosotros accept used In previous ship to resolve error. Here nosotros volition laid upward browser's capability to Ignore zoom setting in addition to disable the native events. Then nosotros volition laid upward browser zoom degree to 100%. Bellow given code snippet volition perform higher upward given all operations in addition to laid upward browser zoom degree 100%.
// Set desired capabilities to Ignore IEDriver zoom degree settings in addition to disable native events. DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability("EnableNativeEvents", false); caps.setCapability("ignoreZoomSetting", true); // Initialize InternetExplorerDriver Instance using novel capability. WebDriver driver = novel InternetExplorerDriver(caps); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // Press CTRL + 0 keys of keyboard to laid upward IEDriver Instance zoom degree to 100%. driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0"));
To experiment higher upward code snippet practically,
- Set your IE browser's zoom degree to 50% equally shown In bellow Image
- And thus operate bellow given examination script In eclipse.
package Testing_Pack; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; populace shape IESetZoom { populace static void main(String[] args) throws Exception { // Set path of IEDriverServer.exe // Note : IEDriverServer.exe should hold upward In D: drive. System.setProperty("webdriver.ie.driver", "D://IEDriverServer.exe"); // Set desired capabilities to Ignore IEDriver zoom degree settings in addition to disable native events. DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability("EnableNativeEvents", false); caps.setCapability("ignoreZoomSetting", true); // Initialize InternetExplorerDriver Instance using novel capability. WebDriver driver = novel InternetExplorerDriver(caps); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // Press CTRL + 0 keys of keyboard to laid upward IEDriver Instance zoom degree to 100%. driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0")); // Load sample calc examination 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 outcome = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value"); Thread.sleep(5000); System.out.println("Calc examination outcome Is : " + result); driver.close(); } }
Above examination volition hold upward executed without whatever error. This Is the best means to resolve Set IE browser Zoom Level To 100% error. It volition apply zoom degree settings automatically on each machine where this software examination script volition hold upward executed. So you lot no ask to worry nigh It. Next post will demo you how to handgrip SSL certificate fault inwards IE browser.