Showing posts with label Zoom In and Zoom Out. Show all posts
Showing posts with label Zoom In and Zoom Out. Show all posts

Alert handling in Selenium


public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
String Url = "http://sislands.com/coin70/week1/dialogbox.htm";
driver.get(Url);
WebElement alert = driver.findElement(By.xpath("///div[1]/center/table/tbody/tr/td/form[1]/p/input"));
alert.click();
Alert popup = driver.switchTo().alert();
System.out.println(popup.getText());
popup.accept();
Thread.sleep(3000);
driver.close();

}

Selenium New Version i.e. 2.42.0


Selenium new version is available i.e 2.42.0 , please download it from below link and update your libraries so that you will not face any compilation or any other version related issue:

http://goo.gl/l3AasO

To stay update, just like my Facebook page

How to Zoom In and Zoom Out in Website

In case, you want to zoom in and out in any website using Selenium. You can follow below commands:

To Zoom In:

WebElement Sel= driver.findElement(By.tagName("html"));
sel.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));

To Zoom Out to normal page, use below command:

html.sel(Keys.chord(Keys.CONTROL, "0"));

This can be useful when you need to pin point something while showing your automation framework to any user.