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

Saturday, April 18, 2015

Event Listeners - Selenium WebDriver

Event Listeners:

Used when I want on Execution of a particular action/event a code should be executed. For E.g. , Say on Click of a click a piece of code should be executed.

This is included in Interface WebDriverEventListener which has the method bodies which can be used for such purpose. The class which implements this is AbstractWebDriverEventListener

Let us see the implementation of Listeners:

Step 1: Create a Class containing the methods to be used , say weblisteners where we can define the methods. Code is as below:
 
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.events.AbstractWebDriverEventListener;


public class weblisteners extends AbstractWebDriverEventListener {
      
       public void afterClickOn(WebElement element, WebDriver driver){
              System.out.println("Object Has been Clicked");
       }

}