Transcript for:
Selenium and Maven BDD Framework Guide

hi all welcome back so this is going to be a comprehensive course regarding selenium Java Maven cucumba setup and test with web driver manager and Al reporting so we'll be using bdd framework and in the end we'll be able to generate a beautiful report so the programming language that we'll be using is Java the automation test tool we'll be using is selenium the automation test framework that we'll be using is a bdd cucumba we'll be using a driver manager we do not require to install specific drivers the web driver manager itself will make will take care the latest uh driver which syns up with the we browser we'll be using mavan as a build tool for Java all reporting and we'll be using intellig as an integrated development environment so we'll be doing this comprehensive stepbystep approach the first step that we'll be doing is we will be installing intell in the local machine the Second Step that we'll be doing is we'll be verifying Java in local machine and if we if required we'll be installing it and setting up system variable and environment variable the third step that we'll be doing is verify Maven in local machine and if require install it step number four we'll be doing is create a maven project and cucumba plug-in step number five we'll install dependencies related to cucumba that is cucumba Java cucumba junit cucumba Co and make sure the versions are correct step number six is we'll be doing is selenium web driver dependency we'll be using the latest version which is version number four we'll be setting up web Drive manager for our pom.xml this will make sure our Chrome driver version is consistent with our Chrome version as such in Step number eight we'll be adding folder structure in the project step number 9 we'll be looking at the introduction to bdd framework step number 10 we'll be having a look at the application under test and the test that we have to code as well as design step number 11 we'll be looking at page object model concept we'll be adding the pages based on the page object model concept that is reusability scalability and maintainability framework we'll be looking at step number 12 adding pages to the project step number 13 will be adding step definitions step number 14 will be inv invoking web driver manager step number 15 is where we will start designing and coding our first test which will involve the test boxes as well as web elements step number 16 we'll be design and coding second test which will involve reusability of Step definition and Pages ass such step number 17 will be designing and coding third test which will be involving web table web element this requir specific web element locators and during all this process we'll be looking at using best practices as well as how to identify the elements in the Dom through the better element locator approach and step number 18 will be last we'll be looking at configuring the AL report in the bdd framework all reporting is a beautiful reporting as such so stay tuned and let's look at the step number one so for installation of intellig ID in the local machine what you need to do is you need to click on on Google and then look for an intellig Community Edition you can search this in your browser and then you can click on the download intellig the leading Java and cotlin ID once you click on the link the first link that you'll be able to see is intelligy idea ultimate but you do not require to have ultimate version what you need to have is a Community Edition which is free for you and and uh you can select as download Based on your uh requirement whether you need azip file or dotexe file but exe file is a better option you can click on download and this will get automatically downloaded in your default downloads folder now once this has got downloaded what you can do is you can go to your downloads folder and just double click on this exe file and once you double click click on the txe file in your downloads folder you'll be able to see something like this which is intell idea Community Edition setup you can click on next and what it will do is it will select a C drive which is a default folder in your um machine and it will try to get installed over there so this is the path you have to make a note of this path which is C drive program files jet brains intell idea Community Edition okay so the version which I have in my machine currently is 20223 point2 you can select whatever is related to your uh specific version it could be 2023 as well but it will same as what I have in my machine so I'll just click on next and then it will give a destination folder where exactly do you require to install it click on next next next and you'll be able to get a successful message that the installation has really happened in your machine now once the installation has happened in your machine you have got a successful message you can go into your search bar in your machine and then just search here as intell and you'll be able to see that the moment you type intellig in your search button you'll be able to see that something like this is getting opened up which is intellig idea Community Edition 2022 so you can double click on or single click on this particular window and something like this will open up which is welcome to idea and you can click on create a new project to start with which will be starting soon or you can customize and look at the pl plugins or click on learn just to learn about intellig but what I would suggest is we have to create a new project okay so this was my intention that you at least install intellig idea and something like this web this window should open up so that you understand okay intellig is really set up before creating the new project we have to make sure that our Java and M is really set up correctly in our local machine so those couple of steps we will be doing soon in the next section so we are done with step number one which is installation of intell IDE in local machine now the Second Step that we'll re really require to do is a prerequisite which is Step number two verify Java in local machine and if required we have to install it and then setting up the system and the environment variable now let's get that done for verifying whether the Java is really present in a local machine what we need to do is we need to search a command prompt in our machine so I'll just click on this search button over here and I'll just type over here as command prompt I'll just single click on this and something which like this will open up which is a command prompt now it will by default go to a path which is see users and then your user which is specifically in your machine now I'll enter a simple command which is Java hyphen hyphen version in this particular machine and press enter on my keyboard now what I have got here is Java 11.09 what it means is Java is really set up in this machine now it may happen that you might not have Java in your ma which might show that it's not able to understand the command of java if that is the case that you have to install Java in your machine and set up the system variables okay I'll explain that step as well now what we need to do is we need to search in a browser as Java and download and press enter on our keyboard and you'll be able to see that there are a couple of links over here one is Oracle link and another is directly a Java link you can go on either of the locations and get Java installed in your machine okay it really doesn't matter recently or previously what had happened is Java was acquired by Oracle that's the reason there are a couple of links over here now I'll just click on Oracle link which is Java downloads and the moment I do that you can see that this particular page opens up which is specific related to Java downloads now the Java latest version currently available in the market is Java 21 and Java 17 okay now these might be the stable um versions of java um but what I have done is I have selected something which is jdk 11 now I just scroll a little bit down and you can see that Java 8 version is also available and Java 11 version is also available now it depends on you what you really need to select now I have selected Java 11 for the purpose of stability Java 11 is quite stable and uh I'll just click on this Java 11 Tab and then there is an option of java 11.0.2 now depends on your OS which is operating system whether which operating system do you have in your local machine and then you can get it installed in your local machine now I have windows currently which I'm using in this particular video I'll just go to Windows Tab and then there is a 64 installer now I'll just click on this downloads and the moment I do that you can understand that this gets downloaded in the default downloads folder in my machine okay so make sure that where exactly is your default downloads folder generally it is under C drive into your local machine where it really gets downloaded now you can double click it or you can single click it so that it gets downloaded in your local machine as such now once you have downloaded your particular dotexe file you can double click on that particular txe file and you'll be able to see that some window will get um appeared and you can get it installed specifically in your machine just proceed with particular steps of installation of java and then you'll be able to very make sure that you understand where exactly the Java has got installed Now by default I'll just explain where exactly Java gets installed and I'll show in my machine as well I'll go to C drive and then I'll go to program files and I'll go to Java folder and over here I can see that there is a jdk hyphen 11 folder that has got created okay now once it has got created you can just verify what all folders you have so you have a bin folder you have a con folder you have a lip folder okay now I had already got this done as soon as my Java got installed and I clicked on thate file and my installation got completed now the reason I'm requesting you guys to verify that which particular path is for you in your machine it is important that we set up the environment variable in uh particular machine okay now this is the path exactly which is C drive program files Java jdk iPhone 11 bin now uh this exact path has to be entered in our system variables uh which we'll be doing right now so what I'll do is I'll search environment variables and the moment I search environment in this particular section you'll be able to see that there is an edit system variables control panel okay now I'll just click on it and something like this will open up as you can see there is a system properties and I'll click on and envirment variables and the moment I click on envirment variables this particular window opens up now this particular window is important for us so that our Java really gets recognized by our Windows File as such now Java is a product of Oracle and used to be earlier within Sun microsystem now Windows is a operating system which is different from Sun Micro Systems or Oracle as such that's the reason we have to set up this environment variable and system variables so that our machine recognizes Java particularly okay now the important area where the environment variable and the system variable has to set up is you can see that there is a path over here now you need to double click on it and you have to provide the exact path so you can see over here we had our Java got installed at C drive program files Java jdk Okay so exactly the path I have given over here you can see that c program files Java jdk hyphen 11 okay I have not given bin over here but I have just given jdk hyph 11 now this is the environment Vari variable I have set up and I'll just close it and I'll go to the system variables now with system variables I have set up a Java uncore home okay now I'll just click on this and as you can see I have set up a variable name which is Java unor home and C drive program files Java jdk hyphen 11 now we have to give the path where exactly is our bin folder okay that exact path has to be given now I have given in the system variable and I have provided the path under this uh which is environment variable as well and now I'm set up with my Java paths okay so system variable is also done environment variable is also done please note that if you are running Java first time in your machine this will not have been set up and that's the reason I'm giving this instructions to to the people who are trying this in their machine that you have to set up both this system variable as well as environment variable and then come back and run this command of java hyen version once you have set up this you have to come back to command prompt and run this particular command which is Java hyphen hyphen version and the moment you do that you can see that you are getting a response back as some kind of version that you have already set up okay so my PC contains Java 11.0.1 9 that's the reason it is showing over here as Java 11.01.19 now you might have installed Java 11.0.2 that will get appeared over okay so this is important in order to proceed for setting up our project as such all right now our step number two is also done which was a prerequisite now what we have to do is a prerequisite verify Maven whether it's really present in our local machine or not if it is not present what we have to do is we have to install it okay and then the setting of the system and the environment variable now this is very similar to our step number two but it is little different as well that's why I had to set it up that this is a prerequisite before we proceed now what we have to do similar to what we did in the step number two we will go to command prompt so I'll just Search Command Prompt here and something like this will open up as a command prompt now I have to enter a command over here which is mvn and hyphen version okay and press enter on my keyboard now the moment I press enter on my keyboard there are some details coming out okay so you can see that there is an Apache version Apache Maven already present which is 3.9.1 and there is a maven home setup okay now it's St trying to take some details from this particular uh area wherein it's taking it from C drive users Au downloads Apache M 3.9.1 bin and then Apache MAV 3.9.1 version and it's giving a Java version as well so it has already linked the mavan itself has linked with Java so we have done some settings of Mayan as well in our system and environment variable after the download that that's the reason it is showing okay the maven is already present but if it is not present and if it's showing that it's not able to recognize it's a mvn command what we have to do is we have to install mvn okay now there is nothing specifically called as installation of mvn what we really do is we have we generally download mvn in a particular location and then set up the system and environment variables now let's do that I'll just minimize this command prompt and then I'll just go to my browser and I'll just type here as MAV download and the moment I press that you can see that there is a link over here which is Apache mavan okay now MAV is an Apache product and I just click on download Apache MAV and you'll be able to come on this particular page which is Apache now you have to specifically download a particular version of apage now there are different links given over here which is apach Mayan 3.9.1 hyphen bin now you can go for zip file or you can go for. gz as well now what I have done is I have clicked on this particular um double clicked on this particular link and it has gone downloaded in a particular version or a particular link where default link of the download as such okay now it is important to understand where exactly this has got download now if I search over here in my downloads folder that is the Apachi you can see that there is a versions of uh different versions of Apache that I have specifically got downloaded and this has been present in my downloads folder okay that's the reason you could see that this particular when I had run mvn hyphen version it was picking up from particular Apache MAV that is downloads folder now once you have got downloaded this particular file you need to zip it or you have to unzip this files and you have to uh try to retrieve the location exact location of the Apache M and once you have understood where exactly is your Apache Mayan you have to search for environment again which we had done in this our step number two that is we try to search the edit system variables that is environment variables and this particular window opens up system properties now in this system properties there is a folder there is a button which is environment variables I'll just click on that and you'll be able to see that there are environment variables and the system variables okay now for the environment variables we have to set up a path I'll just double click on this uh path and you can see that I have specified a particular path over here which is percentage mcore home percentage back/ bin okay you need to specify this particular path exactly as it is appearing over here otherwise you will not be able to map the maven into your local machine okay similar to what we had done in our step number two setting up Java as well now this is the path once you have specified the this particular path in the environment variable you need need to specify the system variable okay so system variable uh what I have done is if I go to system variable Maven home okay I created this particular system variable specifically so I just clicked on new and I created a variable name that is mayore home and provided the variable value now uh I what I did is I provided the mavor home as a variable name and I provided the path exactly where the Apache mavan is present okay now you can see that this is the downloads folder which where exactly it had got downloaded so I'm not installing mavan everywhere okay similar uh in the step number two we had what we had done is we had specifically installed Java but here we are not installing mavan we are only mapping a maven to a particular system variable okay so once you have set up the mavor home and you have provided the path as you can see that the mayore home variable is exactly similar to what we had specified in the environment variable as well so if I go to path I had already specified mcore as a bin so that is the mapping that I'm doing in my environment variable and the system variable okay once you have set up this what you need to do is you need to go back to your command prompt and run your mvn hyphen version and what you'll be able to get is Apache mavan 3.9.1 that means your mavan is also set up in your machine so we are done with our step number two as well step number three as well which is verify Maven and then setting up the system environment so we installed intell EJ and then we have set up Java as well in our machine we have set up Maven also in our machine now let's proceed with step number four all right so once we have installed intellig in our machine and we have made made sure that Java as well as mavan is also installed in our machine what we can do is we can go to our search um in our machine and then we can just search as intellig and once we have opened up intellig it will look uh something like this like welcome to intellig idea and then because I have created different projects Al together uh I'm able to see projects over here but what you can do is if you don't have a project you can click on new project and what will happen is this whole new project will get opened up okay now this whole new project is our uh uh cucumber related project which we are going to set up totally new from scratch and uh it is important that we provide the name of uh our new project so in this case what I'll do is I'll just type here as selenium cucumber and then web driver manager as my project name okay so by default it is selecting uh a location in my PC that is it is it has already created a folder called idea projects over here and uh it will be the local location where exactly this project will get hosted okay so make sure that uh this particular selection is done if you are not happy with this location what you can do is you can kind of select on this folder and then you can specify where exactly do you really want this particular project to get uh saved okay after that you can select uh language over here as Java and the build system has Maven and uh the first time that you are trying to install your intell you will your intell might not um autod detect the jdk okay so jdk is a Java development kit and it is important that your Java development kit is really mapped to your intell okay so if you are not able to see a Java version over here what you can do is you can click on this uh drop- down and then you can click on this particular button which is ADD jdk which is add Java development kit so once you select this folder you'll be able to select where exactly is your Java present in your machine okay so because you had installed Java in your machine what you can do is you can select as program files and then try to look at the folder which is Java which might already been created in your machine and then you can click on that Java folder and under that folder you'll be able to see that there is a jdk which is Java development kit present in your machine okay so it is important that you select this jdk and click on okay and once you uh click on okay you'll be able to see that it is giving a 11 version over here or whatever version you have in your machine that will get selected over here and it gets kind of mapped okay now what we have to do is we will click on create once you click create what will happen is your whole project will get created so this is a brand new project that we have got uh created which is selenium cucumber web driver manager okay so this project contains a pal file so you might be able to see a palom file which is a project object model that's the whole meaning of it now you can add different dependencies now because we are going to create a framework which involves selenium as well as cucumber it is important that we understand what all dependencies we require to add so that our project is as whole is particularly mapped to these particular dependencies okay so we will get this done first but having said that we need to add a plugin okay so we need to add a cucumber plugin and in order to understand before we add any dependencies of cucumber uh over here in the pom.xml you need to understand whether cucumber plug-in is really present in our project or not now for that what you can do is you will be able to see a file button over here you can click on it and then you can click on settings and once settings opens up what you can do is you can click on this particular plug-in okay now once you click on this plug-in in this settings you'll be able to see different plugins which is present in our Marketplace and what I'll do is I'll just search here as cucumber as a uh bird over here and you can see that different cucumber plugins are present okay so there are different plugins which are cucumber for Scala cucumber for Java cucumber uh plus and then uh cucumber for groovy cotlin all those are present uh but what we are important uh what's important for us for this project is that we add uh couple of uh uh plugins over here which is cucumba plus as well as cucumba for Java okay okay so I have already done that if you have not done it what you can do is you'll be able to see something like this which is install okay so you can click on install and once you have installed what you can do is you'll be able to see uh checkbox already checked for you uh in the settings if you're not able to see this what I will suggest you to do is you can close this whole project after you have installed close this whole project and reopen the project Al together or reopen intell and just check whether this particular checkbox are really present for you or not okay so it is important step if you don't have kumbar plug-in into your intellig you will not be able to proceed with uh setting up cucumber specific projects in your intellig okay and just a disclaimer is this activity has to be done only once for your intell okay once this is done for your intelligence setup you need not do it for other projects in the future this is just onetime activity okay so make sure this checkbox are present and after you have made sure that these two checkbox are present what we can do is we can close the settings modal as such and then you can add dependencies okay so let's do that next all right so the next step is that we have to add the dependencies related to cucumber okay now cucumber uh dependencies have to be added and these dependencies are Maven dependencies okay because we are going ahead with Maven as our project management tool that's the reason we are going for Maven repository okay so now for that what we have to do is we have to search in Google and over here we can type as Maven repository in our um Google search and the first thing that you able to see over here is a maven repository okay so you can click on the first link which is Maven repository so Maven repository contains lot of repositories as such which are consisting of different dependencies and the dependency that we are interested in currently is cucumber so I'll just type here as cucumba Java okay I'll just type over here and the first thing that you are able to see is cucumba jvm Java now uh jvm stands for Java virtual machine okay which is um uh the particular dependency that we have to add now just click on Kumba jvm Java and the first thing that you'll be able to see over here once you click on the cucumba jvm Java is that there are different versions of cumba jvm java okay now uh you can see the latest ones are with the 7 point versions like 7.1 15x versions and that has got updated different with different dates alog together now the in the interest of stability what I will do is I'll select something in the versions of uh 6.1 okay uh now some of my viewers ask hey why did you go for this particular version now there is no specific reason that I have gone ahead with selecting as 6.11 version we can go ahead and select with uh particular version of 7 as well it really matters what you are really going to test now I now in the future right I'm going to explain what I'm going to test test as part of the application under test and I'm pretty happy with 6.1 version but if you're looking for versions above 7 okay some of the application doesn't work with versions of um lower versions but the application that I'm working on it is going to be six uh it is going to be stable for 6.11 version as well so I'll just go ahead and select a 6.1 version and then go and select this dependency so I'll just go here and select select this dependency copy it and come back to my project object model okay now this is a pal file uh over here by default there won't be any tags of dependencies please mind that it is very important now some of the viewers right they try try to tend to search hey where are my tags of dependencies so by default there won't be any tags of dependencies in your project object model but we will have to add that so I'm just adding that the first tag which appears over here is dependencies okay so I've added that tag and then I'm adding the um cucumber Java dependency over here as you can see now the moment I have pasted the cucumba Java dependency you can see that there is a uh M signal coming over here or a sign coming here which tries to give you an indication that you have to load your Java Maven changes okay we will load Java Maven changes but before that what I wanted to spef specifically see there are couple more dependencies that we have to add which is cucumber junit as well as cucumber core okay so what I'll do is I'll go back to my Maven repository and I'll search as cucumba Co and then press enter on my keyboard and then you can see that there is a cucumba jvm core okay so I'll just click on it and I'll select the version that I had specifically selected this is very important for for the viewers to understand that um the versions of cucumba core has to match with cucumba Java the uh earlier dependency that we had added okay so cucumba Java we had selected specifically this version 6.1.1 now I'll go back and select the Cucumber core okay so this is a cucumber core I'll just select this particular dependency in fact copy it come back to my project object model and then type or paste the C homebar core as well now the reason I'm saying that you have to have a matching dependency or matching version that is 6.1.1 the one which we have selected is you might encounter errors in while running these files of cucumber okay if you're running through a feature file or through Runner file you would find some mismatches if we don't select a particular version so it is very important that you match which version that you have specific Ally in your uh dependencies okay so once you have added cucumba Java as well as cucumba core the another another uh dependency that we have to add is cucumber junit okay so I'll select search here as cucumber junit and then press enter on my keyboard you'll be able to see that um uh there are junit Jupiter API all that is coming but what we are interested is cucumber jvm okay Java virtual machine junit 4 so I just select here and then come here down below and then select 6. 11. version okay so I'll just copy this and come back to my intellig and then press enter or paste the uh dependency over here which is cucumber J unit okay now this is good enough we have added three cucumber related dependencies and now what I will do is I'll just load the uh Maven changes so I'll just click over here as load Maven changes and the moment I do that there will be some indexing happening in this project okay so indexing as well as there there will be some pre-build shared indexes that will be happening in this particular project now it depends on how heavy is your project now we don't have any test as such or we don't have any feature files as such in our machine so it was pretty much quick that it did the dependency loading and uh we are good to go at at least from a perspective that our cucumber dependencies that we wanted have been added in our project so let's proceed in the next video to add the selenium dependency all right so now that we have installed or added the dependency specifically to cucumber now in this particular video what we will do is we will add the selenium dependency asset okay so similar to what we did in the Cucumber adding dependency we had select Ed cucumber in our M repository okay now over here uh we will search as selenium Java and then press enter on our keyboard now the first thing that you find over here is selenium Java okay so this is what we want specifically and then we'll click on it and you can see the latest selenium versions are of the version 4 and there are different versions alog together which is um down below as which are which had been started from selenium 1 or two in fact you can see back in 2011 it had been started and different versions selenium has undergone okay so more and more stability has uh happened on selenium versions as such um and selenium 4 is the latest one currently in the market and uh most of my viewers were asking hey can you come up with selenium 4 version specifically in your project because that's the latest version and you can try to avoid some set property dependency and all that which is which is I agree with them most of them that uh yeah selenium 4 is the latest version and uh that's what I'll proceed using in my project as well so I'll not go with the 4.18 which is the kind of latest version currently in the market but I'll go for something which is stable okay so which is 4 uh 17.0 okay so I'll just click on on that and then copy this particular dependency come back to my project and then add this dependency on my project okay now the moment I pasted as you can still notice again uh an M over here has come which is prompting me to load the M changes I just click on it and make sure my index is happening okay so that indexing once it's complete it's it has made sure our selenium also has got added in our project so that is done which is which was a small step that we had to add selenium in our project now we are good to go we are ready to proceed with adding web driver manager and I will explain why we we are really requiring web driver manager in our project so let's do that next all right now in this particular video what I'll try to explain is something about the selenium web driver manager okay now selim is an automation tool which has been using web driver concept okay so this is specific to selenium because we are using a driver in our machine okay so I'll just explain uh how it really works is I have opened up a Google Chrome in my machine okay now this Google Chrome version if I go on the version to understand if I click on this help of this go Google Chrome and if I click on um this version of Google Chrome that I'm using in my machine you can see that uh it is up to date okay now there is a version of 121.0 61 67.1 189 now what really happens as a tendency in our machines is this particular versions of Google Chrome will get Auto upgraded okay now with auto upgradation of Google Chrome what happens is this version will keep on changing okay it will go to 122 for example it will go to 123 for example and it is very difficult for uh us to maintain a driver associated with it okay so you can imagine that there are different Google Chrome drivers which are present in the market Okay Google comes with Google Chrome drivers now if you go and search in a Google uh Google Chrome drivers as such what you will be ending up to know is that there is a section of web driver for CH downloads so if you click on this and if you look at this versions okay so currently you can see that the Chrome version is one5 or New Year newer so it means that every time the Chrome gets upgraded or Google comes with a new versions of Google Chrome even the Chrome driver needs to upgrade it okay and if you happen to select this chrome driver manually install it in your your project every time and then you try to run it in your uh selenium project as such it is a very difficult process to maintain your Chrome driver uh along with your Google Chrome okay so you can imagine you have installed uh Google Chrome which is currently having a version of 121 in your machine and then if you go to this particular uh link which provides the latest version of uh Google Chrome driver as such which is is maybe it could be 121 okay tomorrow if it it gets upgraded that is a Google Chrome gets upgraded to 125 then you have to find again the Chrome driver version of 125 and make sure your project is synced up with that okay so this you can imagine it's a big headache and it's a big uh manual intervention of an automation tester but having said that there is a way to uh make sure your Google Chrome as well as Google Chrome driver is in sync at least from the version perspective and you need not manually install your Google Chrome driver in your uh project allog together okay so previously 6 months back I had uploaded a version of um uh project in YouTube as such and what I had specifically done is I had downloaded this Google Chrome driver in that project and I was using it but many of my viewers mentioned that uh you can go ahead with web driver manager which I agree with them this is a better method of course it's best method wherein you are able to use Google Chrome web driver web driver manager which make sure that you do not have to install specifically the Chrome driver in your project you can get away with using a web driver manager okay now the the whole story that I have told you about this is managed by a web driver manager and I'll just show you is about this particular uh Google Chrome so if you go here and search as a web driver manager so there is a de uh there is a person called Bonnie Gaga who has come with this particular version okay so if you click on the web driver manager this explains the whole concept how it is maintained by a web driver manager you need not specifically give install uh this particular um uh versions of Google Chrome okay so if I go back and select this particular dependency which is this dependency and if I add it in my project if I go back in my project and add this dependency and load my Maven changes okay so if I click on this load Maven changes you can see that it's downloading the dependency and my web driver manager has got added okay so this is as simple as that I am not going to install any web driver in my project it will autocalculate what is the version of my Google Chrome in this machine and based on that it will make sure the web driver is synced up with this okay so it hopefully it makes sense why we uh generally go for web driver manager and it is a latest one uh latest Trend as well to use web driver management so that you are not manually installing the driver in driver specific and in the future video we will make uh we will be able to see how we are not setting up any system property as such local path as such it will when we have to launch the browser itself it will autoc calculate your uh driver and then it will proceed with your test all right now in this particular video what we'll do is we'll create some folder structure in our uh project and for the folder structure what we'll be doing is I'll just come to this particular project which we have which is selenium cocumber web driver manager and inside this there is a source folder okay now within the source folder there are a couple of um folders over here which is main as well as test and under the test you will be able to see that there is a folder called as Java okay now our selenium test are actually supposed to be designed under test which is this particular uh folder as such but having said that it is better to structure it in a proper designed fashion so that we will be able to make our project more readable to anybody who really looks into our project as such okay so under the Java folder what we'll do is we'll start creating folders so what I will do I'll right click and select as new and then select as package and uh a new package uh is being prompted over here so what I'll do is I'll add features okay so because we are designing um bdd framework which is behavior driven framework as such that's why we will have to store features which is um uh features folder as such the next folder that we will create is if I right click on new and then select as package I'll create as pages so we will Design this as per our page object model concept which is a particular design concept of test Automation and apart from this I'll create cre one more folder so I'll just right click select as new and then select as package and over here I'll enter is a runner okay so we'll create a runner file as well which will run our scripts sequential fashion one more folder that we will create is I'll right click and select as new and then click on uh package and this time we will create this as step definition so I'll enter ST definition and then press enter on my keyboard that creates one more folder which is Step definition and apart from that I'll just right click and create one more folder which is package and then I'll add this as utility folder so in all in all we have got five folders which will structure properly in our framework as such so first is features then is Pages then is Runner then is Def step definition and then is utility folder as such all right so once we start designing or write our scripts what what is important factor is to understand what all these folders um uh important as such and one on one I'll just explain what are these features Pages Runner St definition utility folder as such when we design our scripts as such so let's proceed all right now I just wanted to give a quick introduction to what's a bdd framework now bdd framework that is behavior driven development approach allows the testers and The Business analyst to create test cases in simple test language generally English and behavior driven development is a agile software development methodology in which an application is documented and designed around the behaviors a user expects to experience when interacting with it bdd also offers the ability to enlarge the pool of input and feedback to include business stakeholders and end users who may have little to software development knowledge due to this expanded feedback loop development teams May more readily use bdd in continuous integration and continuous delivery environments now there is a given when then formula it's a template intended to guide the writing of acceptance test for a user story given some context when some action is carried out then a particular set of observables consequences should obtain now tools such as cucumber encourage using of this template though it it can also be purely as htic irrespective of any tool all right now that we have created the folders in our uh project all together which is features Pages Runner step definition and utility and apart from that we have understood what is a bdd framework and how the bdd framework is supposed to be designed in a given when then format we have to add some feature files in this folder which is features okay so we had created a folder called a features but we need to add those features over here okay now before starting the features alog together we need to understand what we are automating what is our uh application under test and what are the features which have to be added in this folder okay so for demonstration purpose what we have done is we have uploaded a application under test and this application under test is a live demo uh application which is a online Sho portal it's a it's a dummy or a demo project alog together or a web application as such just for practice purposes and as you can see this is the homepage of the application under test which once it has to it has been launched you will be able to see that this particular is a landing page okay which is the homepage altogether and you have to make a note of this particular URL which is is given over here okay now once once you hit this particular URL you'll be able to see this is the homepage but once the user clicks on this particular hamburger menu so there is a hamburger menu on this homepage and if you click on this hamburger menu this particular left widget opens up okay now this left widget has different links Al together and the links that we have as part of our test criteria is couple of links one is signin portal and another is online products okay so if you click on signin portal what really happens is you land on this particular sign-in page okay now this sign-in page consist of different web Elements which are username text as well as password text okay now these are couple of test boxes over here and there are couple of buttons over here and what happens is if the user is able to type something as an username and password and click on login you'll be able to see that the user has logged in into this particular product category page okay now there there are three categories over here one is a formal shoes second is the sports and third is the sneakers now this is what happens if the um user clicks on the uh login buttton as such now if the user is new what the user might be able to do is user might be able to click on new user question mark register here okay now this button if clicked the user will be able to land on user registration page and as you can see there are different um text Fields over here as well as uh there is a drop down over here which is Mr salutation and Mr mrss and uh Miss salutation and then on the bottom there there is a submit button altoe okay so our web application uh application under test is this one so we have uh three tests that we will try to automate in this particular whole video uh what the user will be able to also do is they will be able to click on the hamburger menu and once the hamburger menu opens up they'll be able to click on the online products okay once they rear on the online products as you can see there are three categories over here which is formal shoes sport shoes and sneakers okay now if the user is clicking on this drop- down button which is right under formal shoes you can see that there is a web table which the user is shown and the web table has different shoe names shoe color available size and all those kind of details so we will add add one more test that the user is able to navigate to this particular product category page or online products page and they are able to view this particular shoe name which is the first shoe name which is classic chanam okay this is a kind of a brand shoe which is available in ASL online products as such so we'll put uh this validation as well all right so just to reiterate there are three tests that um we require to conduct one is the user is clicking on the hamburger menu and once they click on hamburger menu they are clicking on the sign-in portal and once they click on the signin portal they enter the username and password and they click on login page these three categories or product category page is coming at least from a perspective that the user is able to navigate this is the first test the second test that the uh user does is they click on hamburger menu they click on signin portal they click on this particular button which is new user register here and they are able to see all this uh values and once uh that is uh they are able to see all these text Fields that's the second test apart from that the third test is that the user is able to click on the hamburger menu and click on online products once they click on online products there is formal shoes sport shoes sneakers and they they once they click on the drop down right of right below the formal shoes you can see that there is a classic chelum as the first shoe name that appears so these are the three test cases that we have to automate in our selenium automation bdd framework as such all right now that we have understood what all test we have to automate in our application and how our application looks like it is important that we structure these test cases into features okay in given then then format which we already had a look so let's create some features under uh this particular folder which is features okay so what we do is we right click and then select as new and we don't have specific feature file type as such but what you can do is you can create a feature file by clicking on this file okay now once you click on this file you'll it will ask for new file all together and then what I can do is I can type here as log in. feature and then press enter on my machine now as soon as I press enter on my machine you might have noticed one thing that logged in. feature. created and there is a symbol of a cucumber okay so what it means is there is it F this file is a cucumba file and that's how it gets identified and after that what we can do is we can write the given when then format over here so before we write a given when then format what we need to do is we need to provide the feature name as such so I'll just type here as feature and I'll just provide here details about what this feature does so what I'll do is logged in user view this is a feature name and after this I can write scenario and the moment I type scenario you can see that there is an intelligence with in intellig is giving me and then I can type here validate user is able to view after login so this is a scenario and then I'll provide the given when statements all right now I'll provide the details like uh what's the user I'll provide the given statement all right so our given statement is user navigates to the login page and when statement when user successfully enters the login details when user and then then statement user should be able to view the product category page all right now this is the logged in feature now we'll create one more feature which is our second test so I'll just right click over on top of new and then click on file I'll type it here as new user registration. feature press enter all right so I have pasted here the feature file okay which is uh new user registration View and validate new user is able to view after clicking on new registration and I'll just pass on the third feature I'll just right click over on top of new and then file as click on file and then so this is General General user view so what will happen is uh that without login or new registration two we can validate this all right so I have added three feature files here so the first one is the logged in. feature okay so the first test we test case we were looking at is valid the user is able to view after login okay uh user navigates to the login page user is successfully enters the login details and then user should be able to view the product category page now the second one is a new user registration. feature which is validate new user is able to view after clicking on the new registration and we have a given when then statement now if you notice one thing right uh this particular statement of given is exactly equal to the this particular given statement so we are kind of doing a reusability over here some of the statements will be reusable and that's the idea about this framework as well that's how we should be designing it and the the third test case is a general view user view okay now the general we use user view is that validate General user so we are not logging in without the logging in we are navigating to the online products page and then clicking on the formal shoes drop down and user is able to view the products now we will refine this third test case don't worry uh our test was supposed to be that the first shoes that we uh viewing is should be the classic chelam formal shoes okay it's a brand classic chelam we are supposed to have it as a validation in our test case but when we will write the test case we will make sure that we are catering to that as well okay so that's the whole idea we have created the feature files and in the next thing we what we will be doing is we will create the pages okay so the next thing which we will create is the pages and step definition as well so step uh Pages has to be created in a format of the page object model concept and that is the framework that we have to design page object model which is a most widely used test automation framework and it is uh good in reusability maintainability and scalability as well from from our automation perspective so let's do that all right now I wanted to touch base of concept related to page object model as well now before we start creating pages I just wanted to give a quick understanding about that now page object model is a approach to script maintenance and uh it is to create separate class file which would find elements fill them or verify them this class can be reused in all the scripts using that element in future if there are changes to the web elements we need to make changes in just one class file and not 10 different scripts this approach is called as page object model which is pal a pal which is little different from Maven pal as such this is Page object and that is Project object totally different terminologies but this page object model concept this helps in code making code more readable maintainable and reusable in the future as such I'll give a classic example now before starting with page object model you have to understand how many pages am I my team need needs to automate for our uh application under test now better to plan it early if you already know and the example is the example which we were looking at which is a online shoe portal now there is a homepage uh and the homepage consists of hamburger menu as well as signin portal now the SEC signin page is little different now signin page contains username password login button new register as such and the registration page consist of different objects which are salutation given name last name contact number email address username password submit now how do we really Define is homepage make let's make homepage as a different class signin page page as a different class registration page as a different class okay three different pages three different classes now how we will treat is um homepage will have hamburger menu and signin portal couple of objects over there and we will make this treat this as objects okay now signin page has uh four different um objects wherein username password login button new register we will make this as objects and registration page has different uh parameters okay different uh objects as such so we will treat this as a different objects of different classes and this will definitely help us during reusability homepage because we made this as um hamburger menu as and signin portal as different objects we will perform click on hamburger menu okay so that's the operation that we are performing on the object signin portal we are going to perform a click on that as a operation on the signin portal in the signin page because it's a different class altoe username we will use as a send Keys okay something which we are entering into a text box we will perform a send Keys operation password again a send keys because that's going to be a text box login button will be a click because we have it's a button that's why we have to click on that new register will perform a click on that so this what this is what is concept of the page object model which we will be implementing in our project as such all right now that we have understood what's a page object model and what our tests are now it is important that we segregate different pages of what we have to design in our test automation framework so I am on the homepage okay so this is an homepage now we will create a homepage page um uh as a class and then we'll click on signin portal so this particular sign-in portal page is uh kind of a login page right and we will Design this as a login page and apart from that uh there is a new user registration page right so this particular page we will Define as a third page and the fourth page that we are interested is the online products page okay so this page particularly we will have to separate it out as a different class Al together so in this process what I will do is I'll create four class files okay and uh those four class files will be added in this particular page so let's do that one by one so I'll just right click on the page and then uh I will select as a Java class and I'll name this as a homepage and the other Pages as well so I'll create a class now this will be login page the third one will be registration page and the fourth one will be online products page all right so these are the four uh pages that we have inserted or we have created now we will Design them one by one based on what all elements or web elements are there on this page okay now in order to capture the elements on this particular web page what is important for us to understand is what is the element properties okay so web element properties like for example you are on a homepage okay now this is how the homepage looks like and the first action that you have to perform is you have to click on this hamburger menu now you will not be able to click on this hamburger menu if you don't know what is the element properties of this particular hamburger menu now there is a very easy method to find out what is the web element of this particular uh hamburger menu and this is a very easy method that we can really find out through uh and if you're using Google Chrome uh what you can do is you can click on this three dots over here and then you can navigate to more tools okay and after you navigate to more tools you can go to developer tools now there is a shortcut as well which is provided by Google Chrome which is control shift I now uh I'm just giving a disclaimer over here now in this particular example we are using Google Chrome as our browser as a standard browser but having said that if you have Firefox there is another way to identify very similar to this one or you can use some other easier methods to automate different browsers like for Safari browser you can identify in the similar fashion okay but I'm giving an example of the Google Chrome you know to identify your web element properties so I'm clicking on this developer tools and the moment I do that you can see that the code at least the HTML code is present on uh your left widget or sorry right widget wherein you will be able to to get the element properties okay now uh most of my viewers uh they have been asking okay what I have been telling them is directly capture the xath as a web element property and I am uh correcting myself now there are different ways or different mechanisms that you can extract the web element properties and like for example if i h on top of this if I click on this particular uh section which is inspect element what I can do is I can hover on top of this web elements okay so this is uh Jumbotron which is a web element now uh if you over on top of this there's an input which is um uh hamburger menu which is a checkbox now you can click on it okay and there is an input type which is a checkbox which is the web element property which is um we we are able to identify now apart from this what you can do once you have identified the web element right you can extract the uh web element properties of this okay now one thing you can do is uh element locators in selenium are by ID by expath by CSS selector by link text by partial text link text and by tag name okay so by class by name as well now you might be uh able to understand that uh we because we have different element locators it is very evident that uh it is you are supposed to get the unique property of your web element if you not getting the unique property of your web element what you might end up is choosing a wrong web element on the page okay so it is important that you get the right web element which you are supposed to click perform an operation on now for example when and most of my viewers or or whoever have been speaking to they mention okay just choose by ID now this is an example a classic example where ID won't work for you okay by ID won't work for you because if you over on top of this this is what you get right if you choose ID menu toggle the whole section that is from here to here it is getting highlighted so it means that you cannot select ID you will have to select an xath in this case or an input type okay so if you can right click and then you go to copy you will be getting some options over here which is copy xath by copy full xath copy selector which is CSS selector of course and uh you can identify this web elements now having said that what I will do do is I will use xath now if I go and copy xath and I come here and just paste it over here in my homepage you are able to see that I'm able to get the xath okay now there are in XPath there are different V variations of expath there is relative expath there is absolute expath and it is very important question in the interview generally when do you tend to get x uh absolute xath and what when do you when do you tend to get uh relative X paath now it is important to get an act relative X paath rather than your absolute X path because it might be very static uh element properties so we don't want our uh element properties to be static we want element proper properties to be dynamic because it might happen that your uh properties might change all the way so as a reason it is important that you select a x paath alog together okay now on the homepage what we will do is we will try to detect um and capture the web elements like hamburger menu is one of them then we will select signin portal as well as online products okay because this is also part of our homepage now let's do that and let's add these element properties all right so we have declared the hamburger menu exper okay and now we will declare the signin path link xath as such so we'll add that all right so we have declared the signin portal link but uh what I'll do is I'll use the inspect element and then over on top of signin portal okay so this seems to be a sign in Portal link so I'll just right click and then copy then copy xath and come back here and then paste my xath over here all right now this is one mechanism to get a our signin link as such but having said that you can also look for another way to pull the element properties so what you can do is you can use uh by text as well so I'll just copy this one copy element and I'll select as signin portal as our text all right which is link test all right so once that is done we will add uh methods all right so I pasted the methods like the operation that we will perform on our methods now click is a hamburger menu and then we will add all right so once that is fixed you can see that buy is one of the um we'll have to import this particular class which is uh coming from selenium Library s such and Driver okay now we will have to declare driver because what we need to do is we need to open up the driver as such and then we need to perform the operations on this this all right now let's do one thing let's uh create some step definitions okay we will create some steps now when we had this introduction to bdd approach we did talk about what are features and feature files as such so feature files will be in the given when then format but having said that it is important that these given when then statements are actually synced up with your step definitions okay now if it is not synced up with your step definition when you run the test it will not Run Okay so that is the meaning of it now let's do one thing let's over on top of user navigates to login page and you can see that there is a create step definition a kind of an intelligence that is being given by the intellig itself so let me click on it and let me show you what's really happening now it is giving an indication create new Step definition file okay so it is giving us an indication okay um you can create it under Source main resources okay so what it where it will exactly go is if you create your St defination it will undergo uh go under this particular folder which is resources okay which we can do it it's not a problem but having said that it will be impacting our readability okay so if someone is reading through our code and if you happen to place your step definitions under resources folder and uh that person cannot um correlate kind of thing okay so it is important that it is we have to maintain kind of readability as well so you can place it in the resources folder not a problem but having said that uh I have already created a package or a folder over here it's better to map these step definition so that it is easy to read as well for whoever is reading the code okay so what I will do is I'll close this okay and I'll create a step definition over here and I'll just right click and I'll select as new and then select as Java class and over here I will add as homepage okay we what we are going to do is we are going to create some uh methods over here related to homepage okay now for this relation what we have to do is in order to map the feature files as well as the step definition it is important that we map these uh through a glue mechanism okay and this is very important because most of the viewers they get confused or it is important or it becomes difficult them to correlate where exactly is your step definition and where exactly is your feature files okay so it is important to understand that you are supposed to create a glue file under Runner file okay and that's what we will do this time what we will do is we will create one Java file under Runner file so we will overover on top of Runner and then right click and then select us new and then add a Java class and over here we will add test Runner and then press enter on our keyboard now uh we have added this test Runner file now one thing which uh um some of my viewers previously were mentioning they were getting an error called as uh annotations are not allowed here okay now what will happen is if you are using test Runner file okay and if you are using test Runner class better to put your at the rate an annotation of uh cucumber options outside of this class and not inside of this class okay now what will happen is that tell you now if you create a cucumber options inside this class it's not a problem but it will import the file from the Cucumber J unit and after that if you over on top of this you will get an error called as um annotations are not allowed okay all right so until this now you might have noticed that we have not used anything specific to driver okay so this is the first time that we have used driver in our code and in our method as well and this driver is related to our selenium web driver okay so selenium web driver what it will do is it will try to find the web element within our web application so we have captured the element locator through xath mechanism for the hamburger menu and after we have found this x path of this particular hamburger menu that is uh element look through element locator we have been trying to perform a click operation on that okay so once we perform the click operation we will we will be able to proceed with our test but having said that click is a mechanism through which we are trying to find this element first okay and to find the element we require a driver and the driver is given by selenium web driver okay now is the point where exactly are we uh using this driver and how we are using the driver okay so you might have noticed when we are installing the dependencies of uh Chrome driver or web driver you might have noticed that we have added a dependency over here which is web driver manager okay and apart from that we have added selenium Java as well in our dependencies in this particular project Okay so until now we have not used it in our project that is selenium and web driver we just added the dependencies but now is the time to use that driver okay so the first thing that we have to do is we have to launch the driver okay as in launch the application itself so for that what we'll be doing is we will add here as a web driver manager when I type here as a web driver you might have noticed that uh web driver is automatically coming but web driver is not what we want specifically what we want is web driver manager okay and then we type as Dot and then Chrome driver and after that we enter the method called a setup okay now there is an error here web driver manager now what it is showing is all right I need to check the spelling first and when I'm pressing web driver manager you can see that it's picking up from the library of uh Bonnie garia okay so this is what we want and that's what we have added specifically in our pom.xml okay so now this is important that is we have called the web driver manager and we are setting up the Chrome driver. setup and apart from that we have to declare a driver so driver equal to new Chrome driver and then I'll just send the statement here now apart from that we have to declare driver okay so before using it we have to declare the driver so what will do is a public static web driver and then driver SS so we are using a driver over here as a public static web driver and what we'll do is we will use this web driver down below in order to set up the Chrome driver and then we will launch this uh application all together so what are do is I'll add here driver. getet and then in the double quotes we will have to pass the application under test the URL itself okay so I'll just paste it over here the URL that we want to launch and then I'll end the statement so our error is gone okay so driver specific error is gone and please notice that we have not installed any Chrome driver specifically in this particular project okay which is a good thing now this is this is how it will remain even if our Google Chrome get upgraded to 122 or 132 or 142 in the future we don't have to worry that the Chrome driver also needs to get updated okay because it will automatically get updated via this web driver manager so what we are doing here is before we are clicking on the hamburger menu we are performing the launching of our application okay so that is what we are doing here now if you have noticed okay so what we have done here is we have just entered a page object model concept right now we have uh entered couple of web elements over here and then we are performing the operations on that right now what is missing here is a step definition right so step definition is something that like even if I try to run this I cannot run this right because our starting point is somewhere like user navigates to the login page okay and the user will be able to navigate to the login page once they launch the browser as well as they are clicking on the hamburger menu and clicking on the signin portal as such okay uh so that is what we will do we will try to create some step definitions but hopefully you got an idea about this chrome driver management and if you notice all our test will try to call this particular Chrome driver setup right the Chrome driver itself so we will try to move this as in refactor our code we will try to remove these three lines of code later on in our project but for the starting purposes at least we can proceed with keeping this at this this um method right now and then we can proceed to at least um launch the browser and then validate our test test case as such so let's do that in the next step that's why we have to um we have to move this at the rate cumar options outside of test Runner and then paste it over here okay so there won't be any annotations problems once we move this cumar options out of the test Rano file all right now what we'll do is we'll open bracket and uh in this we have to pass some parameters okay so we will pass a features as one of the parameters and the double codes and then e comma after that we have to pass glue path okay so this is the glue path which I was mentioning about and I'll pass um some parameters over here as as well and this will be passed as a curly curly bracket parameters okay and then I'll pass on some plugin as well and plug-in also I'll just pass it in the curly bracket parameters okay now as you can see that we are passing three parameters over here one is features second is glue and third is plug-in now the features we will have to pass on the exact path where our features are okay so we will have to start with the source and the source is over here here and then we have to pass it as test and then Java and within Java there is features okay so we'll pass that parameters details over here so Source test Java and then features okay so this is the path of the features and then there is a glue right in the glue we will have to provide couple of parameters again which is utility so we will provide something in the utility but having said that we haven't added anything in utility that's fine but we will have to pass the details of Step definition okay so we will provide the details of Step definition and uh this step definition is where exactly we we have provided these details okay so I'll just correct this um in fact refactor and rename it to definition okay so I'll just refactor and our glue paath is set okay now apart from is I'll Pro provide a plug-in okay so the plugin that we will provide is uh pretty so I'll just provide this as pretty as a parameter and then I'll pass um HTML because what we'll try to do is we will try to generate an HTML report as such so I'll just pass HTML Target cucumba HTML report and then comma Json cucumber Json okay so this whole uh path we have provided now the reason I have provided this plugin as well is this is related to reporting okay so a cumber HTML report will get generated don't worry we will be looking at from a perspective as well but this is a standard default cucumber HTML report that it will generate okay now we are not concentrating on the reporting yet but we will touch base to uh reporting once we complete our whole test as such we have not built the test but this is kind of a design to start with okay now we have provided the features we have provided the glue path now what we have to do is we have to come back to step definitions okay and over here we have to provide the details in the homepage okay so the homepage uh details that we will have to provide is the given statement okay so if you go back into this the first test that we have for the logged in feature what I will do is I'll come to homepage and I'll add an annotation over here at the given okay now this at theate given has been pulled from a particular Library which is IO cumar Java and given okay now uh it is important you make a note of this which is the exact library from where it has been taken across now apart from that what we have to do is we have to pass the details of um this whole given statement okay we have to pass this as a parameter over on top of this you'll be able to see an error annotations are not allowed here okay so what it means is that this is not an annotation that you can really rely upon so you have to make this as a method okay so I'll make this as a method public void user uncore navigates uncore to the login uncore page all right now what I did if you notice what I really did was uh I have used uh the exact statements okay user unor nav so user undor navigates to the login page so I've used exactly the statement that I have given for the given statement and the moment I did that you can see that there is a kind a two number appearing over here okay so if I over on top of this you can see used by two scenarios so what we have done is we have first of all mapped our given statement to the feature uh step as such and once we come to the feature step you can see that the error is gone okay so it means that we our step definition has been defined okay so it has mapped with our step definition over here all right now what we can do here is we can add the methods we were supposed to add it for the homepage okay so there were a couple of methods we added here which is Click hamburger menu as well as click signin link okay so let let us get this added inside of a step definition so if you go back to step definition of homepage and then you add this couple of um lines over here now it's trying to understand where exactly is Click uncore hamburger menu okay so we will have to do import static so what I will do is import static Pages dot homepage dot star and ending with the semicolon now again there is some error now I will over on top of this and add exception Cho the signature and then this error is gone all right now our small test has been set up now what we will do is we will go to this test and we will not run the when and then okay and there is a way to uh commment this out so if I press um Ash over here at line number six and line number seven you can see that this has been commented out so what it means is our only given statement will will run okay now we are running the first test now the first test what it will do is it will come to homepage okay and from homepage type definition it will go to the pages all right and from Pages it will go to uh this uh open up uh Chrome driver and over chrome driver it will open up the application and from there it will click on the hamburger menu and then supposedly supposed to click on the sign-in page so let's see let's head on to logged in page and logged in. feature file and then click on run test and then I'll just click on run scenario and now web driver manager is running and we can see that we have face this error okay so what is the error is uh if you look closely uh the error is step is undefined you can implement this step using snippet which is kind of a snippet given below at the rate given uh that this user navigates to the login page and the method as such but surprisingly we have already provided this in our method isn't it like we have already defined the step definition so what where did we go wrong so let's understand this how to fix it okay so when you encounter that error first uh what we have to do is uh you will you can come to logged in. feature file okay and over here you can see that uh there is a strike uh through which has happened on the given statement so what it means is like um this particular St step has failed now what you can do is you can just over on top of this given statement okay and you can click on clear result so what it will do is there will be result present in the cachy which will get cleared okay and if you make any changes then it will accept that okay so that's the reason you are clearing the result and after that what you need to do is you can come here in the right hand section okay over here you can see Maven okay just click on that and once you come into the Maven do one thing uh come to plugins and then you can see that there is a command of clean compiler deploy install uh jar uh resources sites Sure Fire and you can click on this spe uh you can come to install section and then you can click on the executive Maven goal okay and once you click on that you can see that there are some commands that is coming okay so mvn test is coming mvn clean is coming mvn compile is coming most of the mvn commands are coming okay which are Maven commands now what we will do is we will do M and clean okay so that's one of command which is performs the mbn clean and then you can see the build is Success okay so it has done the build now I'll go here and then click on install and then go to this particular Maven and then I'll click on Maven test okay so what what I did is I went I did Maven clean and then I did m given test as such now what it is doing is it's doing its own stuff okay like as in it did um install the plugins as such or the maven resources as such and there is no error there's a build success so test run was zero and failure was Zero okay so it did the clearance of that as well now let's do one thing now let's go to logged in. feature okay and then try to run this again so the build is happening and and and now I can see that the browser has opened up okay it has clicked on the hamburger menu and it has probably failed okay so let me close this and let me have a look at what is a failure so at least one good thing is we have gone beyond our failure that is it was not able to identify the test step but at least we know that our launching of the browser is happening okay and one good win over here is that the driver as well as the Chrome has matched okay so we have not installed driver please mind we are using the Chrome driver web driver okay uh and web driver manager and uh what we are doing is we are running the test and then it has opened up the browser and it has performed the click operation on the hamburger menu and then it has failed so it has failed at the step of the string signin portal is not valid Expo uh expression okay so what it means is we might have to go to the homepage and I'll just close this Maven window asage and over here we had provided this by expath okay so we might have to change this and maybe this was my mistake so I have to provide this as link text and then rerun again so I'll go to login and then click here and then run so once the browser opens up um and it has not clicked clicked on it has clicked on the hamburger menu but it has not clicked on the signin portal okay so it has failed with the same at the same step it's not a valid expath expression okay so now I will just mention that you will have to clear this result okay and then perform a build or probably go for a build rebuild now rebuild what it does is it clears a cache from idea intellig so I'm just doing a rebuild and after the rebuild is successful I'll just reun this browser has opened it has clicked on hamburger menu it has clicked on signin portal okay so what I did is if you have closely noticed what I have done is I had already fixed the link test okay so I had changed it by exper to link text in my step definition or in the pages okay but I had not cleared the cache so if I come here if I do the clear results and if I do the build and then rebuild okay even if I don't do build but I go for a rebuild what it does is it clears the cache and then you are success next run will be successful okay so it kind of clears the cache whatever results are present in your your intellig itself or the id id id itself it will clear that and then you can try to run it and then it will run okay and you can see that at one scenario one test step has passed okay so that is a good thing at least one test step has passed now what we were supposed to get is user navigates to login page so we were able to navigate to this login page and that is our success okay so that is at least a small win but slowly gradually we will incrementally do all the validations and one good thing is by writing this particular test step that is user navigates to login page if you go to new registration. feature okay it has the same step which is user navigate to login page so what we are doing kind of a reusability over here we are uh calling the same functions that is Click hamburger menu click signin link and let's try that out so I'll go to new re user registration and I'll just click here as a run and then I'll just check whether at least my test is running from new registration or the second test as well so browser has opened up it has clicked on hamburger menu and uh it has stopped at the this particular user clicks on registration button okay so we had not set this or designed this yet coded this yet but we will do this subsequently I wanted to just show the first part at least is working for the second test okay now please note when your browser will open up Okay Google Chrome browser will open up through an automated software just like selenium or play right or cucumber or Cyprus for example it will give a navigation like this chrome is being controlled by autom S test software so it's kind of an indication that the selenium has opened up this browser not it has not been manually um opened up as such okay so that is a it's kind of a um indication to an automation tester this is being controlled by the selenium automation tool or any other automated test software as such so at least our test step is working now let's design the first test case let's capture more xarts or more test boxes as such and then based on that let's complete our first test uh in the uh coming section all right now in this particular section let's try to complete our first test okay we had actually commented a couple of uh statements over here which is when and then statement so let's remove this uh comments so that we design this particular section about when and then as well okay now uh given statement has been already designed we have created the step definition for that now when statement is user successfully enters the login details okay so let's do one thing inside the step definition we let's add the login page as well okay so what I will do is I'll just right click here as a homepage and then paste it in the homepage as a login page okay so what we are doing here is segregation of of Step definition with the with the different pages Al together okay now if I come here in the login page now let me copy this into user successfully enters the login details and come here in the login page and then replace this given statement okay and let me replace this with a when statement okay so you can understand what I'm uh implicating so if uh I have converted this step definition and created a step definition specifically for when statement right and then you have to change the method name as well so void user successfully so I'll just change this to successfully enters the login details so log inore details okay so I have changed this and you can see that there is one particular uh used by scenario okay so if I go back in logged in you can see that my step definition of um user successfully enters a login details is captured okay so my step definition is ready now what I have to do is I have to go into login page and I have to create this uh page specifically for login page okay now I'll just go to homepage okay I'll copy this particular statement or the code I'll come back to login page and then keep on modifying this we do not require and change this whole thing like uh on the login page Okay so if I look at my application there is uh username and password so what I'll do is I'll try to capture the element locators for this one so I'll go to developer tools all right I'll do an inspection then go to username and then uh you can see that there is an ID over here okay so in this case uh this this particular text uh or the user name text field itself has a ID now user okay now if I go and check this is a unique property I will not be able to find any other element which is having this particular ID equal to user now how will I be able to check what I can do is I can just go to this Element Section okay so I'll just expand this so that is easily viewable I'll just do contrl F here okay so contrl F when I do ID so when I do ID you can see that there are some IDs over here in fact um there are 12 combinations okay so if I go here I can see that there are IDs and this is ID which we had captured as a hamburger menu now this uh if I click it again you can see ID equal to menu and after that I go here there is an ID which is a title which is a shoe portal title and if I come down below you can see that there is a ID equal to image as well so image itself has an ID okay and second form and now we are in the ID equal to user now let me enter this particular particular element locator here this is ID equal to user now I have entered over here as user USR and then you can see that there are two USS which is ID is unique okay so uh there are only two USR and that USR is coming as ID and this whole text is coming as U located over here okay so that's a unique property so let's go back and then let's Design This for text Fields so I I will just over on top of this which is ID user okay and then I'll just right click and then copy and then go to I'll come back here I'll change this method I'll just remove these methods okay and then I'll make this as send Keys okay so I'll do send Keys underscore username send Keys uncore password and here I'll provide the driver. find element and I'll pass by ID and here I will have to pass the ID of user okay so I'll just pass here as user and then send keys and I'll pass a detail over here as a username all right so this is the password uh this is the username that will pass and then we'll copy this and paste it over here in case of password and over here if we go what's the ID for the password so if you go here if you inspect and look over here ID equal to PWD okay just to make sure this is a unique property I'll just search here s spwd and then you can see that there is only one ID which is PWD okay now I'll change this to PWD and then I'll change this password please note you shouldn't hard code your passwords uh inside your code something like like this but there are Services cloud services which are specifically giving secret managers to store your passwords now I would advise my viewers to kindly use some kind of secret managers like Azure has a AWS has a secret manager and Azure has a key W as such and that can be used as a service within this one but I'm just giving an example and just giving a disclaimer as well you shouldn't store your passwords like this now I'm just using this for demonstration purpose hence I'm using it so even user can be replaced okay so I'll just make this as usern name text ID and I'll just replace this one with user so that I can replace this one with username text ID all right so that I my readability is pretty good and I'll just change it pass by password all right so we have entered the username and password okay and uh you might have noticed that this is a second page that we have uh coded already and the step definition also has been entered over here now step definition even the method has been created we will have to make sure that at least we are entering the username and password okay now apart from that login page you might have noticed that there is um button here as well which is login button we have to click on it so let me do that all right so I have entered the details about the login Button as well on the login page now on the login page step definition let's enter the details about the entering all right so we are doing the send keysor username send keysor password and click underscore but we will have to import static pages okay so I'll just do an import and then import static as well as import static commands Okay so what will happen is we have imported the login details now this will perform the operations on the login page after the operations are performed on the login page okay we have to verify that um it really enters into the login page or the product category pages are really visible okay right now let's try to run these two steps okay let's say do an incremental fashion so let's run these two steps I'll just close this and click on run to understand if both of the steps are working or not so our browser has opened up it has clicked on the hamburger menu it has clicked on signin portal and then we encountered issue okay now where did we encounter issue user successfully enters in the login page okay so it is not able to identify this particular statement so let's clear the result let's do rebuild then let's go to Maven and then click on install then click here run anything let's do mvn clean then press enter on the keyboard so build was success and let's click on run anything again and MN test so it's downloading and running the test as well and let's run this particular feature test now so browser has opened up just clicked on hamburger menu it has clicked on sign in Portal and again it has failed okay now I will give a reason why it has failed now I'll just close this and you can see what we are getting here is a null pointer exception all right now why is this null pointer exception coming this is coming because our driver has not reached to another state okay so I'll explain it how on the homepage we particularly if you see right we are declaring here a driver okay and we are using this driver and the driver is getting closed over here like the lifeline the session of a driver is getting closed here until this homepage after that we are going to the login page okay and in login page again there is a web driver okay now this particular web driver is different from that web driver so that there is no connection or a session between the drivers as well so that's the reason we will have to come up with another class which is storing the web driver across this whole different pages alog together so for this what I will do is I'll go to utilities I'll right click and I'll create a class called browser driver and this browser driver should store the browser driver related test alog together so what I will do is I'll go to home page I'll copy this web driver and move it over here so this will be a web driver and I'll remove the web driver from here and what I will do is I'll extend this from browser driver utility okay so once I do that what it's doing is it's coming from this particular web driver that is we the Declaration of the driver itself is coming from this driver and you can see that there are four usages okay now I'll come here and then I'll remove this web driver as well and I'll extend do extends from the browser dri all right now I will do a build and then rebuild and then come to logged in. feature and I'll clear the result and then I'll run this test so browser has opened just clicked on hamburger menu clicked on signin page and then you can see that it has landed on the logged in page okay logged in page as in you are able to see that the user has logged in and then he is able to see formal shoes sport shoes and sneakers all right now it the test has failed and the test is failed at the third step because we have not designed yet that's the reason it has filled but we will design it and we will put assert values over here okay so selenium has assert values assert has different variations as in you can compare the actual result as well as an expected result so that you understand whether the your test is really successful or not so let's design the third step now so if I over on top of this you can create a step definition and please note that that you will be able to get something like this okay now it is uh intellig has got an intelligence that you are step definition folder is there and uh you are already mapping your features along with the uh step definitions okay and uh it has kind of indicated do you want to create a new file okay and do you want to create it under some particular features now you can um add it under the same function if it is required so it it kind of gave an indication that if you really want it under homepage or login page based on that it will create the method but if you want to create a new Step definition you of Step definition Java file then you will have to create it under his or else if it is under home or homepage or login page that you want you can get it added over there but what I will do is I'll create one more page okay so I'll just create one more page as well which is logged in page and in my step definition as well I'll create one logged in page okay all right so once that is done you can see that we have a step definition over here we have pages over here so let me capture the objects of the page okay so if I come here if I go to more tools and the developer tools let me hover on top of this and look at at the headings so there is an ID which is shoe type equal to formal and if I over on top of this then again this is a ID this is not unique so as you can see this is ID shoe type this is an ID equal to shoe type so this is not unique okay now we will have to find out some other unique property so that we understand okay fine there is a formal shoes there is a sports and then there is a sneakers at least the titles are present all right so for that what we will do is I'll just right click and then look for xath okay and come back to intell and I'll try to look at the xath in the login page I'll just paste it over just to have a view and the xath that it is giving is also ID equal to shoe type okay star equal to ID equal to shoe type but having said that there are different variations of xath as well okay now um expath itself is a very big topic to understand but why I will give kind of a a quick understanding about xath as well xath is something like a Dom element right document object model element depends on how do you want to really capture now what I can see over here is when you press star okay um for/ slst star then you will be able to get the whole page as such okay and once you narrow down to ID and and then equal to text text equal to formal shoes okay now forward SL for slash equal to test okay so I'll press star and then square bracket text equal to formal shoes so what it will do it it will look for this particular section okay and we will try to do get text on this and then uh once we get the get text we will put an asset value all right so based on that we will try to do the comparison let me create the methods first so I'm adding the extends and browser driver so that we can use a browser driver as such and then let me do asserts all right so we have created uh three methods over here we will verify the formal shoes text as well as sport shoes text as well as sneaker shoes text okay now now what we will try to do apart from that is we have to capture the elements okay now I have already created public static string all right now you might have noticed this particular error wherein the double quotes is coming because we are providing double quotes that's the reason it is not accepting so how we can handle this is doing a backwards slash as well as backwards slash over here and which solves the problem all right now what we have done is we have captured the x paath of the formal shoes I'll just copy and paste for the sport shoes all right so we have captured the U element locators for formal shoes sport shoes and sneakers now we'll store it in the variables and once we have stored it in the variables and once we have stored it in the variable what we'll be doing is we will get the text out of it okay now because this is a string we will have to do get text and then complete the statement okay so we'll do for all three all right so we have completed this now we have to add the assert statement assert do equals and we will have to import the static method which is uh gunit so I'll do that and similar to asserts we will add for the formal sport shoes as well as sneakers so I will just add this one and do a comparison as well whether it matches all right so we have designed our assert statements as well we have captured all the test results so I'll just uh we have not created the step definition yet so let me do that as well from login page I'll just quickly copy this and come to logged in page and then I'll add the method as well all right so we have declared it now we will add the methods of the PS s so we'll do an UT we'll add the interruption exception as is asking for all right our third test step is also configured all right now I'll just um change this one to then statement I'll come here product category page then save it come back to logged in feature and then you can see all three test steps have been configured okay now I'll just do a build and then rebuild after that I'll run the test so browser has opened just clicked on the hamburger menu has clicked on signning Portal it has entered all the details all right so we have encounted an error and let's have a look at what the error is so the error is no such element unable to locate the element that is Method expath and the selector so what what really has happened is we have got not been able to identify with through the x paath that we have selected okay so we will do a slight change in the xath what we will do is we will remove this uh part where we are looking for the shoe type because the web page is looking for because the xath can be looking for that this whole text that is formal shoes that is good enough so I'll just remove this shoe type from the xath and let's see all right so I have removed the uh shoe type as such but we'll be looking for formal shoes Okay and then we'll be verifying that with actual form shoes or not okay so let's uh go for a rebuild and then check to run this test I'll go to logged in and then I'll clear the result I'll just over on top of that and clear the result and then I'll click on run and let's see whether our test trans or not all right so browser has launched just clicked on hamburger menu let sign in Portal and you can see that the three scenarios have passed okay now three scenarios have passed we have reached this particular page all right now we can add one more step that uh kindly exit driver. exit which will make sure that this browser get closed but I wanted to show you the results as such that it's coming over here and it's validating now if I change this little bit okay so as in if I change certain parameters like for example if I change this formal shoes to shoe for example then it would fail because it's trying to match with the uh exact text which it is trying to appear okay so that is kind of logged in feature so if users should be able to view the product category page so once he enters into product category page he should be able to see formal shoes not formal shoe as such so it what it means is is kind kind of doing the validation kind of regression test if the web page is correct or not now we can try to attempt that as well what we can do is I'll go to this particular test step and then just make this AOE and then I'll go for a rebuild so I'll just click rebuild so the rebuild is happening and after that we'll just run the test I'll go back to logged in. feature and then click on run button and the test will run and the browser has launched and it has clicked on hamburger menu just clicked on sign in Portal and then it has landed on this page which is fine like it has landed but having said that our one test has failed okay one test has failed because expected was formal shoes with the S and what we got was formal shoe okay so expected in fact we had put as formal shoe and actually uh formal shoes now some of my viewers might be saying okay fine uh in assert right the first parameter in fact should be your expected value okay so this should be your expected and this should be your actual so I can kind of interchange as well so that it's much more clearer so I'll just interchange this one and put it over here so that the expected is formal choose now I'll just revert it back so my test passes and that's what we are expecting as well and I'll just move these arguments as a second argument rather than first argument because the first argument is supposed to be expected and same I will do with the sneakers as well the tests are correct all right now we are good we have achieved what we really wanted our first test has passed okay all three test steps have passed and what we will do right after this is we will try to design the second test case so that we understand okay how to do a reusability as well and some of the steps like the first step that is given user navigat to the login page all that is uh already done so we can kind of reuse it in our uh second test as such all right so let's do that so for the second test what what we have to do is we have to come to New register user registration and you can see the given statement is already uh having a step definition what is not in the step definition is user clicks on new new registration button okay so this is pretty easy what we will do is we will go to in page and over here you can see that we have already done some steps related to user successfully enters the login page Okay so registration page right now if I if I open up this and if I go back to my homepage and click on signin portal now this already has been captured where so where did we capture this one if we go to login page for example we have captured the login button xath okay so we have not captured the registration or new register here yet so let's do that in the same web page of the login page so we can kind of reuse this so I'll enter the element over here which is public static string all right so over here we will try to get the expath of this one so I'll just right click do an inspect element and I'll just over on top of this and over here there is an ID which is new registration okay so what do we have to do is we have to go to to elements okay and over here we have to check for the element whether it's a unique property or not okay so what I'll do is I'll do a control F and over here I'll just type here as new registration and let me have a look whether it's a unique okay through the page so yes it is unique so that is a good news all right so I think I forgot to make this as capital r so I'll just make this and it's a unique thing all right so that is what I will do I'll probably select here not an xath but probably I'll use it ID over so you can see that I can use combination of xath as as well as ID whatever suits the best that is that is what we will try to use and I just write copy this and come back and I've already got my ID all right so let me use it to click so click new user or new register all right I'll create a step definition here so here the step definition will be what we were supposed to get for the new registration so I'll just user clicks on new registration button all right so we have entered this one okay and uh we have reused couple of uh reuse the login page as well as login page step definition okay so I'll go back to new registration. feature and I'll just go here and then I'll just click on run Button as such so my second test will run browser is open it has clicked on hamburger menu it has clicked on signin portal and it has failed so let's have a look so the the statement has not matched exactly as per what is required so what I'll do is I'll just copy it and go back to step definition and as you notice what I had done is I have slightly modified the step definition that is uh it was not exactly matching with the when statement assess so I'll just paste it over here so that it matches exactly and I'll just go to build and then rebuild and then I'll go back to new user registration I'll clear the result so that the failure has gone and then I'll click on the run again for the scenario second scenario as say so it has open the browser it has clicked on hamburger menu it has clicked on signin portal and we got an error over here here that is both username and password fields are required so what has happened it has clicked on login button okay so if I go back and then have a look at my user clicks on registration button if I go here as you can see what I try to do it we had not changed the loginor button xath okay so we'll have to change this what I have to do is I will have to change this as buy ID and here I'll have to pass pass the ID s and it needs to click now click on build rebuild all right so after rebuild is done you can go to new registration and then click on run the browser has opened let click on hamburger menu it has clicked on signin portal and we are on the raise new user registration page okay successfully now having said that let's do one thing let's capture this particular text okay user registration page text so that we have this validation that it is present here on the third page so let's uh third step so let's do that and let this browser remain opened and over here on the registration page we are supposed to capture the page as such page details or page elements as such so so I'll just capture this one so I'll do extend browser driver so that I'll be able to get driver details from utility folder and over here I'll just capture this particular element I'll do an inspection so I'll just right click so this one is an edge I just right click copy copy xath and you can see that uh we can capture the xath as well which is a center H1 which is kind of a unique property as you can see if I go back here and open up this one elements as such and do crl F and this will probably remain the same so I'll just modify this one user registration X path and this should exactly match with this particular title which is user registration page so just copy it come here and then paste it over here all right so I'll just click on build and then R do a build rebuild and after that I'll just rerun I'll go back to new user registration and I'll clear the results as well and I have to create a STP definition okay so I'll what I'll do is I'll create a STP definition for registration page as such so I'll go to login page I'll just copy that login page and then paste it in the strip definition and I'll just click on okay and I'll just modify this uh then statement as such so that it matches with our feature file I'll do an import class I'll copy the statement so that it is kind of matching all right so once that is done I'll go to registration page copy this particular method import static method so iow to slightly modify this visibility visibility iow to modify this to user registration page all right so my registration page is visible and if I go to new registration. feature file as you can see all three test test steps are done and I'll just click on build and then rebuild and then run the test of the second scenario I'll just click here and then click on run so browser has opened up it has clicked on hamburger menu it has clicked on signin portal and we are on this reg user registration page okay so I'll just close this and you can see one scenario and three tests have passed okay so our second test is also ready which is good now you might have noticed one thing we have created and designed and in fact run the first test case we have created designed and run the second test case now we have not done it for the general user view okay so third test is not ready yet but having said that we can design that at least couple of test are run sequentially in the runner file so here is where our runner file will come into picture all right so in previous uh section we were just looking at um we had created couple of test already which is logged in. feature as well as new user registration. feature all right and previously we had created this test Runner file as well but we have not specifically used it okay we had only added features over here and there was a glue uh that we added which is utility as well as St definition okay but we extensively we did not use a test rof file now is a time because we have couple of test cases which are up and running which we have created design that's the reason we are trying to run it sequentially all right so in order to run the test Runner file what we have to do is first we have to configure the test Runner okay now in to configure the test Runner what we have to do is you can go on this particular section which is run button okay and after this you will be able to see something like edit configuration so you can click on edit configurations and in this edit configuration we have not done much okay but you can see automatically we have got cumar Java over here as a runner file but this is not the runner file that we are looking for okay what we are looking for is a different cucumber options particular run withd file so for that we will create this configuration so so what you have to for what you have to do for this is you have to click on this add new configuration and over here you'll be able to see something like junit okay now you can select the J unit over here and after that what you can do is you can try to add Runner okay now the moment you type Runner you'll be able to see intelligence over here that there is a runner and after that there is a test Runner okay now you are getting this error which is class runner. testrunner is not a okay so what it means is it is not able to identify this particular uh test class or test Runner file as such so what you can do is you can probably click on apply okay and then click on okay so you can see that the configuration is saved okay but there is some error in the configuration okay so it's being shown that there's a cross on top of that so it means like as in it's not correctly configured yet so let's correctly configure it for this what we have to do additionally is we have to add one more annotation which is at the rate run withd okay now once we add run withd you can see that there is an import that has happened for at the rate run withd and it has come from junit Runner run with uh Library as such and over here you will have to pass cucumber. class okay now the moment you add the cucumber do class you can see that even cucumber junit cucumber has been imported as a library okay so these three all three libraries are very important before you run uh the runner file okay now once you have already done this you can go back and then you can see that the cross mark is gone so I can click on edit configuration and even our error is gone okay so that's that's how you configure the test Runner file and once you can probably rename this and you can just put it as stress Runner just for identification purpose it will really not um impact the code as such but just for your identification Okay now click on apply and click on okay and after that you can click on test Runner file now the moment you run this what will really happen is all the test will run okay now the first test has first test has failed okay you can see the general view has failed the logged in user is happening it has passed and then it's started the new registration View and then it has uh passed that as well okay now you get an indication over here down below that one test has failed and two have passed okay now what it means is it has taken around 16 seconds of time for the three test and correctly as expected it has failed the third test because we have not designed it yet that is a general View feature and if you click on it it can it will give an indication okay you have not written the steps or step are not defined or undefined okay which is kind of expected failure as such and if you click on validate user you will be able to see all three test steps have passed and validate new user all three test steps have passed okay so the runner file has this time made sure that um our tests have run sequentially so you can imagine there are 25 30 test which are present in our test Suite so we cannot every time uh run uh this individually it is better to have a test Runner file which tests which runs all your test together all right so our test Runner file has been configured now let's try to complete our third test all right so now that we have completed our first test which is logged in. feature and the second test which is new new user registration. feature now we will configure and design our third test which is General userv view. feature okay so similar to what we really did for um test case number one and test case number two we will do it for test case number three as well we will try to inspect the element from our web application and add it in our pages and in the step definition as well so for Pages we have already created a class which is online products page and and what I'll do is I'll create one for step definition as well so I'll just copy from registration and put it in the step definition as online products and what I will do is I'll start configuring this all right so we will keep this empty and uh what we have done is uh we have completed our then statement okay so we have at least declared the then statement and for the when statement we will create in online products itself all right so we have declared even the V statement for our third test which is good so I'll just do an import class all right so if I go to General View our second is also second step is also defined now user navigates to the online products page okay now this online products page if you see if we go to the homepage right we are clicking on signin portal sorry signin link now similar to that we can use the given statement over here similar to that we can create a given statement in homepage okay so I'll just copy this and paste it over here and then user navigates to online product space so I'll just copy this come back in my step definition file and change this to online products page I'm doing this because my online products link is on the homepage okay so I have to navigate to online products page so I'll just change it to click sign in Portal link right now if I go to homepage I'll have to Define this one and create under link test so I'll just make this as online product page and I'll go here and click come back to the first page which is the online products I'll just right click and do on inspect element so online products is my link test similar to this I'll create another method which is click on online products link all right so that is is done I will come here to homepage and change this to click uncore online products page products uncore link all right so we have declared and used our given statement now what is pending is couple of uh statements for when and then so this is going to be tricky and where I want um my viewers to concentrate is the third test right now it's a web table that we are trying to automate and once you click on the online products you happen to be on this page okay now this page is a little bit tricky because you have three drop- downs and what you need to do as a user or an automation script is you need to click on this drop down okay so if I go and inspect this element you can see that uh there are um elements related to class so I'll just try to open this uh particular Dev tools so that is visible and if i h on top of the second drop down you'll be able to see that there is a class difference okay so there is a sports shoe drop down and this is a class name which is different from this particular class name which we wanted to have it for the formal shoes drop down okay so class is different class is unique so what we'll do here in this case is we will use the element locator by class okay and uh after using the element locator of by class we will try to perform a click operation on that that is one thing and once I click here and go for an inspect element all right and I come here and then click on the shoe name now if I over on top of this table class okay so this is a web table okay and web table is a unique web element wherein the whole table can be taken as a web table element and you can see that there is a class name over here which is formal je table okay which is unique now this formal choose table is uh going to be our identifier of our table okay and from the table once we capture the table what we will try to do is we will try to find the row number two okay now why I'm seeing the row number two is classic chelum happens to be our expected value okay now classic chanm if you see it is on the second row of this table that is how you see it otherwise there is one more angle that you see okay now if i h on top of this this is a th but T head okay and Below there there is a t body okay now T body is something down below so if I CL over on top of this T body you can see that it's skipping the T head okay and we are able to capture the whole body itself now this is an important parameter and I'll explain you when we are coding as as well first we have to take the web table as a unique property and from there we will take as a t body and from T body we will try to take the first row of the T body and within the first row if I hover on top of this we get TD okay that is a first row and the First Column now first row and the First Column is what we are interested in which is classic chanam okay and that classic chelum is is what we are trying to ex ract first and then try to validate with an expected value as classic chanm okay now this is how we have to design our automation scripts to pick up a particular value from the web table and do a comparison okay so let's start to do that let's come to our code and user clicks on the formal shoe drop down so that is the first statement that we are trying to automate and for this we have created step definition but we are yet to create the web element okay so for that what I'll do is I'll go to online products and online products we have not defined it yet so what I'll do is I'll come to login page I'll just copy one particular element and paste it in online products and I'll will modify this so if I come back and what we are trying to look at the element is this particular element which is formal shoes now here as I mentioned we will try to take by class as our web element uh locator okay so let me do that and I'll create a method over here all right so I have defined a method over here and this time around what we will do is we will use our um bu class so driver. find element by Dot and if I see there are different element locators over here ID xath link test CSS selector and class name is what we are looking for all right and I will pass the parameter of formal shoes drop down class and then we are going to perform a click operation on this all right so we have designed this and our couple of statements which is the first statement and the second statement given and then are already done designed so let's run this step test for couple of uh test couple of steps and let's see whether that passes the browser is launched hamburger menu is clicked online products uh link has been clicked and we have landed on this particular page of online products okay and you might have noticed that the formal shoes web table has opened up okay so we um like through the automation scripts we have clicked on the drop down and then this whole web page is opened up which is good so our both of the test as in uh two step test steps looks good the third test step needs to be uh coded as such all right we do not have anything on the third web uh third test step so let's code that for the web table perspective so if I go to online product so what we have done is only the formal shoes drop down class but here is where we will inspect the element of the web table so I'll just go here and click on this particular web table so I'll try to extract this particular web table and then combine it with the D Body now for this what we'll do is we'll right click on this table I'll just copy and go to copy xath so I I'm copying the xath of this particular table message I'll come back and then put over here as public static string and then web table formal shoes web table and this is the table web element that we have captured okay so the x paath of the web table has been captured and put it in this particular string now apart from that what we can do is we can go and capture the this particular T row so I'll just go and copy this particular X paath store it in another variable public static string formal shoes web table uncore Dr equal to in double quotes we'll pass this okay now if you have noticed we have captured the whole first row over here okay within the T body you can see that there is another row the first row and this is an index showing as this is the first row okay now whatever U um expected results say that this is the first row and the First Column okay so every time we are to validate that the first row and the First Column is what we want to validate from a perspective of what's the ACT ual value which is coming from it okay now this test is only capturing the static value of the first row and the First Column but generally what happens is you tend to get the for expected values or your web table might testing validation might be a dynamic Factor so if it's a dynamic Factor Make sure you do not Define the index okay because it will capture the whole index as such the whole values as such okay all the row can be captured at one uh particular shot so this is because we have the first row and the First Column as column that's the reason I'm putting it into this particular category which is TR and TD as such all right now what I'll do is I'll get the get text of this so I'll just perform here as public static void get text formal shoes first value and then driver do find element by xath so we'll provide the xath expression here the formal shoes web table R then get text okay now here we have provided the get text I'll come back to step definition so I'll just come here and then I'll just provide here as get text for first value and after that we are supposed to do assert equals okay so I'll put assert equals asset equals expected which is classic chanam I like to be very specific of this particular spelling of class classic chelam then we'll provide the details of get text first former choose okay all right so we are done we'll do a build and then rebuild then run test General view just come here and then run so our browser has opened just click down hamburger menu just click down online portals and it looks like our test has failed okay let's have a look why the test step has failed all right so you can do a you can see that there was a comparison the expected was classic chelum but what we are getting is couple of spaces over here and then classic CH now if I hover on top of this particular value okay so if I go here and then look on the inspecting of this P particular classic CH so there were two spaces over here okay and then there was classic chm so what we'll do is in the expected we just modify this one and add couple of um spaces and then do build rebuild and then run the test again so browser has opened up just clicked on hamburger menu online products all right so the browser has opened up and it has clicked on the hamburger menu it has clicked on online portal it has clicked on formal shoes drop down and uh hopefully try to validate and you can see that the three test steps have passed okay so all three test steps have passed which is good so this is what we wanted and uh we have completed all three test cases as in logged in plus new user registration plus general user view all right now what we will try to do is we will try to run it in the testr runner file okay so we will choose test Runner and we will go here and click on test Runner and we had already configured the test Runner okay there so there is no change as such that will happen in the test Runner and what is supposed to to happen is all three test cases have to be run automatically in sequential fashion so I'll just click on the Run button of test Runner and you can see the general view test has started out of the three tests the first test which has started is General view then is loged in view okay logged in view user so new browser has started and then it has completed and the third test has started which is new user registration View and it has completed as well so it the all three test cases have taken total of around 21 seconds okay so 21 seconds and 182 milliseconds is the uh time it has taken for all three test to run and as you can see that uh it does not depend on what test that you want you have scripted first okay so what how we did is we had scripted logged in user first and then we scripted the new user registration and then we scripted the general View now you can see that it's alphabetically ordered okay and based on which um these uh three tests have run automatically so that's how this whole uh test Runner file runs as well and it helps you to run all the test Cas which have been automated in a very sequential fashion and uh you can imagine there would be like 50 60 test cases 25 30 test cases which are huge numbers and the those cannot be run individually it is better to run as a test Runner file as such all right so we have done this regarding reporting okay so if you click on the target files and you can see by default there is a cucumber HTML report which gets generated now what I will do is I'll write click and then open in and you can see that there is a HTML report which gets generated okay now what you can do is you can right click and then you can do go to open in and you should be able to find Google Chrome now what I can do is just to show okay I'll just contrl C and then I'll go to HTML viewer and then paste this particular HTML viewer and uh this is how the output will look in the uh in the Cucumber HTML VI uh reporter as such now there are three scenarios which we have run okay and it gives you an idea about uh how many scenarios are there so if you click on is General viewer okay and uh this is logged in view which is uh the second test and the third test is a new user registration so our report is also getting generated and you can use some kind of um filtration as well like uh if you just type as general and then click on search you'll get uh you'll be able to filter it now if I search as logged in and click on search then you'll be able to get the logged in test as suchar uh you will be able to see how much time it has really taken and what are the implementation what's the runtime what's the OS and what is the CPU okay so all this are kind of uh relevant and irrelevant uh details will come out but definitely duration is something which is irrelevant as well as the scenarios and the scenario details whether the test is green or red those kind of details also is kind of helpful now in the next section which is important as well uh we will try to configure all reporting and based on that we will try to use Allure reporting how the report really looks from a Allure perspective and it's kind of a beautiful report comparatively and for which we will add it in the pom.xml and then try to configure that so let's do that all right so in this section we'll be looking at how to generate uh Al reporting and we are going to integrate it with the Cucumber bdd test framework now what I have decided to do is we I have tried to depict these step-wise approach okay and it is very important because if we miss any of the steps it might not work okay so alare has undergone lot of changes and the one which I'm showing currently is the latest one uh with in relation to the bdd test framework as well and uh I'll give the documentation of all specifically configuration that has to be done so if you look at this particular link of alare okay so this is alare documentation of official documentation and this is cucumba jvm specific documentation so if you look from this perspective there are a good number of configurations that you have to really do I will go through all the steps sequentially okay and so that you will not have any issues as such but I'm giving the reference document link here as well if you get to stuck somewhere kindly go through this documentation but I will give the stepwise approach as well so I'll just minimize this and I'll come back to the steps that I have defined already all right so the step number one is you will have to check the version of cucumber that you have in your framework okay so the version of cucumber that I have in my framework is cucumber 6 okay this is very important to understand because this is how we you will have to configure the dependency of the AL in your pom.xml okay so step number one is to determine what version of cumar you have in your frame which is important step number two is you need to add the plug-in of Al support in intellig okay this also I will show how we have to do this step number three is very important make changes to your pom.xml so you will have a maven pom.xml in your project as such and you will have to make changes in that pom.xml the first thing in that is you will have to add a dependency of Al cucumber 6 hyphen jvm okay now this is important because I'm specifically using cucumber 6 in my framework that's the reason I'm telling that you will have to configure the dependency of alare hyphen cucumba 6 hyphen jbm now if you have cucumba 7 which is the latest one currently in the market go for Al cucumber 7 hyen jvm under dependency Stacks so in pom.xml there should be dependency stag you should add this particular dependency uh related to cucumba 6 jvm second Point related to pom.xml is you need to add a dependency of Al hyen junit hyphen platform under dependency tag okay so this is another dependency that you have to add you need to add dependency management tag for Alo version so I'll touch base on that as well what you have to specifically add and the fourth point is that you need to add the build tag for the aspect J viewer Okay so aspect J Vier is a mechanism that through the build process you will be able to create some dependencies which is important as well I'll show you that aspect step number four is ADD properties files so in your project you have to add allow properties the location exactly where you want your results to get stored okay and junit hyphen platform. properties the cumba plug-in details so this also I'll show you how it has to be done step number five is make changes to the test Runner file for the plug-in details this is important because your test Runner file has to call this particular plugin okay and you have to install AOW command line through npm okay so I will show that aspect as well so these are the six steps that you have to perform in order to generate the AL report into your project now let's see practically how you really can do that so this is my cucumber uh that is the bdd framework that we have been looking perspective okay the first step that we had to perform is you have to understand what cucumber test that you have okay cucumber version do you have you used in your project s so I'll go to pom.xml and just to refresh our memory what we cucumber version we have used is cucumba 6.1 how would you be able to understand is if you go to dependencies you might have already used cucumber in your um framework assess so we have used six version okay so it is evident that we use cucumba 6 okay we have understood okay the six version is the cumba framework now the Second Step that we had looked is you need to add the plugin of all support in intellig okay so how do you do that is you go to files and in the settings once the settings model opens up you can go to plugins and in the plugins you can search here as Al and you will be getting as Al test Ops support okay so this one I already installed in intellig and if you have not installed yet kindly go ahead and install in your intellig okay so that was our step number two step number E3 is you have to make changes to your P XML okay so first thing that we have to do is you have to add the dependency okay so I'll just open this up and I'll show the pom.xml and I'll show that under the dependencies so I'll go to the dependencies okay so I have added here as Al cucumber j6 Al hyphen cumber 6 hyen jvm okay so this is one aspect that I have added I have to add all junit platform as well so what I have added here is Al hyphen J unit 4 okay which is important you need to provide this details as well and this comes from your uh Library which is iio do comer. alare okay so make sure you are getting this particular k. alare and all this has been provided in this documentation from where you have to exactly take this Library you have to add the dependency management I have scroll up you'll be able to see that I have added I have added here as a dependency management okay there are a couple of dependencies over here as you can see that there are dependencies related to Alo bomb as well as junit bomb okay this contains the dependency management apart from that you have to add the build tag now inside this build tag you can see that there is a Mayan Shire plugin and there is an argument line that we are passing as a committer plug-in we are calling over here and apart from that I'm providing the aspect aspect J Vier okay so this is important as well that have added inside the build tag so once you have added this in your P pom.xml what you can do is you can go for add properties okay so once I open up here under Source under test there are couple of uh properties I have added that is allow. property now the allow. property I have provided the details of allow. results. directory so what it will do is it will create Al results as such and junit platform. properties okay here I have provided the details of the cucumber. plugin details all right now once that is done you have to make changes in your test Runner file okay so what I'll do is I'll open up the test Runner file under Java folder and under test Runner file I have modified this particular line which is line number 12 little bit now you can see that I have added IO do. al. cumber 6 jvm. Al cumber 6 jvm okay so I'm providing the details of the plugin so test runoff file should ideally call this plug-in once this is done what you can do is you need to install alare command line through npm now how do you do that is I have shown here specifically if I go up if you haven't really installed all command line yet what you can do is you can run npm install hyphen Al hyphen command line hyphen hyphen save hyphen Dev now once you do that you can see that there will be uh an update happening you will you can see one package is changed what it means is it already was present that is the Ala command line but having said that it has got updated now now just provide these details in your command in command prompt or you can come to the terminal of intellig and you can just run this particular command all right so once these configurations are done what you can do is because I have already created the AL report and R result I'll just delete these folders so that it's fresh all right now I have deleted it and as we have three tests under our feature as you can see there is a general user dot General view userv view. feature logged in. feature new user registration. feature all right now I'll come to test rofile I'll just play or run and our test will run all right so the first test has already started as you can see it's a general view all right so second test has started which is related to logged in user and third test has started which is related to new user registration all right three test have ran and three test have passed and as a result as you can see that there is a new folder which has got created called Allure hyphen results okay now this will store all the details which has really run what you can do is you can come to terminal and then you can run a command which is Al generate Al hyphen results hyphen hyphen clean hyphen o Alor hyphen report okay now these the first results or results have been stored in Json file some are in attachment. HTML container. Json which is not readable as such but this particular command which is Al generate Al hyphen results hyphen clean or Al hyphen report once we enter this uh report will get generated now you can see a new report has got generated and over here there is an index.htm HML okay so now you can right click move to open in and then browser and click on Chrome and once you open this up you can see when exactly this has been run at which date how much time it has really taken so it has taken around 23 seconds which is duration you can click on General view loged in view as well as new user registration okay so once you click on here particular step you'll be able to see that there are three steps and exactly how much time it has really taken okay so in logged in user as well as new user so this is how a beautiful report gets generated it gives a kind of a pie chart as well it gives uh line by line aspects it gives a graphical view as well and you'll be able to see how much time it really takes and you can see the categories there are no categories ass such you can see the Suites the timelines how much time it has really taken and uh for the sake of looking at the report what I will purposefully do is I'll P purposefully fail a test okay so what I'll do is I'll go to a test features now I'll go to this one and I'll modify a test okay I'm just failing a test just to see how it really appears in the report so I'll just run this again all right so the first test is running and it has failed which we wanted it to fail second test has has run it has passed and third test has run and it has passed as well so two tests have passed one test has failed out of three now what I will do is I'll go to terminal command and run the report again in fact generate the report and if I go to index.html I'll go in the browser and open up the report as such all right now you can see out of three two have passed and one has failed okay so it is very important to understand from perspective how the graph looks like most of the times the test might fail as well but it is important how it really looks from a Report perspective so I'll just go back and revert it so that the test passes as well but hope you understand how to configure the AL report in our bdd framework as a report helps us to determine how much from the duration perspective date perspective as well as test perspective and uh the whole project has been already pushed into a GitHub public repository which I'll be sharing in my description as well kindly like share and subscribe our channel for more details like this happy coding and and happy automation testing