Session 52: Selenium with Java | Hybrid Framework | Gro… — Transcript

Learn how to group Selenium tests using TestNG annotations, configure setup/teardown methods, and run tests with Extent Reports in a hybrid framework.

Key Takeaways

  • TestNG groups allow flexible and efficient test execution by categorizing tests.
  • Setup and teardown methods must also be grouped to run correctly with grouped tests.
  • The master group is useful for running all tests in one suite.
  • Groups can be included or excluded in the XML configuration for targeted test runs.
  • Data-driven tests are often run as a separate group for better management.

Summary

  • Introduction to grouping test cases in Selenium with Java using TestNG groups annotation.
  • How to assign tests to groups like sanity, regression, data-driven, and master for selective execution.
  • Adding groups to setup and teardown methods to ensure proper execution across grouped tests.
  • Creating and configuring groups in the TestNG XML file for flexible test suite execution.
  • Explanation of the master group that includes all tests for full suite runs.
  • Demonstration of adding multiple groups to a single test using curly braces syntax.
  • Using include and exclude tags in XML to control which groups to run or skip.
  • Best practices for managing data-driven tests separately within the grouping framework.
  • Importance of specifying groups in base classes and setup/teardown methods.
  • Overview of running grouped tests and how to enable or disable tests dynamically.

Full Transcript — Download SRT & Markdown

00:04
Speaker A
Right, so in the last class, we have seen how to automate login test and data-driven test cases. So today, we'll see a few more topics in the framework, like how we can group the tests.
00:16
Speaker A
very simple concept so whatever test cases we already automated we can just add uh grouping tag for every test and after that uh we need to also add setup and ton methods to the groups and after that we need to just create a group in. XML and we can simply run it so
00:36
Speaker A
Very simple concept. So whatever test cases we already automated, we can just add a grouping tag for every test. After that, we also need to add setup and teardown methods to the groups. After that, we need to just create a group in XML, and we can simply run it.
00:54
Speaker A
login test and here this is a verify login so to add group group in the test we can specify group anotation so groups equal to I can make this anity as this verify login is a sanity just a second I think someone is writing something don't do that okay all
01:22
Speaker A
We already have three test cases so far. So let me go to the project and go to the test cases directly. So three tests along with the data-driven test, totally three tests. So first, go to each and every test and will add grouping tags. So to add grouping tags, first let's go to
01:54
Speaker A
upon your requirement you can just add so groups okay so one I added login test I have added to the sanity and account registration test I have added to the regression and similarly even login D also if you want to add you can add this so
02:18
Speaker A
login test, and here this is a verify login. So to add grouping in the test, we can specify group annotation. So groups equal to, I can make this sanity, as this verify login is a sanity. Just a second, I think someone is writing something. Don't do that. Okay, all
02:41
Speaker A
so I can make this as a data driven group okay and also I will add another group called Master groups of sanity and uh you can just if you want to put multiple you can just do like this sanity and and master so Master means all the test should be executed
03:06
Speaker A
right, so I put add this sanity, and I make this part of sanity login test. So after that, let's go to the regression. Let's go to the registration test. I'll make this part of groups, groups equal to regression. So whichever group you want to add based
03:30
Speaker A
code but if have multiple groups we can put in the C Braes okay now login is belongs to both the groups sanity and master and account registration test is belongs to regression and master and DD I'll separated okay Le data test okay so now once you created this we need to also we need tear down
03:55
Speaker A
upon your requirement, you can just add. So groups. Okay, so one I added login test, I have added to the sanity, and account registration test I have added to the regression, and similarly even login D also if you want to add, you can add this. So
04:17
Speaker A
equal to and this should be executed for all the groups so I can say sanity comma regression comma master all the groups so data driven I'm just uh that is also we can add okay data that is up to you if you want to add can just so this is your master
04:48
Speaker A
along with the data providers, all these things are right. So we can also add one more parameter here, groups. Okay, so I will add a separate group for this. I can say data-driven because normally all the data-driven test cases we will run as a separate group most of the times.
05:10
Speaker A
this is sanity this is sanity this is regression this is regression this is also regression so if you select only sanity these two will execute if you select only regression these three will execute and if you select Master then all the test will be executed okay so like this we can put
05:34
Speaker A
So I can make this as a data-driven group. Okay, and also I will add another group called Master groups of sanity, and you can just if you want to put multiple, you can just do like this: sanity and master. So Master means all the tests should be executed.
05:57
Speaker A
specified all the groups in the base class this is also needed okay so I'll just skip the data driven for now because data driven test execution will take more time so I'm just sking that sanity regression and master master means all the test cases will comes under master sanity separate
06:17
Speaker A
So sanity and master. So these are the two groups. And account registration also I'll make it as a part of master. Master is a which contains all the test cases, Master group. Okay, so if you have a single group, no need of curly braces, you can simply put in the double
06:38
Speaker A
Class set up of te down methods also should be part of the groups otherwise when you specify the groups in the XML file so setup method te down method will not pick if we don't specify the groups so those methods also should be part of all the groups so now I'm going to ex create a
06:54
Speaker A
quotes, but if you have multiple groups, we can put in the braces. Okay, now login belongs to both the groups sanity and master, and account registration test belongs to regression and master, and DD I'll separate, okay, Le data test. Okay, so now once you created this, we need to also, we need teardown
07:19
Speaker A
the purposes okay that is a different thing that I'll also show grouping do XML so earlier in the grouping XML we have uh only test parameters we have passed and classes we mentioned right so now in this grouping uh we need to also specify the group tag so where we have to specify so before
07:43
Speaker A
and setup methods for every test, right? So for every group we read, so we need to go to setup method Base Class, even the before class method, and also this after class method also should be part of all the groups. So before class also we can add groups annotation, groups parameter, groups
08:07
Speaker A
it is depends on your requirement so this keeps you can change okay so I can say this is include and then I can write one more include I can so whichever you want to include you can just specify
08:27
Speaker A
equal to, and this should be executed for all the groups. So I can say sanity, comma regression, comma master, all the groups. So data-driven I'm just, that is also we can add. Okay, data, that is up to you if you want to add, can just. So this is your master.
08:54
Speaker A
can specify your sanity or regression or Master something like this so if I say master all the Master Test cases let's say here I'm putting regression and here I'll put Master Okay so if you want to execute only sanity you can go with this and if you want to
09:12
Speaker A
Master means everything will come under the master. So normally, when you're dividing the group, sometimes you want to execute all the test cases, right? So in that case, you will select the master group. Okay, so for example, let's say you will have multiple test cases, right? Let's say
09:28
Speaker A
here I'll just try to enable this all the test cases should be enabled and uh all two I Ena data driven currently and just comment this case exclude means you can just exclude okay just a second so in include Master section okay so in future if you want to remove something suppose
09:56
Speaker A
this is sanity, this is sanity, this is regression, this is regression, this is also regression. So if you select only sanity, these two will execute. If you select only regression, these three will execute. And if you select master, then all the tests will be executed. Okay, so like this we can put.
10:13
Speaker A
sanity but not regression in that case you can use exclude group otherwise you can just simply comment this so what I will do is I'll execute this master suit so whichever group you mentioned there so that is a particular group of uh test methods will execute so you can just enable them
10:36
Speaker A
So Master is a final group which contains all the tests. So sometimes Master is also required because if you want to execute all the test cases, we will specify this master inside the group section in the XML file. Okay, so this is a base class. We
10:56
Speaker A
we'll execute so as of now under master what are the test we have added even account registration is also part of the master and even login test is also part of the master so both will be executed but when I say sanity then login test will execute when I say regression only account registration
11:14
Speaker A
specified all the groups in the base class. This is also needed. Okay, so I'll just skip the data-driven for now because data-driven test execution will take more time. So I'm just skipping that sanity, regression, and master. Master means all the test cases will come under master. Sanity separate
11:34
Speaker A
Meed yeah perfect now let us try to execute so very simple test very simple way we can do it just add all the tags to every test case and then specify whichever group of test we want to execute in the XML file so two tests I have mentioned in XML file so let's see how is going
12:00
Speaker A
group, regression is separate group, and this ton method also we should execute for all the groups. So we have to specify all three groups. So this is the first task. So whatever test belongs to the particular groups, we can just add these tags. So once you added, then we need to create even Base
12:32
Speaker A
execute no even though if you already extended when you're executing the groups okay uh those two methods will not be executed if you go back and see Base Class this Base Class is okay that's fine you have extended into login test fine but in the XML file we specified the group name right so when
12:59
Speaker A
Class setup of teardown methods also should be part of the groups. Otherwise, when you specify the groups in the XML file, setup method, teardown method will not pick if we don't specify the groups. So those methods also should be part of all the groups. So now I'm going to create a
13:19
Speaker A
extended the base class right Base Class methods will not be executed when you specify the groups in the XML file so whichever group you specify XML file only that particular related method will be executed so that is a reason in the Base Class also this two methods setup method and tear down
13:40
Speaker A
new XML file called grouping.xml file. So let's close all these things, and we will also maintain a separate file called grouping if you want to execute only groups. Okay, so I'll take another copy from the master, and I'll name it as grouping. So we'll also maintain one single XML file for all
13:53
Speaker A
can be a before class after class setup whatever it is even though you extended those methods will not be triggered automatically so that is a reason we have to specify the groups even though you have extended so that is a reason okay right so login test and base class and grouping
14:17
Speaker A
the purposes. Okay, that is a different thing that I'll also show grouping.xml. So earlier in the grouping XML, we have only test parameters we have passed and classes we mentioned, right? So now in this grouping, we need to also specify the group tag. So where we have to specify? So before
14:44
Speaker A
so that's again continuous process from the next onwards whenever you create a new test case don't forget to add the grouping tag so grouping is exclusively allows us to separate specific test suit based on their status and it is yes perfect so grouping will exactly
15:03
Speaker A
starting the test, here we need to write a groups tag. Groups, and what groups contains? Groups contains a run tag. Inside the run tag, you should say include. Include name equal to which group you want to execute, you can specify this. I can execute sanity. So this is one include group, and again
15:21
Speaker A
when I specify something in the group only the methods the test methods which are specified with this name will be picked up and execute and all other test methods will be just ignored okay so when I say sanity only sanity will be captured when I say regression regression will be captured
15:41
Speaker A
it depends on your requirement. So these keys you can change. Okay, so I can say this is include, and then I can write one more include. I can, so whichever you want to include, you can just specify
15:57
Speaker A
shown you all the scenarios during the test NG classes grouping class and if you not understood this can go through that video once again you will understand I shown you all the scenarios different scenarios how exactly exclude and include works and everything okay so sanity
16:16
Speaker A
them, and also whichever you want to exclude, you can also write exclude tag. Exclude name equal to something. Okay, so include and exclude, this tag is not needed, so you can have like this for now. So in future, whichever group you want to execute, you can specify your sanity or regression or master, something like this. So if I say
16:32
Speaker A
a relevant name so when I see that particular name or keyword that should exactly reflect the what is a purpose so Master is a general term which we normally use which is collection of everything sanity means a basic test cases regression means every cycle of the testing we will try
16:50
Speaker A
master, all the master test cases. Let's say here I'm putting regression, and here I'll put master. Okay, so if you want to execute only sanity, you can go with this, and if you want to execute only regression, you can go with this, and if you want to execute both sanity and as well as regression, then you can go with the master. So these are the three divisions. So once
17:12
Speaker A
execute this as part of Sanity or regression or something like this and you need to identify but you don't need to separately maintain any XML files for sity group regression group anything just one single XML file for grouping is enough in the same XML file so depends on your requirement
17:28
Speaker A
you added groups, then we can execute this XML file. So even though we specified multiple tests here, I'll just try to enable this. All the test cases should be enabled, and all two I enabled data-driven currently, and just comment this case. Exclude means you can just exclude. Okay, just a second. So in include master section, okay, so in future if you want to remove something, suppose
17:42
Speaker A
be here and only just changing this parameter it will pick required test cases and it will execute okay because even if you have 100 test cases every time you don't run 100 test cases so depends on the requirement suppose whenever you want to you execute regression test case
17:58
Speaker A
let's say I already told you when we have to use exclusion. So suppose some test cases belong to, let's say there is one test case which belongs to both sanity and regression, right? So then I say sanity. That means what? Even regression test also will execute, but I want to execute purely
18:13
Speaker A
cases so that's how we need to configure this XML file okay so very simple concept I already covered all the stuff in the previous classes you can go through this in detail so what we have done is we have added all the test cases to the specific group either can be sanity or
18:30
Speaker A
sanity but not regression. In that case, you can use exclude group. Otherwise, you can just simply comment this. So what I will do is I'll execute this master suite. So whichever group you mentioned there, so that is a particular group of test methods will execute. So you can just enable them
18:45
Speaker A
sanity regression and also Master right so we need to also keep this for every group and then we will create a separate XML for grouping that is called grouping do XML that's it this is how we can simply achieve the grouping concept is it clear everyone please confirm in the chat
19:04
Speaker A
later, and then you can execute. So as of now, I'm not excluding anything because we already discussed this concept in detail in the last session. We can just go through this. So master I just specified. Okay, so now when I execute this XML file, which will pick master test here, master test and
19:31
Speaker A
okay so now so let's move on to the next one so since now we have mentioned grouping tag so we cannot execute using master. XML so mastered XML still you can execute no problem no problem so if you specify the groups okay
19:51
Speaker A
we'll execute. So as of now, under master, what are the tests we have added? Even account registration is also part of the master, and even login test is also part of the...
20:08
Speaker A
will happen it will execute all the test cases by default okay if I don't specify any groups it will execute all the groups by default so that's the nature okay because if you specify the groups in XML file then only it will pick it this particular tags will fetch the uh this
20:28
Speaker A
particular include and excludes are there right so this will exactly Fitch the particular name is available for the test or not here or not if it is there it is matching then we will execute if it is not matching then it will not execute in the master. XML file what happens the groups itself we
20:46
Speaker A
have not specified so by default when execute this XML file all the test will be executed by default let me show you so because if you specify the group uh in include and exclude St then only it will consider the groups otherwise it will not consider any of the groups it will
21:04
Speaker A
by default execute all the test cases so let me put both the tests account registration and login test see in this master. XML I have not put any groups so then still it will try to execute so this is our registration test executed and this is our Lo loin test perfect so by default
21:32
Speaker A
all the test will be executed through Master suit okay so now let's move on to the next I hope everybody's clear on this grouping concept very small concept can easily do this nothing is new so that's the reason I ask everyone to practice test NG
21:53
Speaker A
classes every class is important now again the same topic is repeating here all right so now we go to external report which is very very very important ultimately we have to update all the test case results in the report right we need to generate the extend report so
22:13
Speaker A
let's see how we can generate the EXT report for our project these are all onetime task so first thing we need to have utility file extend report utility class under utilities package okay so let me take this question still I'm getting some questions so what if the test
22:41
Speaker A
belongs to sanity and regression okay and if you only run sanity will it execute those test cases which belongs to both the groups yes that also I have already shown you that scenario yes it will execute so if you just watch our PR previous video I think you don't ask this
23:00
Speaker A
question see I'm repeating once again guys listen very carefully so I have test case one test case 2 test case three test case 4 test case 5 okay this is Belongs to Only sanity this is belongs to sanity and regression this is also belongs to sanity and regression this is regression
23:21
Speaker A
this is regression okay now in the include tag you have to tell me answer include tag I say sanity now tell me what are the tests will be executed in that list T1 T2 T3 T4 T5 among those five when s say include equal to sanity water the test will be executed no problem so
23:43
Speaker A
just tell me the answer for this when I say include equal to sanity water the test will be executed how many are there under sanity T1 T2 T3 three test cases right T1 will execute T2 will execute T3 also will execute so because all three are belongs to sanity only right
24:03
Speaker A
suppose when I say include equal to regression then tell me what are the test will be executed regression regression regression means T1 is not belongs to regression T2 belongs to regression T3 also belongs to regression T4 also belongs to regression T5 also belongs to
24:23
Speaker A
regression that means T2 T3 T4 and T5 four test will be executed okay now what is my requirement is I want to execute only sanity which are not belongs to regression then how we can specify include exclude I want to execute purely sanity test but not belongs to regression so what are
24:50
Speaker A
the test cases comes under here Belongs to Only sanity but not regression T1 is belongs to purely sanity but not regression T2 come into picture T2 no because that is also part of regression we should not consider T3 no T4 T5 anyway regression no I want to execute only sanity
25:12
Speaker A
but not regression that means only I will get one test T1 how we can specify in include section we can specify sanity and exclude section you can specify regression that's it so if you want to get only sanity which is not regression so include sanity but excludes regression so this
25:30
Speaker A
will return it will execute only T1 test case so this is the context okay so similarly I want to execute only regression but not sanity so then how we can specify include and exclude I want to execute only regression but not s what are the test comes under picture now purely regression
25:54
Speaker A
at but not sanity T4 and Pi 4 and Pi purely regression but not sanity so in include section we say regression in exclude section we can say sanity that's it okay so I think everybody's clear now how we can do this so these are the different things so remember this it is very
26:16
Speaker A
simple all right so now shall we move on to the next one so extend reports so in extend reports the first and most important thing is we need a utility file so extend report utility file so in the last classes we already seen that utility file but there are few things are missing in the
26:42
Speaker A
utility file like report name generation how we can generate the report name with the timestamp and how can we add screenshot on failures to the report right instead of uh displaying the test methods I want to display the test case IDs in the report so these things are missing from
26:59
Speaker A
the last report so we will try to uh cover them in our current report so I'll share this extent report utility class which contains everything accordingly uh you can use same thing just a second extend report utility so where you have to put that utility class in which folder under utilities package
27:34
Speaker A
because generating extern report is a part of utility class so I can put here extend report manager okay so let's uh go and see this particular file extend report manager okay so this is a uh extern Port manager file so what is an error sh showing capture screen
28:02
Speaker A
okay no problem so this is a utility file extend report utility file so I will go through each and every step so let's carefully listen so few things we already covered in the last sessions and few more additional stuff I have added here so this is same again on start method on test success
28:21
Speaker A
this is the listener class basically right it is a listener class and on test failure on test skip then on finish okay so let me tell you what exactly these will do so first thing on start on start uh we already discussed right a few classes are there extend is spark reporter extend report
28:43
Speaker A
extend test again I'm not going to explain all these things because we already covered and what are the new stuff we have added in this I will cover that part so the first part is name of the report so earlier we have given here the hard coded name we already created reports folder so in
29:02
Speaker A
this extern report will be generated in this report folder we have to generate the report so earlier we have given a static name here let's say my report something.com my report.
29:13
Speaker A
HTML something like that so what is a problem when you give hardcoded name here is we cannot maintain the history of the reports suppose yesterday I have done one round of execution today again one more round of execution have done so I want to verify the test results yesterday execution and
29:30
Speaker A
today's execution then it's not possible so if you maintain the history of the reports like yesterday report today's report then I can compare them so in that case what we need to do is whenever you create a report if you create the report name with the Tim stamp current timestamp then we can
29:47
Speaker A
maintain the report otherwise what happens if you give the static name that will replace the old report name because same is name is the same exactly right fine so first step is we need to to First create a date timestamp then we will append the date to the report so to create a date time
30:06
Speaker A
stamp this is a piece of code I can write so let me go through this code and uh then I will do it there is a class called Simple date format and the simple date format is a a class which is
30:19
Speaker A
there in java. text package this is a predefined okay and DF equal to new simple date and in this we have to specify in which form format we have to generate the date which format so here first years
30:33
Speaker A
then month date hours minutes and seconds along with the date and time also okay so time also very important because hours minutes seconds also very important why because in the single day same day you can run test case multiple times right so hours minutes and seconds also most important
30:52
Speaker A
so I will generate the date in this particular format so this is a special class we have used simple date format I created one object called DF equal to new simple date format I'm passing the format and then to create the date in Java we have a special class called date date equal to DT
31:10
Speaker A
equal to new date and after that we already have a DF right simple date format in that we have a method called format in this we have to pass this date object because we want to generate the date
31:24
Speaker A
in the particular format that's the reason so in the date format object do format is a method in this we have to pass this date object so this particular part will return the date in a string format string format so that will be in the exact this format first year month date hours minutes
31:45
Speaker A
and seconds so this piece of code we have to write to generate the time stamp means which includes the date and current time so instead of writing three steps I can also write a single step I can put all three in one single step so this is a single step I put so what I have done here is
32:06
Speaker A
just you need to split the statement then you can easily understand so here simple date format DF equal to new simple date format I mention the date form so to avoid this particular variable I have taken this entire object here okay new simple date format and we stored this object in a variable and
32:30
Speaker A
from this variable we are calling the format method right so then what I have done instead of creating this variable I've just taken this part here dot I'm calling the format method both are same right if I stored this in a variable DF and DF do format instead of doing that I directly
32:50
Speaker A
get this object do format I have used simple so I I I combined this one and this two and inside the format what we have passed DT what is this DT new data datea object we have stored so instead of
33:09
Speaker A
creating this variable this new date I directly I have passed in the format method both are same right in the format method we pass DT here same thing in the format method I pass DT here both are same so I have just combine these three statements into one single statement just by avoiding the
33:27
Speaker A
multiple variables so DF is a variable I have avoided and then DD also have avoided now that I can store in this time okay you can have three statements or you can have a single statement so this is a time stamp this is the way we can get the time stamp in Java current time stamp Now by
33:45
Speaker A
using this Tim stamp we have to generate the name of the report so I have taken one string variable here rep name which is representing report name so report name equal to test Typhon report Typhon this is the first name of the report ion and I'm attaching the Tim stamp whatever I have generated
34:04
Speaker A
so I'm just concatenating the report name along with the Tim stamp and extension of the report is what HTML so I say HTML so I have concatenated that means the overall the report name will be test tyen report ien timestamp do HTM this time term will be dynamically generated okay so this
34:26
Speaker A
is the ultimate report name this particular name I will provide here at the time of creating the new report where where exactly it is creating in which location reports location dot is representing current project location sl/ reports folder inser the reports folder the report name I
34:45
Speaker A
specified here so this is a way we can generate the report with the time step so this is a first step so here we specify the location of the report and here we generated the time step and time
34:58
Speaker A
time whatever we generated that we have concatenated with our report name clear so this is the first part now rest of the them are same so this is the document title report name and theme okay now come to this part in the last classes we just hardcoded a few values which are
35:22
Speaker A
populated in the report right like tester name operating system name browser name and so on but this time we will get that information dynamically so if you look at here uh application name we have to hard code there is no other way so application name is open cut module module name subm module
35:41
Speaker A
name and these These are the project related Project Specific details so we specify them and after that so who is executed the test case if you want to get the name of the tester you can put username and system. get property of user.name so this particular method will return the current
36:00
Speaker A
user of the system who is using your system who is running your test cases that particular name will be returned so username in the place of username it will display the tester name and environment QA this we have to hard code and the rest of the things we need to dynamically get
36:17
Speaker A
for example in which operating system your which from which operating system uh no no this is not property file so we are not getting anything from the property file that's a total so we are using a predefined methods to get the data from environment environment variables so
36:34
Speaker A
user. name is it will return the username current system username okay so these are the few values we will populate in the report apart from this you can also populate operating system browser okay and what are the groups of test methods we have executed the groups information also
36:52
Speaker A
we can put in the report in the common details so how to extract the operating system is simple so here when I run this when I execute this on on start method it will capture the test context test context is nothing but what which test method we got executed so that test method details will
37:11
Speaker A
be stored in this variable so by help of this variable I'm getting the current XML test so this particular test is executed by which XML file so I'm getting that XML file from that XML file we are getting the parameter OS you remember when you run the XML file we are passing the parameters oos
37:32
Speaker A
and browser parameters from the XML file so these are the values we need to capture into the report so these are the values whichever operating system we are passing whichever browser name we are passing so these are the two values which we have to capture into the reporter so how to capture
37:48
Speaker A
these values from the XML file dynamically is this is the process from the test context get XML test from that get a par of os similarly text context get current XML test get parameter of browser so these two statements will capture operating system and B browser name from the XML file from
38:13
Speaker A
where you have run okay got my point so operating system and browser name we are getting dynamically from the XML file whichever browser name we are passing whichever operating system we are pass passing obviously we have to get into the report so these two values we are getting from the XML
38:34
Speaker A
file any confusion here anyone so these are all the different methods which are available so we are using those methods you no need to remember all these things is very difficult to remember okay so now groups also so for example I have run specific test test test cases and which groups
38:55
Speaker A
they are belongs that group information also I can operate in the report so for that from the test context getting the XML file basically get current XML test method will return the XML file from whichever XML file we have run started run that XML file be return okay so from that XML
39:13
Speaker A
file get included groups so what this method will do is suppose if you run the grouping XML file okay suppose if you run this grouping XML file so we'll have some include groups right so what this command will do is this particular get current XML test. get included groups this
39:33
Speaker A
particular method will return will capture the groups which we have specified in the include section the group names which we specified in the include section will be captured and display them in the report display them in the report some for example I don't have any groups suppose if I'm
39:54
Speaker A
executing this master suit I don't have any groups here but then how come it will capture the group names if there is no group names right so that condition we have to validate here test context.
40:06
Speaker A
getcurrent XML test get included groups we are getting all the groups in the list collection okay we are getting all the groups in the list collection and if include groups is empty that means we are not running any groups then what we need to do is groups information just to specify
40:24
Speaker A
the name not empty not operator have used okay if the group information is empty it will not display any groups in the report if the group information is available that means not operator include groups. ismt is not then add this information to the report include groups. two string so this
40:46
Speaker A
method will add all the group names to the report but before adding the group name to the report first of all group names are available or not that we need to check so once available then only add this if it not available then don't add so this is additional stuff we are going to add into
41:03
Speaker A
the report okay even cross browser test results also will be added into the reports when when you executing the cross browser test it will generate multiple reports for Chrome browser it will generate one report uh Firefox browser another report so multiple browsers multiple reports
41:20
Speaker A
will be generated so that is a different contest don't Club here I will show you that separately okay so guys you understood this why have written these statements so these are the common data we populated along with that few details we have to capture from the XML file like operating system
41:38
Speaker A
browser name because these are the values we have to pass through XML file right at the time of execution so we have to capture these details from the XML file that's the right way to capture instead of hardcoding the data similarly suppose if those test cases are attached to particular
41:54
Speaker A
groups then we will also capturing those groups and and specify the or display the grouping information on the report this is a first method on start method is this clear so far everything so cross browser testing forget about it I come to that part so till here what are the additional
42:17
Speaker A
information which we added is this clear so even though if you're not understood all these methods no problem but at least you need to understand why we have written this statement why the statement is written all this things why we verify this condition so at least this much you have to be
42:31
Speaker A
clear so not include groups is a negative operator suppose okay let me explain by taking simple example so why have not used not operator here let us say I have multiple test cases okay so I have added to some group sanity or sanity or regression thing so in the report along with
43:00
Speaker A
the test cases along with the we put some common information right suppose these tests are belongs to specific groups so I'm executing the specific groups so sanity I'm specifying sanity group I'm executing so this information I want to put in the report okay so these are the test cases are
43:19
Speaker A
executed from the sanity group I want to display this okay suppose some tests are regression some are master so have executed sanity regression and master multiple groups so all the group information whatever test case are belongs to multiple groups all the groups information I
43:36
Speaker A
want to names I want to display in the report like this okay so what we need to do is this particular command test context. getet current test. get included groups it will capture all the groups whatever we have included in the XML file and store them in the list collection all the group
43:57
Speaker A
names will be stored in the list collection okay and then from this list collection by using this two string we are printing the groups suppose if these methods are not belongs to any of the groups or I have not executed first of all grouping do XML file I have run my master XML
44:15
Speaker A
file in that I don't mention any groups right in this particular case how this will deal but we don't have any groups in the XML file right so then what it will do is it will try to Capt
44:27
Speaker A
all the groups if XML file doesn't have any groups then it will be empty only right the value will be empty empty is what true is empty this method we already discussed in the list collection concept so if you have some elements suppose in the list collection I have some elements so now I'm using e
44:49
Speaker A
empty method what this method will return true or false if I have some elements in this list collection I'm using e mty method what this will return true or false true why because there are some elements suppose I don't have any elements it is totally empty then what it will return is
45:08
Speaker A
empty is empty yes true if you have some elements is empty false it will return negative right so that is what I'm checking here includes good. is empty is equal to false means e mty returns false normally e mty is equal to not means what if it is not empty if it is not empty means what it
45:31
Speaker A
contains some values it is not empty means what it contains some values if it is contain some values and print them in the report print them in the report that is a conditional statement if it is not empty that means what some values are there if the values are there then print
45:51
Speaker A
them okay if it is an empty there are no values then don't print them so that is a condition we are validating in a if condition okay so this is a utility file so this is the way we need to
46:06
Speaker A
populate some common information into the report so this part now come to the on test on test success and here we created a new test case in the report so what exactly it will do create a test method we will create a new entry in the test case so from the result object because whenever on
46:31
Speaker A
test success method is got triggered the result will capture the all the result information from the test method so from that result we get we are getting the which class we have executed from the result We Will We Will extract the class which class we have executed from that
46:47
Speaker A
class we are getting the name of the class see we are executing these classes from the test cases right so class is nothing what this one and this is a method name normally what happens in the extend report these methods names will be displayed but I don't want to display the method
47:05
Speaker A
names I want to display the class name that is actually representing the test right test case so that I want to display so for that what I can do here is from the result get the class from the class get the name of the class and with that class name I'm creating the new entry in the
47:23
Speaker A
report okay and also from that particular test from that result whichever test method is got executed getting that method and whichever group the test method is got assigned I'm also getting that groups and that also I'm adding to the test because along with the test case I'm also adding
47:47
Speaker A
the group which group the test case belongs to and then finally I'm adding the log status. pass result. get name so the result. get name is nothing but again same name of the class and got successfully executed this is the message I have added so once we generated the report
48:02
Speaker A
you will see all these options okay so we can also display the group names in the report in the test case wise okay in the Common Table format you can specify the group names along with that each test
48:14
Speaker A
case wise also will specify the group name so this will do that job same thing for on test failure so from the result we are getting the class name class first we are getting the class from the class we're getting the name with that name we are creating the test also we are assigning the
48:32
Speaker A
category which category that test is belongs to category in the sense group only okay there is no something new category is nothing but a group so assign category result. get method get groups so from from the result from the method getting all the groups whichever groups that method is
48:49
Speaker A
got added and add those groups to the particular test case so that is called SN category but in on Val we need to do some additional stuff what is that additional stuff so along with the status we have printed so we also printed the error message in the error message also
49:08
Speaker A
we can print the report apart from that we should also attach the screenshot of the report so screenshot of the failure so on the screen wherever the failure is happened we need to capture the screenshot attach the screenshot to the report so how we can do that
49:27
Speaker A
we need to do some few changes so when this on test failure method will be triggered whenever a test method is got failed then on test method will be trigger on test failure method will be triggered and after executing of the statement so what this statement will do us in the Base Class
49:47
Speaker A
whatever we created in the base class we should also add one more a method which will capture the screen okay so first we go back to the base CL add that method because capture sken method is common for all the test cases right so where we have to put this capture sken method in the base class so
50:05
Speaker A
we need to go back to the base class so inside the base class I will add capture screen method let me add so listen very carefully guys if you miss something again you cannot proceed further so this is the method I have added so this is the new method which I have added I will go through this
50:34
Speaker A
also so for a few seconds let us come back to the base class so here we stopped so on test failure here we are attaching the screenshot to the report but before attaching the screenshot to the report we have to capture the screenshot right once we have capture the screenshot then only we can
50:53
Speaker A
attach the same screenshot to the report but this on failure will execute on test failure whenever test method is got failured so these statements will be executed but before executing this the screenshot will be available so where we have to capture the screenshot so go to the base class we
51:10
Speaker A
have added a new method here capture screen and this capture scen method will take some name as a parameter because we need to provide some name to the screenshot so normally whatever the method name we have given to the test method same name we will capture the screenshot so we'll take one
51:27
Speaker A
test name and inside this even the screenshot also we have to save with the time stamp okay the screenshot also we have to save with the time stop because sometimes what happens is same page same test case if you run multiple times It capture multiple screenshots if I give same
51:45
Speaker A
name the old screenshot will be replaced with the new screenshot so always whenever you are generating some files try to save with the time St okay same command I us string time St equal to new simple date format this date format we have to import from java. text and date also we need
52:03
Speaker A
to import from java do util package remember this java. util package and take screenshot we need to import from selenium output type also we need to import and then file so we already seen how to capture the screenshot concept earlier so again do not ask now if you have not understood this
52:25
Speaker A
go through my previous class again so I already asked everyone to practice the stuff so again the same thing is repeated here so first I have generated the Tim stamp okay and how to capture the screenshot we already know that so we need to use a t screenshot a special type of interface
52:43
Speaker A
is there right so we have assigned the driver to the screen scen so driver we will anywhere we'll get it from the base class it's we are creating the driver so we can directly use it and source file we are getting but we have to copy the source file to Target file so here where we have to copy
52:58
Speaker A
this in the project location in the screenshot folder and with the time stamp so T name whatever the name I'm passing to the screenshot with that name underscore the time stamp which we generated so what could be the name of the screenshot now whatever name here we are getting the screen uh
53:18
Speaker A
the name of the test method underscore the Tim stamp which we generated do PNG because it's a screenshot so this is the actual name which will be generated with the time stamp okay now this is a target file so now what we need to do we need to copy the source file into Target file
53:38
Speaker A
for that we have to use this command Source file. rename to Target and once it is done finally what we are returning we are rning the path where exactly the screenshot is located the uh Target file path screenshot path I returning so this is a method we do that so capture screen
53:58
Speaker A
method will capture the screenshot of the test wherever it is got failed it will automatically capture the screenshot okay but who will call this method where we have to call this method because until unless we call this method the capture screenshot method cannot capture the screenshot
54:17
Speaker A
right we have to call it but when we need to call every time for every step no right when whenever the failure is happened right whenever the test is got failed then we will capture the screenshot see if you don't return the path because this path we have to use in
54:40
Speaker A
the report extern report manager okay because as soon as we copied the file path source to Target because based on this path only we will attach the screenshot to the report otherwise you cannot attach the report you cannot attach the screenshot to the report if you not return
54:55
Speaker A
the path it will just cap screenshot and keep it in the folder that's it what is the use of it right so if the file is just you copied that but you have not written that then what will happen
55:08
Speaker A
the screenshot is available in the screenshot folder but that is not part of the report okay so this part so this is a way we need to capture the screen chart this part is clear everyone so don't go beyond that I will come to each and every step so still I have not discussed about TR catch
55:28
Speaker A
block and all those things so just this part is clear or not just tell me that okay so don't go beyond this I've just captured the screenshot method I've written one new screenshot method but the next step is what when we have to execute this method from where we have to execute this
55:44
Speaker A
method so these are the two questions when to execute and from where we have to execute so normally when to execute this method whenever a test method is got failed whenever a test method is got failed then we'll execute this right from where we will execute where we will execute how
56:04
Speaker A
we will know whether test method is got failed or not at the run time in the run time how we will know whether the test method is failed or not yes in the extend report manager we have this method
56:16
Speaker A
right on test failure so if the test method is got failed this onest failure method will execute right if my test method is got failed immediately on test failure will trigger or not yes if on test failure is triggered means what my test method is got failed so inside this on test failure itself
56:41
Speaker A
we have to call capture screenshot method why we have to call this capture screen method on test failure because capture screenshot method will be called only on the failures but how we will know whether test method is failure or not if on test failure is got executed that
56:59
Speaker A
means what my test is got failed okay so when to execute capture skin method whenever the test method is got failed then capture skin method should be executed that means whenever on test failure method is got triggered then we have to execute capture scen method first point is
57:19
Speaker A
clear second why we are calling this capture screen method only from the on test failure because on test failure will be executed only on the failure cases so here we need to call but if you look at the capture schem method go to the base class capture schem method is created under
57:41
Speaker A
what Base Class can we access this capture skin method directly from the Base Class directly from the base class no because this is not a static method this is not a static method right so how we have accessed this here is extend report manager I have created an object for the base class new base
58:03
Speaker A
class but the object I have not stored in another variable I have just avoided that variable okay I created an object for the base class from that object I called capture skin method and what capture skin method is expecting parameter name of the method so whenever you executing the
58:22
Speaker A
capture schem method here it is it is expecting some name in the string format so in the extern report manager I'm getting the name of the method from the result itself because the result contains the name of the method right which method is got failed that information is it will store so
58:41
Speaker A
from the result object I'm getting the name and that particular name I'm passing to the capture screenshot method so what capture screenshot method will return return finally from here the cursor will go to base class as capture skin method and this will be executed and finally it
59:00
Speaker A
will return the location or path of the screenshot and again that we are capturing into the variable image path you got my point so this statement will invoke capture skem method from the base class and by passing the name and it will return return the location of the image and now this image we need
59:24
Speaker A
to attach to the report so test is representing the report so test. add scen capture from path and here we need to pass this image file path that's it so this will go and attach the screenshot to the report these two things will do parallell so as as soon as the test case is got failed
59:47
Speaker A
immediately it will capture the screenshot method will trigger Capt screenshot will be captured and as soon as screenshot is captured this statement will attach the screenshot to the report okay and why I put this in the TR catch block for example if the screenshot is not properly taken okay the
60:07
Speaker A
screenshot is not properly taken or screenshot is not available it is still trying to attach the screenshot to the report so in that case File not found exception you will get okay in that case we'll get a file not found exception so we will put in the try catch block if the
60:24
Speaker A
screenshot available no problem catch block will not ex if the screenshot is not available then it will throw some exception so just we had add we are capturing that exception that's it so this is on test failure so the main crucial thing is this part you need to understand this so capture
60:40
Speaker A
screenshot method we already created in the base class so that's the reason by creating a base class object this is a base class object new keyword will create a new object but that object I'm not stored into another variable I'm directly used here and do capture screen result. get
60:56
Speaker A
name and it will return the image path and with that image path I'm attaching the report to the rep I'm attaching the screenshot to the report so it is print stct race okay this is a predefined method which we can access from the even and this will just display the exception message
61:17
Speaker A
that's it print stct means in the console box in the console window it will just print some warning message something like that because once you to catch it we need to write something in the console window right even if you remove that no problem so everybody's understood on this on
61:34
Speaker A
test failure how we can implemented this method there are so many things are there but you need to spread them and try to understand even though if you don't know and if you not remember those methods still that is fine but if you look at the statement you should know why the statement
61:48
Speaker A
is written why the statement is written why the statements are written you need to understand at least that much for okay and Method names and all not important to remember but when you look at the statement you should understand that what exactly it is okay every statement you should understand
62:07
Speaker A
that's the reason I'm going to each and every step so what this particular statement will do this one will do we need to split it actually so result from the result it is getting the class and from the class it is getting the name of the class and with that name it is creating the new test
62:25
Speaker A
entry in the report that the meaning of it and what is the meaning of this from the result it is getting the test method whichever we executed and from the test method it is getting the groups in which group the test method is belongs to it is capturing those groups and those groups will
62:44
Speaker A
be attached to the report as a category wise and this is we are updating the test cases failure information here we're print printing the error message and here we attaching the screenshot how we are attaching the screenshot from the base class we are calling a screenshot
63:02
Speaker A
method by passing the name of the test and it will return the image path and by using this particular method add screen capture from path we're attaching the image that's it this is on test failure okay everybody's clear on this it is you need to understand the very high
63:26
Speaker A
what exactly it is doing because this is a utility file okay even if you're not understood there is no problem at all because you can just copy paste this code as it is in your projects I can use it
63:40
Speaker A
now on test skip is very straightforward and we are creating the new test by getting the class name and getting the class class and get the name and uh create the new test and send category again groups also we attaching and because on test skip method will Ex whenever the test method is got
63:58
Speaker A
skipped this will be added and also the message why it is got skipped so that also I'm adding this is on test skips very simple now this is important on finish on finish so in the on finish uh we
64:15
Speaker A
have to do few things actually so only one this method is enough extended. flush so this method will uh consolidate all the information from the report and finally it will jump generated this one single statement is enough on onfinish but I have written an additional statement what exactly it
64:32
Speaker A
is doing is so normally where the report will be generated under reports folder and if you want to open the report how we will open we need to go to the report folder and then we need to right
64:45
Speaker A
click on the report file right click open in the browser we have to do it manually right so instead of avoiding this part suppose as soon as I have executed my test cases as soon as my report is
64:55
Speaker A
got generated immediately it will automatically open I don't want to open the report manual I I want to open the report automatically for that we can add this piece of code so what this will do is from the project location from the reports folder and whatever report name we passed here we
65:13
Speaker A
already generated this report name right with the same report name I'm referring so that I'm going to store in a variable basically this is the path of the report and then we have to create a VI file object file extern report equal to new file because extern report. HTML that is also
65:28
Speaker A
a file so we'll create a file object equal to new file and pass this location into this now what is this extern report is representing extern report file and in this we have to call one method called desktop is a predefined class in this we have a method called get desktop do browse and whatever
65:50
Speaker A
extern report we captured that extern report do to U what this method will do is this Butler method will open this report on the browser automatically we no need to write we no need to open the report manually it will automatically open the report on browser so why I put in the dry cach block for
66:10
Speaker A
example if this external report is not available this will throw some exception so that's the reason I put in the TR catch block so this is additional piece of code optional code so if you want you can write it or else you can comment it no problem so this piece of code you can comment
66:27
Speaker A
okay because if you include this code we only need to open the report manually it will automatically opens and this is all uh other uh piece of code basically this will automatically send an email uh suppose as soon as you generated your report right so you want
66:45
Speaker A
to send that report to your team automatically as soon as you automation tests are completed execution immediately you want to send a report then you can enable this piece of code okay so I can just remove this code so just un commenting
67:06
Speaker A
this okay so I'm just uncommanded this code so what what exactly this code will do is I will tell you just a second all right so uh I put this everything in the TR block okay so let's go through this so what exactly this piece of code will do so this piece of
68:08
Speaker A
code will actually send a report automatically whenever the report is got generated so for that what we need to do is first we need to uh get the okay so we already have a report in the reports.
68:24
Speaker A
reports folder right in which format HTML format okay so that we will open in the browser so here we need to convert that path into URL format so URL format of URL so normally when I open the report in the browser you will get the URL in the browser right so this is a URL format actually so
68:47
Speaker A
file colum current project directory reports folder report name so this is a location that will convert into URL and then we have few methods image HTML all these things we have but we need to add some dependency actually we haven't added Java email dependency we need to add let's go to mvn
69:08
Speaker A
repository and search for Java email okay so Apachi common email you can just go with this so 160 you can get it so go to p.
69:27
Speaker A
XML so add this dependency okay so now go back here so now we can get image HTML email so this package we have to import so all this stuff we need to import so you can see import data source URL resolver all these things we need to
69:56
Speaker A
import okay done so first we need to convert the uh report URL format and then we have to create there is a lot of stuff is guys because I'll tell you just main important stuff what you have to change so this email host name port number is depends upon the email server so this
70:18
Speaker A
particular piece of code will work for only Gmail if you want to use yaho email or suppose if you're are working in some company you will have a corporate ID right like your name atate your company name.com so this keeps changing so this is not a constant value okay this keeps saying
70:36
Speaker A
this is for only google.com you have a Gmail ID you can try this and this is a port number and here you need to provide the authentication information like who is sending the email ID and their password you need to specify and here again send from sender email ID and the subject of the
70:54
Speaker A
email and and in the email body whatever message you want to write you can write it and then from whom you want to send an email like you can add to you can add one single email ID or you can
71:06
Speaker A
add multiple email IDs so normally if you don't have mult if you want to add multiple email you will create one something called distribution list DL in your real-time companies suppose if 10 20 members are working in one single team right suppose a manager want to send an email
71:22
Speaker A
all to all the 20 members so they don't include all 20 people in the CC or anywhere so they will create one combined email ID that email ID contains everybody in the team that's called distribution list we can call this a DL email so that you will specify normally here and then what
71:39
Speaker A
is an attachment we have to attach to email so URL the name of the file attachment name and you can put some message and send is a method which will automatically send an email so if there is any problem at the time of sending or the file is not properly attached or not properly sent then C
71:55
Speaker A
patch block will execute so this piece of code we can use to send automated email to the team okay so you guys can try this later but you need to provide your your own email address and your email
72:11
Speaker A
password okay so I will just put this in the comment I'm not showing this now I'm just giving the functionality if you want you can export this line number 80 where is that 80 okay what is your question R me this is on test
72:33
Speaker A
failure okay so this is a last method on finish so on flush is enough but this is extra code I have written so this piece of code for what automatically the report will be open I will show you that functionality also and rest of them are for sending an
72:52
Speaker A
email so line number 81 82 8182 is basically for what 80 is nothing but on test failure so this method will be triggered automatically 81 is nothing but here we are creating the new entry in the test report this is same for these two methods these two statements
73:10
Speaker A
are same for every method here we have written also here also we have written every test on test success on test failure on test skip also we have written the same statements basically what those two statements will do is from the result it will capture the class
73:26
Speaker A
from the class which class we have executed that class will be captured and get the name of the class with that name only we will create a test case entry in the report and the second step is suppose uh which category the test case class is belongs to because we have added multiple groups
73:45
Speaker A
right so which group they are belongs to so that also information we can capture from the result get a method because the groups we have added only to the methods right so get a method method and that method is belongs to which group so it will capture all the groups so the group information
74:01
Speaker A
is also attached to the particular test method so that is all about two statements to display the group information on the report we will add this statement okay so this is the full-fledged and final uh extern report manager file okay and one more thing so this Gmail accounts don't
74:24
Speaker A
try multiple times because sometimes your Gmail account will be blocked because we are controlling everything through automation so Gmail servers uh some production applications will not support okay if you do multiple rounds of execution on the Gmail they may be blocked so just do only one
74:41
Speaker A
or two rounds Max don't go beyond that if you face any issues just stop doing it but in the real time you don't have any problem because you will have a corporate ID here and the server details also
74:51
Speaker A
will be different so you won't face any issues but I'm giving this piece of code for refer purpose in future if you want to use you can do it okay and you need to change all the details whatever is required done so this is the extern report manager now let's go back and see the steps
75:07
Speaker A
first we have created extern report utility class under utilties package then we have added capture schem method in the Base Class also this is also we have done the next one is we need to add extern report utility l a class entry in the XML file right we need to add this entry in the XML
75:25
Speaker A
file then only it will able to execute so let's do that in XML file we need to add that entry okay go back to master suit and where we can add this listener entry where we can add this
75:46
Speaker A
listener entry so before test is started here I can add so which we what we need to add listeners right listeners opening tag and in tag inside the listeners listener okay this is the listener tag opening tag and closing tag and inside the listener sorry
76:12
Speaker A
inside this listener itself listeners listener class name class iph name equal to then closes so we need to specify The Listener class name along with the package so where where it is there under utilities so you can say utilities dot what is the name extend report manager extent report manager
76:40
Speaker A
okay that's it so I will also create one final XML file which will have all the listeners groups and everything so this is a way we can attach the report and even if you want to attach this another
76:55
Speaker A
XML files you can do that so go to grouping XML file so where we need to add here listener so here we can add before the test in all XML files we need a report right so I'm just adding that
77:09
Speaker A
even in the parall cross browser testing is also if you want to add listeners you can add it here that's it okay everywhere in all XML files we have added listener class now whichever XML file you want to execute you can execute so let us to execute grouping because we can also populate the
77:28
Speaker A
groups in the report right so that you can see so let's go and one more step we forgot it here uh just a moment go to the document and last step so we need to make sure web driver is static in the
77:43
Speaker A
base class because we refer the same driver instance in the extern report utility see if I go back to the extern extern report utility class okay so in this this we are calling the capture sken method right so here we are calling the capture skin method and what we are passing
78:05
Speaker A
here name of the file we are passing name of the class we are passing then it will go to the base class in the base class it will call the capture scen and get the name but inside this we are using
78:18
Speaker A
this driver right we are using this driver so basically One driver will be created here and from the extern report manager we are creating a new object whenever you create a new object for the Base Class okay then what will happen Base Class will have another object even that object
78:40
Speaker A
also having a new driver right see two drivers will be creating now so first in the base class anyway we already have one driver here we already created One driver instance here now in the extern report manager we created an object of the base class so inside the object also there is one
78:59
Speaker A
more driver right so the base class driver and the object related driver are not the same because as soon as your object is created that is separate so there are two different drivers are there so there will be conflict then what we need to do we need to make web driver as a static then the same
79:22
Speaker A
driver will be referred in the object also you got my point so we need to make web driver also St tier we need to also web driver also starting why we need to do this because the base class will
79:38
Speaker A
anyway will create one our driver and that is referring everywhere but additionally in exter report manager this Base Class object also having their own driver because we created an object we are not directly accessing the driver from the base class so this will have another driver
79:55
Speaker A
but if you have a two driver instances definitely there will be conflict execution will not be happen so how we can make it as a common variable across multiple objects if you want to make it as a common variable what is the way we can follow only by making the variable is static
80:12
Speaker A
the Java classes we discussed that so I should make this as a static okay this is the last step fine perfect so all all the steps we have successfully executed done so now let us execute and see the reports so everything I'm closing so whichever XML file you want to execute you
80:36
Speaker A
can execute so I'm choosing grouping XML file so that I want to display the group names also in the report so what I will do is I will try to execute the master group I'll include this master group Master means by default all two test cases will be executed perfect so now run as test NG
80:59
Speaker A
test so this my first test is got executed second test is got executed now you can see observe report is automatically opens see this earlier we haven't se this option report is automatically created and automatically open I I have not opened report manually earlier what I have done earlier we went to this report folder
81:31
Speaker A
where is report folder Ive refreshed it and after refreshing I got a report and then I just right click here we open with the system edor so this is the process we followed so now we no need to do like this automatically open and if you look at the report name can see the
81:48
Speaker A
time stamp with the time stamp is got generated see I will run one more time and then we will see report history is maintaining or not so I will REM I'll close this report now just one more round
82:02
Speaker A
I'm executing and this time I will intentionally fail the test case and then we will see whether the screenshot also attaching or not in the report so for example uh in the login test in the login test I'm passing email and password from the properties file right so what I will
82:20
Speaker A
do is I will just pass some invalid password so that my test will definitely be failed so I can just comment this part and instead of this getting password from the properties file or else if you want to change you can change this in the property file also okay let me change in the property file
82:37
Speaker A
better I'm passing the invalid password go to the property file close this where is our property file resources conf professional this is a valid password right so I'm giving some invalid password I can say this I can how can we comment the if you want to comment something in the conso in
83:02
Speaker A
the properties file you will use hash okay hash is a comment this will be different XML file comment is different Java file comment is different property file comment is different okay I just commented this now I put this test at theate 1 2 3 I say test at theate 1 2 3 4 5 invalid
83:21
Speaker A
password so my intentionally I'm failing my login test okay now go to the grouping XML and then execute so I want to see the two reports first round I have already executed both the tests are passed second round again I executed one test is got
83:40
Speaker A
failed okay login test this is got failed okay done fine so one now we can see automatically report this is the latest report so if I look at the first test let me increase the font yeah now we can see the name is displayed or not
84:09
Speaker A
exact name from the test cases test case ID is displaying earlier the previous sessions only the test methods are get displayed so now you can see I selected my failue test it is also tached the screenshot see when I click on the screenshot it it will be bigger size so I can
84:26
Speaker A
close this if you want so you can see the time stamp the details everything will be displayed here everything is very and also group names you can see this particular login is belongs to both sanity and master right so sanity is displayed Master is also displayed and in the go to the
84:44
Speaker A
first test case which is belongs to actually account registration test is got passed so which is belongs to registration and master two groups and this is one report now go to the second one this is the one here you can see all the information in the group wise so from the
85:00
Speaker A
master group how many test cases are executed two test cases because both are belongs to master from the regression one test is got executed from the sanity also one test got executed so this is group wise result or category wise results so this also we can check it this is additional stuff we can
85:18
Speaker A
see in the report now the third page go to the graph section in the graph section also you can see everything in the graphical mode so when it started when is got completed so how many are got executed passed failed all other information you can see here yeah now you can see this particular
85:38
Speaker A
table tags so from the master suit how many are got passed one passed one failed 50% passed in the regression side one executed one passed no failure 100% passed from the regression from the sanity one is got failed of them are not executed so 0% only once already got executed
85:59
Speaker A
so this is a table format also you can see this now system and environment details see here all the details are automatically populated so name we have to put this actually I think oh this is the header actually application is open cut module name subm module name usern name environment which
86:19
Speaker A
operating system we have executed on which browser we have executed and which group we have executed Master group is specified in the XML file right that we capture so in detailed report we can generate so in the first page second page third page three pages of information will
86:36
Speaker A
be displayed first page you can see only test cases pass or failure in screenshot also will be displayed here second page group- wise results you can see third page graphical format and overall summary type of report you can see here this is a ultimate report for
86:55
Speaker A
automation extend report if you keep on adding more number of test cases it looks very very beautiful okay so now we can see World Report first time first round I have execution run so I have done Let me refresh it see the top one is a previous report so you can also maintain
87:14
Speaker A
the history of the report so you can open this the system Eda so first time both have passed right so I got both are passed and you can group also group information also displayed and here it will show you the graphical information in the third section everything is passed so everything
87:31
Speaker A
is green and popular information is populated here so this is how we have to generate the report clear everyone so far everything is done by extend report manager utility file this is the most important file this is the customized one if you want you can change the theme and everything
87:57
Speaker A
other information and everything if you want you can change it so clear everyone so far please confirm in the chat box so you need to practice this step by step extern report uity capture scen extern report everything you should do step by step practice now I'll take another five minutes
88:17
Speaker A
guys so I'll take a small topic very simple how to run failure test cases this is very important scenario even interview also people will ask you the question let us say you have 100 test cases for example you have 100 test cases in 100 test cases in the first round of execution in the round
88:38
Speaker A
one 90 test cases are got pass 10 test cases are got filed now in the second round of execution I want to execute only these 10 test cases how it is possible how it is possible so whatever test are
88:54
Speaker A
already passed I don't want to execute again I want to execute only failure test cases I want to capture these failure test cases somewhere and that I want to execute so how it is possible so if you execute XML file normal XML file it will again execute all the test cases right by default it
89:12
Speaker A
will execute all the test cases so if you go back and see like let us look go to the master suit for example so if I go back to the master suit in the master Su we specify all the test cases let's say
89:28
Speaker A
you mention here 10 test cases first time few test cases got passed few test cases are fail next time whatever fails are there so only failure test case I want to execute again if you run this XML then what happens whatever got passed earlier those tests also will be executed I don't want to
89:44
Speaker A
happen this only failure test I want to execute if you have 100 test cases how it will remove and how it will add it is very tedious task right so again removing adding the test cases is a tedious
89:57
Speaker A
step I don't want to remove anything I don't want to add anything let it be the XML file but still I want to run only failure test cases so in test NG is provided one important feature very very useful feature I'll tell you what is that feature okay so for example let's say go to
90:14
Speaker A
the master su. call so I'm running the two test cases okay uh anyway login test will definitely will fail right so next round I want to execute only login test which whichever is got failed first round I will execute both the test cases account registration will pass login will fail
90:31
Speaker A
now next round I want to execute only login okay we'll see that first very carefully listen this I'm running the test you can take any test suit now I'm running my test suit Master suit look at here so account registration test is got executed and passed now login is executing which is got
90:55
Speaker A
failed which is got failed okay done so report is got generated so one is got passed one is got failed now in the next round I want to execute only login test so next round what I will do is I will fix the issue so
91:19
Speaker A
go to the properties file and I will fix the issue okay now I make the correct password then I want to execute only login test but I don't want to change this XML file so then how we can do it is
91:33
Speaker A
test is provided one important feature so whenever your execution is completed whatever tests are got failed those test will be captured into a separate XML file that is automatically happen we don't need to capture but where that XML file is present in the test Typhon output refresh this one
91:54
Speaker A
test Typhon output inside this inside the test tyen output expand this folder inside the test Typhon output you can see one XML file called test NG failed. XML test NG iph failed. XML if you open this XML file it is captured whichever tests are got failed
92:20
Speaker A
and also it include all the methods by default Okay so so this XML file contains only failure cases in the previous run in the previous run whatever failures are there will be captured into the XML now just execute this XML file no need to execute master. XML just execute
92:41
Speaker A
only this now the login will Ex only login will execute and it will pass just observe one more time okay now the log test is got passed okay now again close this XML file close Master suit again refes test. output refresh now can you guess tested XML file contains the entry or
93:08
Speaker A
not test engine. fail. XML contains entry or not previously the test is got failed so it is captured the entry but now this time it has got passed right still will it have the entry or not still the entry is there still the entry is present why because this entry will be here till
93:32
Speaker A
the next failure is happened so the next failure some of test cases got failed right in that time this will be replaced with the new test till that time this entry will not be deleted even though it is got passed okay that is a default behavior of XML file okay next time observe very
93:50
Speaker A
carefully so till the entry is still there now this time I will fail another test case so go to account registration test so I make the login is passed so in account registration test I'm trying to fail this one Accord registration test I'm going to fail just observe carefully so just
94:11
Speaker A
you need to observe the behavior okay that's the reason I'm running multiple times go to master. XML file normally okay so just go to mastered XML I'm running this uh I'm running both both the test cases again this time login will pass but account registration
94:27
Speaker A
test will fail but what is the entry we have in the fail. XML file login entry still there even it is passed in the previous run still entry is there but when that entry will be replaced with the new entry some other test cases got failed in future that will be replaced now when I execute
94:44
Speaker A
this so now you can just observe this is the account registration is successfully done but I given title is wrong so that is got failed so this is our login test so one test got passed you can see account registration is failed login is passed now go and refresh
95:05
Speaker A
the test Ty every time you need to refresh this right after refreshing just observe I'm opening test NG fail. XML see now the login test case entry is gone now in the recent run whichever is got failed that has got captured so if both the test got failed both the entries will be
95:26
Speaker A
captured both the entries will be captured so let me fail both the test cases then so go back to the properties file one more time and let us change the password so how many test cases have got failed all test cases will be captured now this time I'm failing the
95:42
Speaker A
both the test cases now just observe how it is going to work so again go to master. XML file so I'm running both previously how many entries are there in the test XML file fail.
95:56
Speaker A
XML file only one entry registration test so this time I'm failing both the test cases okay first test case is got failed now the second one is started this is also get failed perfect so now how many entries we should see so both the entries both the test case have got
96:28
Speaker A
failed both have the captured the screenshots you can see the group result graphes everything right so now we I look at here go to test tyon report refresh now how many entries you can see two entries go to the file. XML now you can see here this is account registration test this is
96:49
Speaker A
the login test okay so now I want to execute only failure test then what you need to do you can just correct the test cases go back make them correct I remove this one save and again go to properties
97:06
Speaker A
file everybody's understood the functionality how it exactly working if you want to run only failure test cases this is the procedure so after fixing the issues then again I'm running the only test.
97:18
Speaker A
failed failed. XML file so this will be very very useful feature guys so you don't need to run all the test cases every time only on the failures we can execute this whichever failures it will reduce lot of thing so you know to execute all the test cases multiple times so this time everything
97:38
Speaker A
is got passed now you tell me entries are still exist or entries will be removed in tester XML file entries will be there or entries will be gone after passing still they are exist Okay so so how much time they will exist till the next runs are failure so even though they are passed
98:00
Speaker A
still entries are exist suppose in the next time some other things are failure then these things will be replaced so this is a default uh working mechanism of this testan field. exml okay so with this we have finished ninth step clear so we'll stop here today's session till now we have almost
98:24
Speaker A
done 70% of the framework we have completed 70% of the framework we because these are all only onetime job grouping extern report adding and failure test case execution data driven test these are all onetime job so in the next sessions we will focus on the execution part and
98:43
Speaker A
maintenance part so also grid environment how we can run the test cases and remotely parall multiple environments so that also we'll see in the next class so till now whatever you completed so just practice them and finish everything and the next class Monday class you can demonstrate
99:02
Speaker A
your framework with your own words you can share your screen you can demonstrate what are the files you created how execution is happening all the nine steps so far whatever we have completed all the steps you have to explain yourself okay that is a plan for next class and
99:18
Speaker A
then we will proceed forther topics once you finish till here everyone should be finished once you finish then only I will proceed further stuff okay so I already shared the document once again I will share it all the files and everything you guys can take now you can
99:33
Speaker A
see all the reports will be captured and maintain the history also you can see all the screenshots are captured maintain the history everything is there in the framework everything we have done okay so that's it for today's session I'll stop here and we will continue in the next class
Topics:SeleniumJavaTestNGTest groupingHybrid frameworkExtent ReportsData-driven testingSetup and teardownTestNG XMLSDET

Frequently Asked Questions

How do you group tests in Selenium using TestNG?

You group tests by adding the groups annotation to your test methods and specifying group names. Then, you configure these groups in the TestNG XML file to run selected groups of tests.

Why should setup and teardown methods be part of groups?

Setup and teardown methods need to be grouped to ensure they execute correctly before and after the grouped tests. Without grouping, these methods may not run when executing specific test groups.

What is the purpose of the master group in test grouping?

The master group includes all test cases and is used to run the entire test suite at once, making it convenient to execute all tests without specifying individual groups.

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 →