Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
682 views
by Contributing Tester (35 points)
edited by

my question where we implement this listener .

Every body ask me about listener .After few days i got smothing about this answer (There are two main listeners i.e. WebDriver Listeners and TestNG Listeners).Please some one explain clearly for every one .

There are two main listeners i.e. WebDriver Listeners and TestNG Listeners

1 Answer

0 like 0 dislike
by The go-to Tester (448 points)
edited by

What is Listener?
Listener is defined as interface that modifies the default behavior. Listeners listen to particular events of WebDriver.


What is Event?
Event refers to any action that we perform using WebDriver like click, type, navigate etc. this all are termed as Events.

Why to use Listener?

We can make the use of listeners to perform set of actions before and after a WebDriver event.

There are two main listeners.

  1. WebDriver Listeners
  2. TestNG Listeners
  1. WebDriver Listeners : WebDriver Event Listeners in Selenium WebDriver. Listeners “listen” to the event defined in the selenium script and behave accordingly. Listeners are mainly used for generating reports and logs. Below are the class and interface listeners in Selenium:
    • WebDriverEventListener: This listener allows to implement the methods and selenium WebDriver perform the activities like Type, Navigate, Click, etc. For tracking these activities, this listener should be implemented in the WebDriver Event Listener interface is used.
    • EventFiringWebDriver: This is an event firing WebDriver class used for firing WebDriver Event.


2. TestNG Listeners : These Listeners “listen” to the event defined in the selenium script and behave as per the defined events. These listeners are used for generating logs and customize TestNG Reports.

There are many types of TestNG listeners available. Below are the few TestNG listeners:

  1. IAnnotationTransformer
  2. IAnnotationTransformer2
  3. IConfigurable
  4. IConfigurationListener
  5. IExecutionListener
  6. IHookable
  7. IInvokedMethodListener
  8. IInvokedMethodListener2
  9. IMethodInterceptor
  10. IReporter
  11. ISuiteListener
  12. ITestListener


Test automation services adopt very high standards for script development & Reports. Software testing company write Selenium test cases in TestNG, and calling the TestNG suite from selenium.Above Interface are called TestNG Listeners. These interfaces are used in selenium to generate logs or customize the automation testing reports. Below is one example

ITestListener has following methods

OnStart - OnStart method is called when any Test starts.
onTestSuccess - onTestSuccess method is called on the success of any Test.
onTestFailure - onTestFailure method is called on the failure of any Test.
onTestSkipped - onTestSkipped method is called on skipped of any Test.
onTestFailedButWithinSuccessPercentage - method is called each time Test fails but is within success percentage.
onFinish - onFinish method is called after all Tests are executed.
 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...