Showing posts with label how can we use HTMLUnitDriver?. Show all posts
Showing posts with label how can we use HTMLUnitDriver?. Show all posts

Pick Date From a Calendar in Selenium



public static void main(String[] args) throws InterruptedException {

WebDriver driver = new FirefoxDriver();
driver.get("http://jqueryui.com/datepicker/");
driver.manage().window().maximize();
driver.switchTo().frame(0);
driver.manage().timeouts().implicitlyWait(3000, TimeUnit.MILLISECONDS);
driver.findElement(By.xpath("//*[@id='datepicker']")).click();
driver.manage().timeouts().implicitlyWait(3000, TimeUnit.MILLISECONDS);
driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div/a[2]/span")).click();
List column = driver.findElements(By.tagName("td"));
for (WebElement j : column)
{
if (j.getText().contains("13")){
j.findElement(By.linkText("13")).click();
break;
}
}
Thread.sleep(5000);
}

Difference Between Implicit Wait and Explicit Wait


Implicit Wait – 

An implicit wait is to tell WebDriver to stop the DOM for a certain amount of time. The default setting is 0. 

Syntax – driver.manage().timeouts().Implicitly Wait(10, TimeUnit.SECONDS); 

Explicit Wait - 

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: