Book Image

Selenium Essentials

By : Prashanth Sams
Book Image

Selenium Essentials

By: Prashanth Sams

Overview of this book

Table of Contents (12 chapters)

The EventFiringWebDriver class


The EventFiringWebDriver class is a sort of API that encloses arbitrary WebDriver instances to register WebDriverEventListener; it provides an automatic system to trigger events. For example, whenever a test failure occurs, the automatic screen capture method gets activated and starts logging screenshots. The EventFiringWebDriver class is highly recommended for better reporting and test maintenance. Through EventFiringWebDriver, the user can have full control over the web page under test, including control over navigation, over finding elements, on exception, the click action, over script execution, and so on.

Follow these regulations to run tests through EventFiringWebDriver:

  1. Create a Listeners class by either implementing the WebDriverEventListener interface or extending the AbstractWebDriverEventListener class:

    public class Listeners extends AbstractWebDriverEventListener 
    {...
    }
    
    public class Listeners implements WebDriverEventListener 
    {...
    }
  2. Now, create a...