Session 46 – Selenium with Java | TestNG | Listeners | … — Transcript

Learn how to use TestNG listeners in Selenium with Java to perform post actions and generate Extent Reports for test automation.

Key Takeaways

  • TestNG listeners help automate actions after test execution based on results.
  • Listeners implement predefined methods from the ITestListener interface without modification.
  • Post actions include updating reports and capturing screenshots for failed tests.
  • Tests and listeners are run together via an XML configuration file.
  • Extent Reports can be generated using listener-based post actions for better test reporting.

Summary

  • Introduction to TestNG listeners and their role in Selenium test automation.
  • Explanation of test method statuses: pass, fail, and skip.
  • Concept of post actions triggered based on test method execution results.
  • Implementation of listener classes by extending the ITestListener interface.
  • Automatic triggering of listener methods like onTestSuccess, onTestFailure, and onTestSkipped.
  • Examples of post actions such as updating reports and capturing screenshots.
  • Steps to create test cases with multiple test methods.
  • Creating and configuring an XML file to run tests with listener integration.
  • Practical demonstration of implementing listeners and generating Extent Reports.
  • Clarification that API and listener concepts are separate.

Full Transcript — Download SRT & Markdown

00:04
Speaker A
So in today's session, we'll see a new concept, TestNG listeners, and after that, we'll also learn about extent reports and how to generate extent reports.
00:29
Speaker A
sometimes uh when you run your test cases in the sense we have a class class can d a test methods so if you run your class or if you run multiple classes sometimes the test methods can pass some sometimes test method May Fail sometimes the test method May skip
00:47
Speaker A
Okay, so first of all, what is a TestNG listener and how can we implement this, and what is its usage?
01:04
Speaker A
actions okay so based upon the results by considering those results I want to perform certain actions okay so those actions are called post actions we can call them as a post actions means once your test method is got executed once you get a status like it is passed or failed or
01:24
Speaker A
Sometimes, when you run your test cases, in the sense we have a class that can have test methods. So if you run your class or if you run multiple classes, sometimes the test methods can pass, sometimes test methods may fail, sometimes the test methods may skip.
01:42
Speaker A
I can do some other type of action So based upon execution status of the test method we can perform certain actions so those actions are called post actions examples for example my test method is got passed so what could be the post action is I can update the results into the report like my test
02:05
Speaker A
Right, so most of the times we can see these three statuses: either your test methods can pass, or it can be failed, or it can be skipped.
02:24
Speaker A
along with the screenshot so that is a post action and that we can do only after execution is done similarly my test my test method is got skipped for example now I'll update the skipping status in the report so these are few examples of the post actions we can say post actions So
02:43
Speaker A
Now, based on this result, like based upon the result, it can be passed or fail or skip. So based on the results, I want to perform some actions.
03:05
Speaker A
time just a second okay now let's say my test method one this is my test method two test method three now I have a three test methods you can have one class or multiple classes it can be anything now my test method is got passed
03:31
Speaker A
Okay, so based upon the results, by considering those results, I want to perform certain actions.
03:50
Speaker A
these are called post actions and to perform these post actions we use something called listeners we have to use something called listeners concept from test in okay so how to implement this step number one we need to First create a test case which contains a multiple test methods you can
04:11
Speaker A
Okay, so those actions are called post actions. We can call them as post actions, meaning once your test method is executed, once you get a status like it is passed or failed or skipped, based on that particular status, I want to perform certain actions.
04:25
Speaker A
create these post actions okay suppose my test method one is passed then I can do one action test method two fail then I can do another type of action test meod three fail then skip then I can do another type of action so to perform these post actions we will create another class called
04:43
Speaker A
For example, let's say my test method has passed, then I will perform certain action, or my test method has failed, then I will perform some other type of action, or my test method has skipped, then I can do some other type of action.
05:02
Speaker A
The Listener class inside the listener class we have to implement certain methods listener class methods we have to implement okay so whenever you create a listener class this listener class should Implement from predefined interface called it test listener I'll tell you again it test listener is
05:27
Speaker A
So based upon the execution status of the test method, we can perform certain actions. So those actions are called post actions.
05:49
Speaker A
failure on test success and so on so there are certain methods are there okay inside the it test listener interface so maybe these methods can be default or abstract whatever ultimately these methods are provided by it test listener interface so now what we need to do is along with
06:11
Speaker A
Examples: for example, my test method has passed, so what could be the post action? I can update the results into the report, like my test method has passed, updation of the results into the report. That is one type of post action.
06:34
Speaker A
is a second step okay so if my test method is got passed then we need to call on test success method this will automatically trigger and my test method is got failed then on test failure method will automatically trigger if my test method is got skipped then automatically on test skip
06:55
Speaker A
Suppose my test method has failed, my test method has failed, then what could be the post action? I can capture the screenshot of the page and also I can update the status as failed in the report along with the screenshot. So that is a post action, and that we can do only after execution is done.
07:14
Speaker A
listener class we have to implement this method according to our requirement and this is second step now third step is what we have to create an XML file to run the test right so this particular class we will run through XML file along with this class we should should also specify this listener
07:32
Speaker A
Similarly, my test method has skipped, for example, now I'll update the skipping status in the report. So these are few examples of the post actions. We can say post actions.
07:54
Speaker A
these methods will automatically trigger whenever my test method is got passed fail or skipped and these methods will perform the post actions and what could be the post actions we can Implement them inside these methods listener class methods okay so this is overall context again I'm
08:14
Speaker A
So based upon the execution status, we can perform certain actions, and those actions are called post actions, and those post actions we can do by using TestNG listeners concept. We can do the post actions using TestNG listeners.
08:33
Speaker A
these are predefined names we don't need to change we should not change them okay so normally if you have an interface when implementing this interface in the class should we change the method names no right we should not change anything whatever methods are there in the interface same methods
08:49
Speaker A
Okay, so let me give you a context again one more time, just a second.
09:05
Speaker A
methods similarly here The Listener class also we can Implement from it test listener interface okay now let us try to implement this practically then you will get more understanding about this Apachi there is no connection between this one and AP pii AP is totally different that's a third party
09:28
Speaker A
Okay, now let's say my test method one, this is my test method two, test method three. Now I have three test methods. You can have one class or multiple classes, it can be anything.
09:50
Speaker A
can understand what exactly listener means how it will work and how where exactly we use so once you understand this concept then BAS on this topic I will try to show you how we can generate extend reports so that is our ultimate topic but before discussing extend reports we need
10:08
Speaker A
Now my test method has passed, and my test method has failed, and my test method has skipped. Multiple states.
10:32
Speaker A
and the third step is we can create an XML file create an XML file which includes XML file and include both test case classes and a listener class okay so these are the three steps first we need to create a test case then we have to create a list listener class and how to create
11:00
Speaker A
And my test method has passed, I will do some action. My test method failed, then I'll do another action. My test method skipped, then I'll do another action. So these are called post actions.
11:17
Speaker A
case parallely The Listener class methods will automatically triggered and those methods will actually perform the post actions okay so based on the condition we can do certain actions right so let's try to implement this practically step by step go to the eclipse and create new package day
11:42
Speaker A
These are called post actions, and to perform these post actions, we use something called listeners. We have to use something called listeners concept from TestNG.
12:17
Speaker A
just look at here web driver I'm trying to import and this setup method I will execute before class only one time and I'm driver is initiated with the Chrome driver and uh I put put some implicit weight here and after that I'm launching the browser with this URL and maximizing the browser
12:36
Speaker A
Okay, so how to implement this? Step number one, we need to first create a test case which contains multiple test methods. You can have one class or multiple classes, up to your requirement.
12:59
Speaker A
URL here I'm getting the current URL of the application and I'm checking this URL is exactly same or not okay and if both are equal then my test method will pass or else it will fade now the third method homepage title so in this I'll just specify depends on method when to use this depends
13:20
Speaker A
So basically, we need to have some test methods.
13:40
Speaker A
this particular test method is depends on what app URL okay so this is app URL so if this app URL is got passed then only this test homepage title will execute and then it will pass so dependency methods I put so now the last one teer down so this is just for closing the application so now
14:03
Speaker A
Okay, this is one class we will create. This is step number one. Step number two, to create these post actions.
14:24
Speaker A
test passed one test failed one test skipped okay because I want to show you the test engine listen how exactly the post actions will work now if I look at the status test logo it passed app URL is failed intentionally I failed this because I have given some invalid URL here this
14:42
Speaker A
Okay, suppose my test method one is passed, then I can do one action. Test method two fail, then I can do another type of action. Test method three fail then skip, then I can do another type of action.
15:06
Speaker A
got skipped now I got a three different statuses pass fail and skipped now based upon these status past fail or skipped I want to perform certain post actions so how we can perform those post actions we need to create a listener class to perform the post actions now let's close this
15:27
Speaker A
So to perform these post actions, we will create another class called listener class. Listener class is a special class we have to create.
15:48
Speaker A
on finish yeah so when you're implementing The Listener class what is the prerequisite we have to implement this class from the it test listener interface okay there are two ways to implement the listener class I'll tell you two ways to implement listener class one is there are two
16:13
Speaker A
And the test case class is one thing, is the first part. Second part is we need to create a listener class.
16:35
Speaker A
way of creating our own listener classes extends from test listener adaptor so test listar adaptor is also predefined class which is already there in test NG so we can extend this class into our own listener class and same methods are there whatever methods are in this interface same
16:52
Speaker A
And what is this listener class contains? This listener class doesn't have any test methods, doesn't have any Java methods.
17:16
Speaker A
interface is it test listener okay so it test listener is a base interface so actually what happens is this particular it test interface is already implemented by another class in test NG which is test listener adapter test listener adapter class so this here I have mentioned so
17:43
Speaker A
The listener class, inside the listener class, we have to implement certain methods. Listener class methods we have to implement.
18:02
Speaker A
so there are two methods so one is suppose here there is a method called on test success okay so this method will automatically trigger whenever my test method got passed so this method is available in the it test listener as a default method or maybe abstract method so this method the like
18:22
Speaker A
Okay, so whenever you create a listener class, this listener class should implement from predefined interface called ITestListener.
18:39
Speaker A
own definition so whatever methods are there in the it test listener interface all these methods are already implemented in test L adapter class according to their own definition okay now if you go with the first method if you create your own listener class by implementing it test listener
18:59
Speaker A
I'll tell you again, ITestListener is a pre-defined class which is already there in TestNG. ITestListener is an interface, sorry, it is not a class. ITestListener is an interface which is already existing TestNG default interface.
19:18
Speaker A
class so this test listen adapter is a class which we can extend into our own listener class when you do extend what will happen whatever methods are already implemented in this class those methods we we can get into the our own class that means our own listener class is becomes a child class of
19:36
Speaker A
Now in this particular interface, there are certain methods like onTestStart, onTestFailure, onTestSuccess, and so on. So there are certain methods.
19:55
Speaker A
is it enough no even though extended this listener class methods even though the methods are already implemented so those implementations will not be suitable for own projects so these implementations are default implementations so those implementation may not work for our projects okay
20:16
Speaker A
Okay, inside the ITestListener interface, so maybe these methods can be default or abstract, whatever. Ultimately, these methods are provided by ITestListener interface.
20:34
Speaker A
modify those methods even though the methods are already implemented in the test L Raptor because that implementation will not work for our own projects okay so even though you extended all the method from the test laser adapter again we have to override those methods and if you directly
20:52
Speaker A
So now what we need to do is, along with this test case, we have to create a new listener class, and this class, this is our own class, should be implemented this interface.
21:08
Speaker A
of these methods either by implementing it test listener or by extending test listener adapter so during interview they will ask one question how we can Implement test NG listeners either by using it test listener interface or by using test listener adapter so by using any of these options
21:28
Speaker A
That means our own listener class should implement ITestListener interface. That means what? We have to implement these methods inside our listener class. That is the second step.
21:56
Speaker A
should implement it test listener interface so I'm just writing implements inheritance concept implements High test listener so when it's it test listener this is a predefined interface that we need to import from org. testng package okay so now we have imputed so now in this interface what
22:19
Speaker A
Okay, so if my test method has passed, then we need to call onTestSuccess method. This will automatically trigger.
22:36
Speaker A
see on test start there is one default method and on test success there is another default method on test failure this is also default method they have not implemented just they created this method as just default methods on test skipped right so like this there are some more methods are there
22:55
Speaker A
And my test method has failed, then onTestFailure method will automatically trigger.
23:17
Speaker A
at the time of implementation we should implement the exactly same methods so we should not change the definition part we should implement this as part of our own lenar class so how to implement this so before implementation we have to know what are the methods are there in the itest
23:36
Speaker A
If my test method has skipped, then automatically onTestSkipped method will be triggered.
24:00
Speaker A
to their official documentation this is the test NG official documentation so which class which interface we are using it test listener interface so just click on it docs so not this one so I'll go to another link so test NG listeners we need to check here let contrl F just type listeners
24:59
Speaker A
And these methods we have to implement as part of listener class.
25:16
Speaker A
at this it test it test NG listener so it test listener so this is again implemented by multiple classes so one of the class we have discussed test ler adapter can you see my screen can look at this
25:35
Speaker A
Okay, and we are not going to write our own methods. These are already existing methods in the ITestListener interface.
25:54
Speaker A
there in the it test listener you can go through the documentation you can see all are default methods they are not abstract they are all are default methods so on finish on start so then on test failure on test to skip on test to start on test to success so these are the predefined
26:11
Speaker A
Just we have to implement that interface by using our own listener class. Inside the listener class, we have to implement this method according to our requirement.
26:29
Speaker A
trigger suppose my test method is got executed and passed then on test success method automatically will trigger suppose my test method is got failed then on test failure method will trigger my test method is got skipped then on test skip method will execute so every method is having their own
26:46
Speaker A
And this is second step. Now third step is what? We have to create an XML file to run the test, right?
27:05
Speaker A
you can just copy that method like this and keep it here this is the one method which we are going to implement and on test start so this method will execute before starting any test method and then I want to execute this also on test success also I I'm going to implement and this method
27:24
Speaker A
So this particular class we will run through XML file. Along with this class, we should also specify this listener class inside the XML file.
27:46
Speaker A
on test to start on test success failure on skip so there are few more methods I can also execute this uh on finish so whenever all my tests are got finished then I can EX this method okay so so like
28:05
Speaker A
Then when you run this XML file, it will run our class. At the same time, whenever my test method has passed or failed or skipped, immediately listener class methods will be automatically triggered.
28:20
Speaker A
this is the one we'll try to implement this also okay so on start okay so I just collected these methods from the interface now one important point so whenever you are trying to implement any method from the interface what should be the return return type what why it is giving an error
28:40
Speaker A
So we no need to call those listener class methods. We never call them. These methods will automatically trigger whenever my test method has passed, failed, or skipped.
29:06
Speaker A
them right so make them as a public because we should not uh reduce the visibility so public is higher modifier so public we should specify right so these are the methods I get it from the it test listen interface now we need to implement them so this is also taking one parameter what is
29:28
Speaker A
And these methods will perform the post actions, and what could be the post actions? We can implement them inside these methods, listener class methods.
29:45
Speaker A
implement them according to our own requirement so for now what I'll do is I just put some only print statements so that we will see how these methods are triggering based on the execution and after that we will try to write exact post actions whatever post actions we plann so we will
30:01
Speaker A
Okay, so this is overall context. Again, I'm repeating step number what is a listener.
30:20
Speaker A
this is a listener class so inside this I will print same thing so on start method so when this method will be triggered whenever I started my test case suppose go to Orange HRM this is my test case which is implemented so whenever I started this particular test or this particular class
30:38
Speaker A
Listeners are nothing but a class which contains the methods which are implemented from ITestListener interface: onTestSuccess, onTestFail, onTestPass.
31:06
Speaker A
here so this on test start method and what is the difference between this one and this one on start method will execute only once only once before starting all the tests and on test start method will execute multiple times for multiple test methods so before executing any test method on
31:28
Speaker A
So these are the different names of the methods. So these are predefined names. We don't need to change. We should not change them.
31:45
Speaker A
method will automatically triggered we no need to call so on test start here I will say so test started okay this is the test execution all tests before starting all the test this will execute and this will execute for every test method before starting and this on test
32:09
Speaker A
Okay, so normally if you have an interface, when implementing this interface in the class, should we change the method names? No, right? We should not change anything.
32:33
Speaker A
got skipped now on finish method will execute once it finished all the tests okay so test execution is started here and test execution is completed so I'm writing a simple messages so that we will try to understand the concept first okay so on start we'll execute only once before starting
32:58
Speaker A
Whatever methods are there in the interface, same methods we have to implement in the child class without changing any declaration.
33:16
Speaker A
test method is got skipped and on finish will execute once all the test methods are execution is completed so this is how we can create our own listener class by implementing it test listener interface yes on start method will execute only once before starting all the tests only once
33:40
Speaker A
Right, it can be abstract class, it can be default, it can be abstract method, or it can be default method, whatever it may be.
34:03
Speaker A
will execute only once on finish will execute only once at the end of the all the test method so on test start this particular method will execute before starting every test so before starting test method one on test start will trigger before starting test method two again
34:21
Speaker A
At the time of implementing that interface in the class, we should use the same definition of the methods.
34:41
Speaker A
to understand only this part so difference between on start on test start here the test is nothing but a test method not a test NG test okay here the test is meaning is the test method which is there in the inside the class that is a meaning of test here and XML file that test
35:00
Speaker A
Similarly here, the listener class also we can implement from ITestListener interface.
35:21
Speaker A
using XML now we need to create a third step create XML file and include both the test case and listener class okay now let's go ah and create an XML file which includes all three two classes I can create my own XML file or you can automatically generate your own XML
35:40
Speaker A
Okay, now let us try to implement this practically. Then you will get more understanding about this.
36:06
Speaker A
46 okay so now I have created a basic XML file which includes our class test case class but it doesn't include listener class so far okay if you run this class if you run this XML file by default my test will execute so still we have not integrated test NG listener class
36:28
Speaker A
Apache, there is no connection between this one and API. API is totally different. That's a third-party package which we can use only for Excel files, Apache POI.
36:49
Speaker A
status one is passed one is failed one is skipped okay and this execution is what before integrating listener class so in the cons window except this one we are not able to see anything else now how to integrate listener class so to integrate listener class in XML file we have to add one
37:12
Speaker A
more tag a new tag we need to add so we should not add listener class like this we should we should not create another class entry and we should not specify listener class here that's not a integration so listener class we have to integrate in the different way how we can
37:28
Speaker A
integrate so before starting the test tag before starting the test tag we need to add one new tag here called listeners listeners and close closing opening tag and closing tag inside this listeners we need to add one more tag called listener and here we need to add one attribute called class
37:53
Speaker A
iph name equal to here we have to specify where is our listener class in day 46 uh name of the listener class is my listener that you can specify so here so day 46 day 46 dot name of the class is
38:15
Speaker A
what my listener I can say my listener and then close it so this is how we need to add listener class inside the XML file this is a special tag which we need to create so we should not include
38:33
Speaker A
this so we should not include this along with the normal class okay remember this so we should not include this listener class along with the normal class we should have a separate entry in the XML file okay now third step is completed so first we created a new test case we created a listener
38:53
Speaker A
class by implementing it test listener interface then we created an XML file which includes both test case as well as listener class now in the XML file you can have multiple classes okay for all the classes there will be only one listener class remember this very very important I'll tell
39:14
Speaker A
you why we should have only one listener class in the next example so you can have n number of packages or n number of classes n number of test cases but the throughout the project there will be only one listener class we will maintain so the listener class methods will be automatically
39:30
Speaker A
triggered whichever method is got passed failed or skipped from whichever test case it is throughout the project okay basically this listener class is a utility file this listener class is a utility file which we need to create for generating the report so I'll show you that next example so we
39:49
Speaker A
have created a new test created a new test class third step we have integrated test Eng listener class along with the test case inside the XML file now just observe previously when I run my XML file in the console window you're not seeing any printed messages just observe now when you're
40:09
Speaker A
running as testng suit this time the test NG listener class methods will automatically trigger we will also able to see those messages from the triggered methods now we can see the console window we able to see these messages from where we are getting these messages see test execution is
40:28
Speaker A
started so this message we are getting from what on start method and the rest of the messages see one test method is got passed one test method is got failed one test method is got skipped so where from where these messages we are getting from The Listener class methods okay and test started
40:47
Speaker A
method is executed multiple times before starting every test method on start method executed only one time here on finish method executed only one time after completetion of everything so these are messages printed by listener class methods what does it mean whenever you run your test parall
41:10
Speaker A
The Listener class methods will automatically trigger okay so whenever a test method is got passed so it will go to listener class on test success will be triggered and whenever any test method is got failed so it will go to the Nar class and then it will execute on
41:27
Speaker A
test failure So based on the status corresponding method will be triggered from The Listener class okay so everybody has understood so far how we need to implement test NG listener class and how we can use it to perform the post actions so as of now I have not written any post actions I
41:48
Speaker A
just printed some messages because first we need to understand the concept and now I will write exact post actions what can be the post action how we can Implement in these methods so everybody's understood so far I'm going to show you one more thing okay so this is a one way to integrate test
42:10
Speaker A
case and listener class how in XML file we just added this entry okay this is always preferable but there is another approach suppose I don't want to run test case using XML file let's assume I don't have an XML file first of all I want to run only my test case alone so like this I want
42:32
Speaker A
to run but if I run my test case directly like this will The Listener class will trigger or not right no our listener class will not be triggered so if I run my only test case my listener class
42:46
Speaker A
won't be triggered it will just show you the results listener class is not triggered right but how can we trigger listener class without having XML file directly from the test case I want to trigger my listener class directly from my test case without having XML file so there is
43:09
Speaker A
another way to do this for what for that what we need to do is whichever test case class you created before starting the class so before starting the class here you need to write one annotation a new type of annotation that is called at theate listeners at the rate listeners and in
43:34
Speaker A
this we have to specify The Listener class which listener class you want to trigger when execute this test case so here I can say day 46 dot class name is what my listener and what is this my listener it is a class so explicitly we have to tell dot class and this listener annotation
43:57
Speaker A
we have to import from org. test. annotation so if you do not have XML file still I can integrate my listener class into my test case okay now let me run this class once again I'm running as a test
44:14
Speaker A
Inu see my listener class methods are triggering so that I can get all the messages perfect so you can see we got all the messages from The Listener class listener class methods are automatically triggered without having XML file right so how we can integrate either by using XML file we can
44:41
Speaker A
specify listener class entry here or we can directly specify listener class name before starting the test case class by using atate listeners entry these are the two different ways we can trigger listener class but which approach is prefer preferred and why we always
45:00
Speaker A
prefer to use XML approach okay XML file we will incr degr we will put listener class why is it so there is a problem in this so let me tell you what is a problem so why we should not go with the
45:15
Speaker A
listeners annotation so the problem is let us say you have multiple test cases multiple test cases classes in your framework or in your project let's say there are multiple test cases are there and for all the test cases you will have only one listener class I told you right so you will have
45:35
Speaker A
a only one listener class which is implemented and the same listener class we want to trigger whichever test case got executed for all the test cases there is only one listener class fine now if you go to the uh approach where we we haven't used XML file for example then what is a problem
45:57
Speaker A
we we have to add this listener class entry in every test case in every test case we need to manually add this entry if you have 100 test cases in all 100 test cases you need to have this
46:10
Speaker A
listener class entry in every test case suppose if you're are using XML file then anyway we are going to execute all the test cases using one single XML file right anyway we have to execute as a suit so if you put this listener class in the XML file only one place that is applicable for
46:29
Speaker A
all the test cases so which one is very simple XML approach right instead of specifying The Listener class in every test just writing one single step in XML file if you just specify The Listener that is applicable for all the classes you don't need to write anything in the classes
46:48
Speaker A
nothing right so that is the reason XML approach will be always preferred and why don't you have have only one listener class why should we have only one listener class throughout the project why can't we have multiple listener classes because the post actions can be same post actions should
47:10
Speaker A
be same for all kinds of test case classes or test methods so if my test method is got passed I will do the same post action for all the test method from all the classes similarly if my test
47:22
Speaker A
method is got failed then I will perform same post action for all the test methods which are passed similarly when a test methods are got skipped for all the skipped methods I will do only one type of post action so those actions we will specify in The Listener class so we will maintain only
47:39
Speaker A
one listener class which is applicable for all the test so post actions means whichever test methods got executed passed or failed or skipped based on the status we will do some action and those actions called post actions so normally what could be the post actions
47:58
Speaker A
generating the report is a post action when you will generate the report once execution is completed we will consolidate all the status all the results then we will generate the report right so report generation is a main post action inside the report generation inside the report we
48:18
Speaker A
will update the status of the each and every test case right test case pass test case fail test case skip so updating the results in the report is also post action suppose my test method is got failed immediately I will capture the screenshot attach the screenshot to the report that is also
48:35
Speaker A
one of the post action so these are all post actions we have to implement as part of listener class so that is the main objective of creating the listener class to perform the post actions so what are the post actions creating the report generating the report is our own post action I'm
48:52
Speaker A
not talking about test Eng report test Eng report is a default report which is generated by test that is anywhere will generate through XML file but if you want to create any other new reports like extern report which is very popular with selia web driver so if you want to create a
49:08
Speaker A
extend report the report is nothing but what which contains all Consolidated information means suppose you have Run 100 test cases all 100 test cases results will be populated in one single report so tell me one thing will you maintain multiple reports throughout the project or single
49:25
Speaker A
report most of the time we will maintain only one single report or multiple reports you always maintain one single report right even you have 50 test cases 100 test cases 200 test cases you will log all the test cases result into one single report you don't create multiple reports for
49:44
Speaker A
multiple test cases every test case doesn't have any new report so for all the test cases combinely we can create one report similarly for all the test cases we will have only one listener class why because we will have only one report for all the test cases that is a reason there will be
50:04
Speaker A
only one listener class for all the test cases what is the purpose of creating the listener class is post actions what could be the post actions is report generation and updating the results into the report so that is actual context okay so to get to there initially we understood
50:22
Speaker A
what is listener class how we can Implement how we can trigger listener class methods so far everybody is clear what is the use of test NG listeners concept so by using this concept now we are going to generate the report extend report I will show you now how
50:38
Speaker A
can generate our own customized extend report extend report is a third party report that is nowhere related to test engine but still if you want to generate extend report we need to trigger post actions because report generation is a post action means once we get all the
50:55
Speaker A
results then we can start creating the report rep at the time of execution we cannot create before execution also we cannot create after execution is completed then we will create a report okay if you have a multiple listener class definitely there will be conflict first
51:12
Speaker A
of all why we need to have listener class what is the purpose of listener class if you understand the purpose of listener class you won't ask this question what is the purpose of listener class to generate the report if you create multiple listener classes then what will happen
51:27
Speaker A
it will unnecessarily create a multiple reports we don't need them right you will not get any conflict but there is no necessity for that it will create multiple things so instead of creating one single report it will create multiple reports but Al alter ultimately you will refer only one
51:44
Speaker A
report right so unnecessarily why we should create things why we need to make them complex so have only one single listener class which will generate the report update the status that's it if you create a same listener class multiple times it will generate multiple reports nothing will happen
52:03
Speaker A
there is no conflict but the results which we are not going to expect that means unnecessarily we're getting the duplicate results okay so everybody's understood now what is a listener class why we need it what we will do in The Listener class okay so you need to have more clarity on on this
52:28
Speaker A
so many people have some confusion on this but you should have Clarity on this so what is the use of listeners to perform the post actions post actions means what after execution is completed based upon the results we will perform certain activities or actions they are called
52:45
Speaker A
post actions and how can we do those post actions by implementing listener class methods on start on test start on test success on test Val you should tell these names also during the interview very important just three to four methods it is very very easy to remember those methods
53:01
Speaker A
also okay also we have seen how to execute this listener class along with XML file and without XML file right so now let us see how to implement extn report for our project using listener class concept and basically this listener class is a utility file okay so like listener class is a u
53:27
Speaker A
file I'll share that utility file we'll try to understand what exactly it contains okay so mostly we use this approach or else alternatively you can also use extended test adaptor is also fine you can use one of this approach anything is fine both are same the implementation of methods
53:43
Speaker A
everything is same only this one is different okay yeah so now let us try to implement actual listener class uh which will generate our reports and update the test method status in the report failures pass everything so now we'll talk about extern report listen carefully which is very very
54:08
Speaker A
important concept even in the framework project also we will try to use them again one more time so if you understand here so you will not have any confusion while we are developing the Frameworks if you're not understood here again it will be difficult for you to understand the framework
54:23
Speaker A
so what are all topics we are so far discussing in test Ng every topic is most important with respect to framework okay so if you miss any concept just try to understand and listen one more time so that you can easily understand the Frameworks otherwise it is very difficult so extent report is
54:41
Speaker A
basically what a third party reports third party mean the sense the test NG or selin web driver these people have not developed testng reports so SEL web driver anyway doesn't support any reporting mechanism test NG will support reporting but their default reports will be generated but
54:58
Speaker A
they are not much attractive it is not contains a detail information so we will depend on a third party report extend report is very very popular one especially for selenium so now let us see how we can Implement extend report so to implement this extern report we need to have uh a third
55:19
Speaker A
party dependency we need to add because this is a third party we need to get some external classes and methods which are not there in web driver or test so to get external classes and methods from test from extern report so in the form that XML we need to add some additional dependency in the last
55:37
Speaker A
classes we already added selum Java dependency and apach P dependency and log for J dependency to to avoid the warning messages in the console window and test change dependency we added so now we are going to use extern report that is also third party Library we need to add dependency for extern
55:56
Speaker A
reports yes in every kind of IDE you can generate extern reports even in intellig also you can generate everywhere so once it is in some place it is supported in everywhere it will support there is no uh deviations between IDs ID can be anything the concept will not change okay so now let me
56:20
Speaker A
show you how we can generate exter report so the step number one we need to add required dependency in form. XML so let us get the dependence if you want to see the extend report official page you can just type extend reports and Google it you can find extern report their official website
56:41
Speaker A
and their official website you can see sample screenshot they have given I go back to this docs there multiple versions are there CM 5 is the latest version and this extern report support only Java net and clue only these three Technologies is support so python it doesn't support so click
56:59
Speaker A
on Java and you see the documentation here how to start how to create how to use each and everything the detailed documentation is provided in their official website so you can see EXT report like this this is a UI so lot of things so many classes so many methods so many are there okay we can also
57:20
Speaker A
use this EXT report along with the Cucumber bdd Frameworks everywhere you can use if it is Java you can use it okay so this is they have given some examples uh some along with some screenshots and everything and uh I will simplify this because reading this entire document understanding is so
57:42
Speaker A
much difficult stuff so I will try to simplify this and uh we will see how to create a simple utility file to generate extern report and then I will show you it okay so but from where we will
57:56
Speaker A
get the dependency if I go back to getting started here uh they can mention somewhere okay this is the dependency and you can also get this from the mvn repository just go to mvn repository so that you can also find different versions in the mvn repository search for extend reports okay now
58:19
Speaker A
we can see this extend report the first one so 5.1.1 is there so can and just click on it now get this dependency and just put it here this is some additional dependency which we need to add because we will get some additional classes methods and so on done so that to use extended
58:45
Speaker A
ports the framework can be anything but ultimately that framework should follow Java concept Java programming language should follow so wherever you use Java there and you can use extend report okay so it can be any type of framework whatever framework you're using your automation but inbuilt
59:05
Speaker A
language should be Java and then only you can use extend report okay otherwise you cannot it can be Java or net or clue these are the only three languages which will support python doesn't support the framework can be anything so whatever Frameworks are available in the market you can use
59:21
Speaker A
any type of framework but the in built programming language should be Java then only extern report will be sub important okay so may one so this is a mvn repository so from where we need to search for extend report then you can get this dependency so you can just type mvn repository mvn repository
59:44
Speaker A
okay just go to their website and here go here and type extend reports plus enter now go here EXT reports and get the latest version 5.1.5 as of now I just copied this and keep it inside your form. XML so this is how we can keep adding more number of dependencies for extend report we
60:07
Speaker A
will add this dependency okay so if you open this link directly you can get this dependency so once you have this just try to update your project once so that it will download all the jars and everything so just force update and say okay
60:30
Speaker A
okay so once is updated we will get required jar files that means a buil-in classes methods and everything into your project right so now we will start creating the extern report using listener class listener class is the most important so the listener class itself will able to create a
60:50
Speaker A
generate report update information everything also okay so we already have one listener class so Sim I will create another listener class which is basically called utility file okay even if I not understood the code between in this you can still use the utility file in your projects
61:06
Speaker A
but now I'm going to show you that utility file in very basic file which doesn't have so many other things but in the framework I will show you everything in the uity file so let me create a [Music] new listener class here so I will name it as a extent
61:27
Speaker A
report manager I call it as extern report manager basically this is a utility class and listener class the same listener class we are calling it as a extern report manager because this is the main class which is going to create an extern report it will manage all
61:43
Speaker A
the extern reports so click on finish so in this whenever you create a listener class we should not forget it should be implemented it test listener interface right so what I will do with here I can say implements it test listener interface so this it test listener we have to
62:05
Speaker A
import okay so now whatever methods are there in the it test listener those methods we have to implement here according to our own requirement so let me copy this external report manager class exter report manager so I'm just having this class already so this is a utility file so there are
62:34
Speaker A
a lot of things are missing in this I will go through step by step so try to understand this a little bit complicated but try to understand few important things I will tell you what are the changes you can do in this but this file you can as it is in your Frameworks and our projects
62:50
Speaker A
but this is not complete file uh in our project once you start our framework I will share the complete file there are lot lot of things are missing in this I will tell you what are those things yeah remember so in extend report is mainly provided three classes main three classes extend
63:08
Speaker A
spark reporter is one class everything we can do by using only three three classes extender spark reporter another one is extend reports this is another class and third one is extend test so these are the three classes they have provided mainly these are the three classes again every
63:32
Speaker A
class is having their own methods and story mainly these are the three classes which are provided by extend report so every class is responsible for something for example extent spark reporter this is a first class which is responsible for UI of the report means user interface how it looks like
63:56
Speaker A
like dark theme or standard theme okay and where we should display the information the location of the information so it will always deal with the UI of the report the look and feel of the report color of the report alignment so all these things will be taken care by extend spark reporter
64:15
Speaker A
class so this is always deal with the UI of the report second one is extern report this particular class is responsible for populating some common information on the report means what suppose I'm running my test cases today it will populate some common information in the report what could be the
64:36
Speaker A
common information for example who is executing the test case tester name on which browsers you are executing the test cases browser name on which operating system you are executing the test cases operating system name your project name module name right so these are all common information
64:56
Speaker A
which we need to populate in the report every report if you generate 100 report every report is having this common data right like operating system name browser name tester name environment details in which environment we have executed test cases so all these things will be populated in the
65:13
Speaker A
report by using extern reports class so first one is taking care of the UI of the report look and feel second class external reports is taking care of the populating the common details in the report now the third one is extend test the extend test class is responsible for updating the status
65:35
Speaker A
in the report like populating all the test cases updating the results past fi Skip and attaching the screenshot on failures these are all taken care by the extent test so these are the three important classes are provided by external report one is for UI another is for common information
65:56
Speaker A
projecting into the report Third One is updating the test case entries we can create multiple test case entries updating the status in the report so these are the three classes are responsible for three different things this is the first thing you need to remember now so these are methods test
66:15
Speaker A
engine lener class methods we already know on start on tester access on test failure on test escaped on finish okay now we we will see the implementation how we have implemented so when this on start method will execute when it will it will trigger on start whenever your test cases
66:37
Speaker A
of started execution right once you initiated execution then onart method will automatically Rec so at the time of initializing the test case at the time of or when I initializing the test run at the time we have to create a report template we're not going to update any results or entries
66:59
Speaker A
we just create the UI of the report that is a reason this piece of code should be part of on start so what this piece of code will do there are variables we already created at the global class level so that I can refer them in multiple methods so spark reporter is what this are object
67:20
Speaker A
of extern spark reporter in this we have to pass Loc location of the report where exactly we want to generate the report the location you have to provide so what I will do is in the project itself normally we generate all the reports within the project so go to the project level and create
67:40
Speaker A
a new folder okay and inside this folder I will have all the reports now I can create uh a folder name called reports okay so now I created a new folder so in this report folder I want to have all the extend reports now in the statement we have to specify the location where
68:03
Speaker A
you want to create a report so I'm just capturing the current project location by using system.
68:09
Speaker A
getproperty user. Dr slash inside the report folder slash the my report name is what my report.
68:17
Speaker A
HTML this is the name of the report you can give any name but extension should be HTML okay so here can specify the location of the report that's the first thing now what are these three statements here from the spark reporter we are calling one method called config and inside this in
68:38
Speaker A
the config method we have two more methods set a document title set report name set Theme by using these three methods we can specify the title of the report we can specify the name of the report and also we can choose theme of the report there are standard and dark dark means it will comes in
68:56
Speaker A
the black color standard means it will comes under white color so the theme also we can select here so see this by using the spark reporter we are just confering the UI of the report means this is responsible for only UI of the report right so till here we configured the UI of the report
69:16
Speaker A
we specified the location of the report we specify the uh title of the report we specify the name of the report title is different name is different okay so once the report is generated then I will show you where the title will display where the name will display so the title of the report name
69:35
Speaker A
of the report and theme of the report so these these things we can configure by using spark reporter class next here the what is this extend extend is a extend report class object so by using this what we can do we can populate the common information on the report the also we can do in
69:56
Speaker A
the same method so extent do attach reporter so we need to attach this one and this one by using this method and here this is a common information how we can put this extent dot extent is an object of
70:09
Speaker A
extend reports set system info is a method and uh this this method will take two parameters key and value pair just like a hashmap so computer name is a key Local Host computer name where exactly you are executing a test case that you can populate in which environment you can specify tester name you
70:30
Speaker A
can specify on which OS you are executing you can specify and on which browser you are executing you can specify so as of now I have hardcoded these details but actually in the realtime projects we will get these details dynamically at the run time okay that I will show you in the Frameworks
70:49
Speaker A
again so for now I'm just hardcoded these details okay so these details will be populated in the report every time when you create a new report these details will automatically populated in the report so these things should happen before starting your execution test execution so that
71:08
Speaker A
is the reason we put all these inside the on start method so once the report is created the template is available then rest of the results will be updated in the same report so onart method will execute only one time before starting all the test so by the time we have to create UI of the report
71:27
Speaker A
and also we will populate some common details into the report so these are all user defined values you can put whatever information you want so these keys and values are your own defined so you can put whatever data you want in the r okay so this is implementation of onar now come to
71:44
Speaker A
the next one on test success so when this method will be triggered whenever any test method is got passed then this method will automatically trigger so what this method will do is is in by using this extent in the extent report by using this extent we are creating a new entry because as soon as my
72:07
Speaker A
test method is got P passed that entry we have to create in the report so this particular statement create a test will create an entry in the report and what is the name it will give the name of the
72:20
Speaker A
method so whichever method is got passed that method name should be updated in the report but how we will how we will get this method name whichever is got passed how we will get the name of that method here this is the parameter we have to choose so on test success on test failure on
72:41
Speaker A
test by default we'll take one parameter here I test I test result result is a variable so what this parameter contains actually is whatever the test method is got passed this will capture the information or details about the pass test method so this contains all the details about the
73:03
Speaker A
passord method similarly here this is contains all the details about failure method and this contains all the details about skipped method so from this results we can capture the name of the method which method is got passed how we will know that so you can get the name of
73:19
Speaker A
the method dynamically and with that name you can create an entry in the report that is job done by the statement and after that by using this test.log what is the test here test is a extend test object so this is responsible for what creating a new entry in the report and update the
73:40
Speaker A
status is passed or failed or scaped that's the purpose so test. lock okay test lock lock so on test success will pass my test method so I can say pass and here you can write your own description along with the name of the test method so how to capture the name of the test method dynamically
74:01
Speaker A
by using this result object because this result contain all the details about the test methods okay so this will create a new entry in the report now the Second Step will update the status of the test method whether it's passed or failed whatever so this will happen whenever any test method got
74:21
Speaker A
passed same thing will be repeated here if any test got failed so we are creating a new entry in the report with that same name and updating the status as a failed and whenever the test methods got failed we will get some exception right we'll get some error messages and those messages also
74:39
Speaker A
we can log into the report additionally for that I have written this particular statement so result.
74:45
Speaker A
get name will give you name of the test method from the same result object get a throwable this method will give you the error message normally we get in the console window right the same message will be captured by this get throwable method from the result whatever error we are getting that
75:02
Speaker A
error if you want to get get throwable method will return return that error that also we will display in the report this is additional step we have written in the on test failure now on test skip so again we are creating the new entry in the report with this test name and also updating the status
75:19
Speaker A
as a skipped along with the name of the test method so once you have done all these things and the final method is onfinish is must and should if you do not have this method whatever you have done here nothing will take care in the report so only onfinish method will update the whole thing
75:37
Speaker A
in the report so here inside this we have to call one method called flush from extend object so what this flush method will do is this write all the test information from the standard repositories to their output view means whatever the things we have created so far everything will be updated in
75:58
Speaker A
the report finally on finish this action to be performed so this is mandatory method we should call so this is a extend report manager utility class so line number 30 so line number 30 this is a one right so here what exactly we are doing because even though these classes are independent
76:20
Speaker A
we need to connect each other right whatever UI we created so that UI we need to connect to the extend report so whatever the information we created here that again we need to connect to the extend test so in the line number 30 what exactly we are doing is we already decided UI here we we
76:37
Speaker A
provided the location of the report name of the report title theme everything after that we need to populate some common information for that we are using extent but again this extent should be attached to the UI that is the reason we created an object for extent this one and for that extent
76:56
Speaker A
we are attaching the reporter attach reporter and we are adding this object spark reporter so this statement will basically combine the UI along with the populated information that is done by this particular statement okay so this is how we need to create a utility file this is a very basic
77:20
Speaker A
stuff okay there are lot of things are missing I'll tell you what are those things are missing so even though if you not understood this you can directly copy paste this in your project and you can use it but this is not the final file I will share actual file in the framework so that is a
77:36
Speaker A
file you can use it in your upcoming projects okay so we don't need to attach the extend test class extend test class we already created here if you look at here so extent you can see extent we already attached here right so this extent we need to also attached to the test where we have
77:56
Speaker A
done it here we have done extend. create test so this will return the test that we are going to store in the test actually we are not creating any object for this one actually this we are using only for storing the data we are not creating an object so as soon as you created your new test
78:14
Speaker A
that we are going to store in the test object so extend test is also connected okay fine so now this is actual listener class now let us create an XML file and let us add one test case which
78:27
Speaker A
he already created with the new listener class method so what I will do is I will make another copy of XML file and this XML file will generate the extend report so I will change the name of this XML file called extend report. XML so earlier we already created just I'm going to change it so
78:50
Speaker A
same test case I'm going to execute previously whatever we created but only the listener class I will change so in the day 46 what is the name of the listener class dot extend report manager extent report manager okay so this is we need to specify and then save it so the
79:17
Speaker A
same test I'm going to run with the listener class so what this listener class will do is listener class will generate the extend report so where it will generate this is the location inside the reports folder my report. HTML will be generated now let me run and show
79:34
Speaker A
you now go back to the XML and one more thing guys when you want to run listener class I have told you two ways one is we can specify either in XML file or you can also uh specify
79:48
Speaker A
annotation in the test right here you can specify annotation but both the things you should not do only one thing you need to follow okay so anyway this particular test I'm going to run through XML file in XML file I already put listeners so I can just comment this this is not needed only
80:09
Speaker A
one way we need to follow if you put both the places again it will be Comon right so now this is a particular test I want to run through XML file and this XML file will execute this extern report manager and it will generate the report so let me run it run as test NG
80:29
Speaker A
test okay now it is started execution done so if I look at here one test method passed one is got failed one is got skipped now we'll see where exactly these things are generated in the external inut so according to our
80:52
Speaker A
configuration file utility file so we specified the location in our current project reports folder report name is my report. HTML let's go to the report folder then refresh it so once you refreshed you can see the report here my report. HTML now let's open this in the system editor yes
81:15
Speaker A
now you can see this is a extern reports looks very very attractive and very colorful right so this is the external report so we can see lot of information in this let me show you so this is a dashboard this is a first page actually so here what are all test methods are executed and passed
81:33
Speaker A
or fail it will show you information you can see this is my test passed second one fail third one again Skip and along with these test methods information it will also give you the message whatever you put time stamp and everything and uh suppose if it is got failed it will also show you
81:49
Speaker A
failure and this is a failure message and also we can attach the screenshot on failure that you can can see here currently we have not attached but if you attach the screenshot on failure here it will display the screenshot and this is the one page and here uh title and name
82:07
Speaker A
of the report so if I go back to the utility file so automation report this is a document title functional report functional testing is a tit name of the report so where this automation report will be generated if I go back and see you can see here the tab automation report this is a
82:25
Speaker A
title of the report and here functional testing this is a name of the report okay this is the logo of external report normally if I use this in the companies they can put the company's logo here and apart from this you can see here second one graphs and this is very very attractive if I look at the
82:46
Speaker A
graphs so here it will show you graphs also Let me refresh once go to the second one now we can see sometimes if you're not able to see the graphs just refresh the page see here it will also show you the beautiful very attractive graphs so how many tests are passed fail skip each
83:09
Speaker A
and every information it will show you like this and this is the common details if I go back to the utility file here we populated some common details computer name environment tester name OS browser name right so those details will display here on which computer you have executed
83:25
Speaker A
which environment who is executed which operating system Chrome actually these details we can get it dynamically at the run time we can capture these details so that also I will show you later so this is very basic extend report which is generated through listener class okay now so
83:47
Speaker A
these are the common information you can put this is a title name and this is a location and if you want you can change these things whatever I shown you here these things you can change okay and what are all things are missing in this okay before telling let's try to change the theme
84:01
Speaker A
so this is the Dark theme now I'll make it as a standard standard theme save and close my report execute XML file one more time everything is same I just change the theme of the report okay done now go back to the reports folder once again every time you need to refresh so
84:35
Speaker A
now we can see another report open system edit yeah this is a standard them theme everything is same so it comes in the different color so this is our dashboard refresh so that you can see the graphs yes so more attractive than test engine report right and not only this
84:58
Speaker A
we can populate so many other things we can populate the screenshots lot of other things all right so now we'll see what are the things are missing in this which are very very important first thing if I go back to the utility file here we are specifying the
85:17
Speaker A
location that is also fine but we are hardcoding the name of the report what is the problem with this is suppose first round I have executed my test it is generated Report with the same name second time when I run one more time again it is generator Report with the same name because
85:36
Speaker A
we have hardcoded this name every time when you generate a new report the report will be saved with the same name so what is a problem with that we cannot maintain history of the reports suppose yesterday you have executed your test cases you got one report and after modific
85:54
Speaker A
after are some modifications again one more time you have executed test cases today now if you want to see the difference yesterday's report and today's report if you want to compare you need to have two reports right so that is not maintained here why because we are giving the
86:12
Speaker A
name hardcoded name so when I give hardcoded name the report will be old report will be replaced with the new report so old information we are not maintaining here that is one limitation so that we can overcome by saving the by creating the by giving a name with the time stamp okay so
86:32
Speaker A
how we can create this report with the time stamp dynamically that also I will show you as part of the framework okay that is one thing is missing here how we can generate the report name with the Tim stamp if I create a report name with the timestamp so then it will not be deleted so
86:51
Speaker A
every time it will create a new report with the Tim stamp so the time will keep changing so we can also maintain the history of the reports so that is one thing missing here that I will show you in the Frameworks second thing this part so here we are hardcoding this data Local Host
87:11
Speaker A
QA tester name and operating system everything so this information also we can get it at the run time so once you run your test cases this information automatically we should get by using certain predefined methods are there we can get them and populate it in the report so that also
87:27
Speaker A
I will show you in the framework so this is one thing is missing next thing on test failure we are capturing the status and we are updating the status is failed along with the error message but I want to also add a screenshot failure screenshot I want to capture the screenshot on failure the
87:45
Speaker A
same screenshot should appear in the report itself so that also we can do so that is one thing missing here okay so report generation in the report the screenshot attachment so that also I will show you in the uh framework and one more thing if you look at the report if you
88:05
Speaker A
look at the report here you are able to see only test methods suppose I have run only one single class right so this only one single class I run only test methods are showing suppose I have 100 classes like this every class is having so many number of methods but in the report if you start
88:26
Speaker A
displaying only methods it is very very difficult to handle because there is no ID right there is no test case ID here nothing is there just it is only method name can we tell by seeing this name this
88:42
Speaker A
method is belongs to so and so class no we cannot tell so instead of displaying the method names we should display the test case names like what are all classes we are running here the class names we should display along with the test case ID and uh we can easily recognize so instead of having
89:03
Speaker A
these methods instead of having these test methods if you just specify the class name along with the test case ID right so that will be more easier to understand so that is also missing here that also I'll cover in the framework okay so this is how we can generate external reports using test NG list
89:25
Speaker A
class okay understood everyone so if you give hardcoded name here the same report the new report will be generated with the same name as soon as it is generated the new report with the same name so old report will be replaced with the new report in that case we cannot find the old
89:45
Speaker A
report because the name is same right so that is a reason so in the framework once I started your project then I will show show you the complete the full-fledged utility file which will generate extend report so we can pass the name with the time stamp and we can pass this common details
90:05
Speaker A
dynamically we can attach the screenshot to the report also in the report instead of having these test methods we can also have test case IDs will be displayed here okay also I will show you how we can send this report through email suppose if you want to share this report to your team
90:24
Speaker A
and how we can share it so that also I will show you as part of the framework so this is very basic concept to understand what is test engine listeners what is extend report how we can generate the process you have to know first that is more important okay so that's all for
90:44
Speaker A
today's session we'll stop here and try this very very important concept so if you're not understood go through the video one more time two times or three times because the same concept will be repeated in the framework okay yeah so let us stop here and first do practicing of test NG
91:03
Speaker A
listeners and then create an extern report and when you're creating extern report just try to copy this code as it is and if you want to change some information you can change these details if you want you can change this common information and everything but create this folder properly
91:18
Speaker A
inside this particular folder project label and have this and whenever you run your code every every time you need to refresh this report then only you will report will be updated if you not refresh the report will not be updated okay yes yes utility files normally created by the
91:39
Speaker A
senior people okay if you have more than three years experience or five five plus of years of experience and if you're if you're familiar with them so you can create your own utility file or else you can use existing utility file which is created by somebody
91:54
Speaker A
else nothing wrong in it because nowadays many people are getting the code from CH GP itself so instead of creating your own utility file you can use existing utility file right so what is an advantage you will save lot of time and lot of effort right so nothing wrong in that you can get
92:13
Speaker A
it U files whichever is already created existed somewhere you can utilize in your project nothing wrong okay yes so with we stop here for today's session and practice this and tomorrow we'll continue another topic
Topics:SeleniumJavaTestNGListenersExtent ReportsTest AutomationITestListenerPost ActionsTestNG XMLScreenshot Capture

Frequently Asked Questions

What is the purpose of TestNG listeners in Selenium?

TestNG listeners allow you to perform specific post actions automatically based on the test method execution status, such as updating reports or capturing screenshots.

How do listeners trigger actions after a test method runs?

Listeners implement methods like onTestSuccess, onTestFailure, and onTestSkipped from the ITestListener interface, which are automatically called after each test method execution.

How are listeners integrated into the test execution process?

Listeners are specified in the TestNG XML file along with test classes, enabling them to run alongside tests and perform post actions based on test outcomes.

Get More with the Söz AI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries, speaker detection, and unlimited transcriptions.

Or transcribe another YouTube video here →