Showing posts with label What is HTMLUnitDriver?. Show all posts
Showing posts with label What is HTMLUnitDriver?. 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();

}

What is HTMLUnitDriver?


HTMLUnitDriver is fastest (50% faster than Firefox), lightweight, platform independent. However, we don't use it. We always prefer to use Firefox, Chrome, IE but not HTMLUnitDriver

Do you know why?? 

Here is the answer: