IEDriver - How To Resolve Set IE browser Zoom Level To 100% Error On RunTime
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;
public class IESetZoom {
public static void main(String[] args) throws Exception {
// Set path of IEDriverServer.exe
// Note : IEDriverServer.exe should be In D: drive.
System.setProperty("webdriver.ie.driver", "D://IEDriverServer.exe");
// Set desired capabilities to Ignore IEDriver zoom level settings and disable native events.
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("EnableNativeEvents", false);
caps.setCapability("ignoreZoomSetting", true);
// Initialize InternetExplorerDriver Instance using new capability.
WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
// Press CTRL + 0 keys of keyboard to set IEDriver Instance zoom level to 100%.
driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0"));
// Load sample calc test URL
driver.get("http://www.corejavawithselenium.blogspot.in");
// 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 result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");
Thread.sleep(5000);
System.out.println("Calc test result Is : " + result);
driver.close();
}
}
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;
public class IESetZoom {
public static void main(String[] args) throws Exception {
// Set path of IEDriverServer.exe
// Note : IEDriverServer.exe should be In D: drive.
System.setProperty("webdriver.ie.driver", "D://IEDriverServer.exe");
// Set desired capabilities to Ignore IEDriver zoom level settings and disable native events.
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("EnableNativeEvents", false);
caps.setCapability("ignoreZoomSetting", true);
// Initialize InternetExplorerDriver Instance using new capability.
WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
// Press CTRL + 0 keys of keyboard to set IEDriver Instance zoom level to 100%.
driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0"));
// Load sample calc test URL
driver.get("http://www.corejavawithselenium.blogspot.in");
// 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 result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");
Thread.sleep(5000);
System.out.println("Calc test result Is : " + result);
driver.close();
}
}
ReplyDeleteWhen we speak of Selenium, we are actually talking about both its flavours: Selenium WebDriver and Selenium IDE. Both automate browsers in support of web application testing. WebDriver is typically used to create browser-based regression tests, whereas Selenium IDE is most advantageous in creating unit tests, exploratory tests and one-off bug reproduction scripts. There is no need to make further distinctions between the two, however, when discussing Selenium’s advantages and disadvantages.
Selenium Training in Chennai