Showing posts with label WebDriver Handbook. Show all posts
Showing posts with label WebDriver Handbook. Show all posts

Thursday, September 27, 2012

waitForPageToLoad in Selenium 2.0/WebDriver

The following method can be used to wait until the expected page title appears.


public void waitForPageToLoad(String title){
     Integer i = 1;
     for(i=1;i<=100;i++) {
          if (driver.getTitle().equals(title)) {
               break;
          }
          Thread.sleep(10000);
     }
}
 

Friday, March 23, 2012

Handling Javascript Popups Using WebDriver

WebDriver has an inbuilt library for handling the JavaScript alerts, and capturing values from the dialogs. It has a class called Alert. The following actions can be captured by using a Alert class build in latest version of WebDriver



1. accept()
2. dismiss()
3. getText()
4. sendKeys()



1. accept()



This method can be used to click 'OK' button in a popup.
Ex: 


Clicking on OK for JavaScript Alert