Data Driven Framework in Selenium WebDriver(Using Apache POI) - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so today I'm going to cover that is what is data driven testing okay done by where we are storing the data inside the excel files okay that's the most important topic because in the life projects also you will be storing a data in excel files and how will you fetch the data how will you fetch the test data from the excel file I will give you an example that okay let's see if you want to execute for multiple lines you want to submit a form and you want to submit multiple test data okay so obviously you are not going to store the data inside your script right so you will be using excel file concept to store the return so why we are preferring excel file because excel files are easy to maintain it's very user friendly it stores the data in the form of rows and columns right so we can maintain the data in a very systematic way and in a single excel file we can create number of worksheets okay so let's do that and then there are number of utilities let I'll tell you that how to use those Judit ease in excel files okay so for that what exactly we will do in our project and create a separate Lachie I'll create a separate package and the package name is let's see comm dot Excel dot utility okay this is my package name and in this comb tot Excel dot utility what you have to do I will give you an excel file code okay that utility is already created you don't need to concentrate on these utilities okay number of function generate functions I have already created you just need to copy paste that particular excel utility okay in this particular package and start using all the methods written over there nobody will ask you at a time of interview that okay how will you read the data from excel file right the method or okay or give me the syntax or right the automation for that no nobody will ask you because these are the standard methods provided by X and automation in Java okay so those methods and those generic functions already created okay so you can use this particular utility okay whenever you join any project or any kind of automation you are going to start you can use these do Atilla T's and then you can start working upon it okay so I'm giving you I'll be giving you this particular excel file dot Java class one I have one class that I already created so I just downloaded yeah this one okay so I'm going to copy this and just paste it over here so I will share this thing with you okay so one utility is there XLS underscore Reader or Java you can give any name whatever the name you want to give you can give any name so if you open this class you see that there are number of methods are written over there so if you want to see that what are the different methods are there just press ctrl oh okay or in Mac you just need to press command oh you will see that number of methods that get row counter okay so there is let's see there is one excel file and you want to see that okay how many counts are row counts are available how many rows are available so we have get row count which will return one integer obviously ten rows are there it will give you ten if there are 15 rows are there that will give you 15 similarly we have get get data from a specific cell okay on the basis of rows and columns if you want to add a new sheet if you want to remove a sheet if you want to add one column remove the column if you want to change out okay some sheet already exists or not this is the method if you want to see that okay how many column counts are available we get quite amount is available right get cell row number the specific number you want to check ok gets a low number is also there so these are the utilities all these utilities are created with the help of one APA we are using that is called Apache pi e library okay this is used by Apache poi library and right over here for you guys Apache boy okay Knapp tree so this Apache pylab reading it's a java-based like today it's freely available okay you just need to download and you need to import in your project so how to download a patch apoyo library what you have to do just go to google ok and simple we need to write download a patch a boy okay and click on this first link what happened okay you need to download these our power J PI EAP is let it open okay let me check in some other okay see this is the patch apoyo piayed or PI API download release art events what you have to do you have to go to binary distribution don't download source distribution otherwise it will give you complete source code okay so what you have to do you have to download this one the latest version this one this zip file tar file you have to download ok so just download this towards easy just click on that it will start downloading automatically ok so there are number of download links are available so you can use this latest HDB middle link so just click on this and this is a zip file ok tie rods user file it's around 21 MB if we you just need to start out let it complete and then okay so it's done so what I will do I will go to that folder and this is the jar of a simple we will unzip it okay so you see that this is a folder okay we have extracted in this particular folder in this particular folder VM number of jar files are available now what you have to do we have to import these jar files in our project this is my project and just right-click on it just like we did for selenium girl files go to properties and go to Java build path click on libraries and these are obviously external jar files so click on add external jar files and what we have to we have to go to a download folder this is the folder and all these jar files we have to add okay don't add license and noted all these things all these will jar files we have to add dot jar files and click on open see that okay these jar files has been added now again click on add action jars there are some other libraries also just click on this or XML library click OK add these two libraries also XML beans and this curves ap8 towards our fight also be able we have to add and again click on add action jars go back and check if there are at the libraries also so these are the other libraries also okay you can ignore this j-unit jar file because we don't need to ej unit so you can download you can add all these jar files also ok and click on ok the moment i add all those jar files see all the errors are gone now right because all these files are coming from where this XSS workbook exercise sheet Rose cell everything is coming from Apache by APA okay and this is a package we have to change this particular package is available in we have to give this perk package comm dot Exel dot utility so as we move this package and I'll add that package okay so once you add this particular Excellus underscore Reader dot Java utility number of errors will be there okay number of red line ads will be there so how will you remove all those errors you just simply you need to add on the jar files of Apache by APM so you need to download it and add the jar files in your project and once you add all the jar files are I mean all the errors are gone right now what you have to do so these are the utilities number of utilities number of methods are available okay now what we have to do we don't need to bother about that or how exactly we wrote this code and everything we are not bothered about it okay you just need to use the code you just need to use a method all these methods you need to call all these methods according to your requirement now so this is the utility so editor I put over here inside this utility package separate utility I created over here now I will create a test class or maybe I will create a simple let's see I'll create another package comm dot let's see data-driven dot test okay so today we will learn that how to do data driven testing inside this particular package I will create a class let's see my class name is data-driven test okay select the main method and click on finish so inside the main method okay we will start writing our code now first we will create one excel file obviously now we have to read the data from excel file so what it exactly I'm going to do I'm going to create one excel by you just open your file I'm going to create one one blank workbook okay so this is my this is called workbook inside this workbook we can great number of worksheets right by clicking one plus right we can create different worksheets and then we can give some name also okay let's see today I'm going to cover let's see the de station registration test data okay something like that you can give some name worksheet name and you can create multiple sheets like this by clicking on plus icon so inside the single workbook we can have multiple worksheets okay so we have this particular worksheet and module wise we will prepare our data so let's see we have this particular ok let's see we have this table dot ebay.com and sorry not even odd come so what I will do I will go to sign-in page and we will do the gestation process because we are familiar with this code right so okay now let's see I have to fill some data over here so what I'll do that I have to fill this form so first I need I know that okay I need first name last name address city and state and everything so I will create these columns in my excel file okay so I have written that okay registration test data and my first name is like that first name last name right address one at there are to address address well it is true then we have city then let's you will that state also okay so number of columns I will create and zip code zip code and then what we have then let's see email address okay email address we have and fine till here we will fill this form this first section we will fit okay so these are the columns I have created okay the first row will be represented by the column okay let me write the proper name first name okay see it's a good practice that either you can start with the you know F capital or L capital but don't give any space between these two words like first space name don't do that okay although it's your choice you can take it with a space named but I won't recommend it because there are chances of errors manual errors so what we have to do better give some more everything is in a small so that everything will be generate now first name let's see I'm giving Tom last name I'm giving am prepare my data Tom Peter let's see address is twelve new Street and let's see downtown city is let's see Sonny will state it let's see California okay so I know that state I had to select it from here so make sure whatever California spelling is written over here it's C capital the same exactly thing you have to write it over a California let's use zip code is nine 408 five and email addresses let's see Tom at the rate gmail.com okay this is the information I want to fill right and what I'll do to make it more clear the first I mean the column headers I'll make it bold and let's give some color also so that you will understand okay these are my columns and my actual values are getting started from second row right first row is always column wise always remember first row is always columns now I'll save this file first of all so I'm going to save this file lets you on my desktop and let's see my give some proper name let's see half ebay test data okay so give some proper name half ebay test data and you have to save with dot xlsx don't say bit dot XLS save it with dot xlsx and say we don't next stop and click on save okay so half EBA test data is my workbook and inside that we have one sheet the regular I mean registration test data this is my sheet name okay and then save it and what I'll do I will go to my desktop and where's that file half just search half ebay test data I will copy this okay and copy this and I'll go to my clips and I will create one more package over here for my data let's see comm dot test data okay comm dot test data another package is there and inside that package and paste my excel file so my excel file is also part of my code or part of my project okay so I'll close there is a existing excel file that I created on desktop and I'll open this file okay half ebay test data dot XLS and open this movie okay so this is my file see you can put put it on your desktop also that doesn't matter but it's always a good practice that your excel file should be part of your project so just create a separate package let you tomorrow you are going to create another fine okay or two or three Excel files you are going to create so you can put all these files together inside this particular package inside the test data package okay and I had this particular test data XLS file okay now we have Apache PI API we have the utility XLS underscore reader now we have the data also in Excel files okay now I know that so what we have to do so in selenium sessions we have covered that the registration page so we will take that particular code from there I'm not gonna waste my time on these things so we is I think in locator concert yeah we took this code right so we will take this code till here okay right so we have system property for google chrome launched google chrome and enter this particular URL so that we will be on we will directly on this particular page so let's run it it's working or not till here and click on java application and chrome is getting launched okay so I'm on this page now now my responsibility is to fill the data okay and but data is coming from where X in five no see okay okay now what I have to do first I know that this is my utility that this utility already created and it's already available in my package and this is a simple class so what I will do I will create the object of this particular class so this is my class name so how to create the object of any class and this class is public in nature so I can create the object let's see my class object name is reader is equal to new Excellus readin okay so Excellus reader reader is equal to and what is this reader reader is the object reference name reader is not the object okay this right hand side is the object remember Java classes okay functions in Java okay now this Exodus reader I have to import because it's coming from different package so I will import it okay and it's saying that we have to give the pot what exactly the part where exact the path of your excel sheet so I know that my path of the excel sheet is this and go to properties and this is what my path is available over here so I will copy this path and I will paste it over here okay right so XLS Reader Reader is equal to new excels reader and inside this particular object okay we have to give this particular half a bit s dot XLS file path in your case it will be C dry D dry or whatever okay in my case this is the folder structure I'm using okay so this is a excellency eater constructor is already created which is accepting one string path okay so okay to make the connection with the excel file through file input stream so we are not bothered about what exactly the code we have written over here forget about it so the concept here is we just need to use the X we just need to create the excellence reader class object and path the excel file path over there that's it now the connection has been established now what we have to do we have to read the data right so how to read the data so by using this object reader object name we have number of methods which can be accessed okay what are the different methods all the methods which are available in excellence underscore reeded plus remember how to fall okay a class method to call to call a class method we have to create an object on that particular class remember functions in Java if you want to call a specific method or a specific function okay you have what you have to do you have to create the object of that particular class if that particular method is a static then you don't need to create the object by class then you can directly access but all these methods are non-static okay all these are non static methods I have not written any straight keyword over here so we have to create the object of that class so that's why I have created the object of these this particular class and by using this class we can access all the methods which are available in Excel is on this foreigner class okay now I want to read the data which data let's see I want to read this particular data what is the data is available okay on first name what is the first name column value the first name column value is top so I want to read this data okay so how to read simple we have one method reader dot get cell data okay this is a method get cell data okay and it's asking three parameters we have to fire what is your sheet name okay so my sheet name is what my sheet name is this registration tells data okay so just copy this and sheet name we have to pass this is my sheet name what is your column name from which column you want to read I want to read it from this particular column so guys please copy and then paste don't write it manually and this is my column name okay and what is a row number from which row you want to read the data I want to read the data from second row so what I'll pass I'll pass two over here okay so what exactly this method is doing see if you press control and click on it so this is a method I have written over here to read the data from that particular cell okay so no need to bothered about what exactly this code is doing this is a standard utility is already created you nobody will ask you that please write a utility this utility there are number of utilities are available you can download and you can use those utilities no need to waste your time on these utilities your job is to just get the data from that particular cell that's it okay I am NOT working for Microsoft Excel that where I'm going to write am Excel automation or something like that okay obviously so this is not part of my duty my job is just create a utility which is or use some existing utility and call that particular method and then get the data from that building of method by calling that method okay so get shell data I have called and three parameters I have fast so if you mouse over you see that get cell data will give you one string this is a return type so I will store in some string variable string and what is that IAM storing in like this first name is equal to this string first name is equal to this right and let's say I print a system dot dot println first me right what exactly it will do it will okay so what I'll do I'll do this stuff okay reading the excel file and everything before my chrome execution before starting the chrome okay because unnecessary it will open the browser first so what I'll do meanwhile I will comment this code unnecessary it will execute the Chrome browser and everything so we are just making the connection with excel file and get the data from this particular cell from this particular sheet from this particular column and second row okay so first name this column and second row first column second row it means tom will be given okay Tom will be passed so I printed it okay so let's run it so if you run this program see it's giving Tom can you see the output is giving Tom simple okay say similarly what I will do I will get all the values from different columns okay I have different columns and we get all the values from different columns the column name is last name so I just need to change to last name and the row number row is always second address 1 address 1 then address 2 then City City then state state and two more is the zip code okay zip code and email address take email address okay and I'll change the variable first name um we are storing in first name last name I'm storing in here last name this is my address 1 this is my address - this is city this is state this is zip code and this one is email address okay so all the values from the different columns I have taken and I'm printing on the console to make sure that ok everything is fine all the values are coming properly or not so let's run it and you will see that output is coming a Tom Tom Tom why we have printing first name first name you have ok sorry guys last name you have to print exact variable last name address 1 address 1 address to friend address true city city state interstate zip code friends of course email address email address ok now let's run it see all the data is coming Tom Peter to a new Street downtown Sunnyvale California this is a zip code and email ID okay now we have the data data is available okay we or data is available in these variables first name last name address one I'll just - okay now we have to fill the data that's it what we have to do we will launch then we will write a selenium code so we will launch our browser and okay Chrome browser enter the URL okay just enter the URL and what we have to do same thing exFAT and all those stuff so we know that okay let's see four we will use this code first name last name address one okay I'm not going to write ok these techniques you already know that how to read Excel I am how to get the XPath and everything so without wasting time so what I do by classicism we have to import okay now first name send Keys what what exactly you want to send so I will remove this hard-coded value and my first name is this so I know that the first name is this first name okay and remove this and this is my last name and address one so I'd remove this hard-coded value and pass the variable Xactware even address one right same thing for address - what is the address - XPath address - okay I trust to what is therefore city for city is this okay so I will take this X but these are not you know quickly I am doing all these expert stuff because these things we have covered so many times so I'm not gonna waste my time and these things so this is my city Vivi to be where to pass city variable over here and after that we have to pass the state okay so let's okay so a state we know that it's a select we have to use the drop down techniques so how to remember select class select select is equal to new select so how to select the value from drop down by using select class 3d object and select class import it from selenium okay please refer that video okay or how to select the values from drop down and we have to pass the element what is the element driver dot find element by dot X path X path of select so this is select X but state X part and then what we have to do select dot select by visible text and which text this particulars state whatever the state California we are getting you have to pass it over here okay so we are not passing California directly we are passing state the state is coming from excel file and an excel file we have already written California okay now for zip code it takes path of zip code support is this so I'll get the X path of zip code and then copy copy this thing and paste it over here zip code also have pasted and then what we have to fill zip code value we have to fit see be careful while passing the variable okay and the last thing is we have email address right so and get the email address and this is my email address XPath and email address is this okay now see we have one more column verify email address for reenter email address so obviously no need to create a separate column in excel file because both the values will remain same so what exactly we need we just need this particular XPath okay so we will copy this thing this is for reenter email the first one is the main email this is for the email and this is for reenter retype email and i know that both the values remain same email address and email address will be same because the actual email address and the confirm a confirmation email address both both the image will remain same so no need to create a separate column in excel file okay now this thing is done so I'm fetching the data so this is my preparing the data and fetching the data so I'll write get test data from excel so till here I'm using and this is nice we have driver code right so first prepare the data get the data from excel file create all the variables okay on the basis of what exactly the sheet name in column name all these columns from the second row tu-tu-tu-tu-tu okay because we are getting from the second row is we have created third row then you will be writing third row okay and then whatever the value you want to fill just pass all the variables so see I have removed all the hard-coded values tomorrow if you want to run with some different set of data you can execute it so let's run it and then check it's working or not okay so it's launching crop up and see see you can't ring Tom Peter and then it didn't select okay that's fine some problem let's see what exactly it's saying my third expert state what Oh see double slash is missing okay copy mistake problem anyway so let's run it again so it was like that I missed one forward slash so one more /p have to put and you on it again wait wait wait I'm I'm terminating with here also be applicable yeah I'm putting it over here maybe copy mistake either okay so let's sit on it again let me close the existing browser first and then run it again so and first name there's and okay and reenter also email address also gentling see okay and it's entering all the values ok whatever we are passing from the excel file right whatever we are passing from the excel file now tomorrow you want to you don't want to use this particular data you can change the data from Tom to David or whatever may be you know you know Reshma or whatever the name you want to give you can fill the value but the problem here is let's see if you have different set of data right let's see I have something like this okay for set of data with a different name let's see I'm writing Reshma okay and let's your last name is Kay I narrowed last name is D and green last name is whatever I don't know writing this is some name like this and let's see city is for all of you is Unni Unni let's see for Pune and okay so let's City we can write but let's see let's make it an email only otherwise it will not select California una is not in California so the address is something like this let's see 13 new street 14 new street right and then 15 new street like this and Zippos good also we can change it to 86 eighty-eight and email address also I'm writing like this test one okay some different data and grading actually there's two there's three tests for okay so this is a data I have prepared that I have to register these four users right you can register hundred of users I have to register these number of users fine now what we have to do we have to according to this approach then we have to create again for a second row and for third row and fourth and fifth row and how many rows are there till here from second to fifth row we have two who write this particular code again and again right like this and copy this and then I'll paste it over there and then I'll pass the third row and create a different variable first name one first first name - first name three firstly info first name pipe so unnecessary number of variables I will create unnecessary number of lines of what I have to write so this is a bad approach I should not do that okay so how to parameterize so this is just to read the data from excel file now we will learn how to parameterize your test cases okay how to parameterize your code so simple let's create one more class we are sorry to interrupt but I might need to leave editing I'll send you the recording okay so parameterize test is there and created this okay so everything most of the things will remain same first we need to get the data from excel file okay fine know what we have to do just check this concert very carefully we know that how many rows are there five rows are there but the actual data is starting from there from row number two right so if I can do one thing that if I can provide on for loop here okay I can provide one for loop and my loop is starting from number second to door number five right and my purpose will be solved and for each and every row one by one I'll pick the data and then I'll enter the value 1 by row one by one pick the value from the second row then third row then fourth row and then fifth row so in four blue pile it starts something like that I equal to 2 then 3 then 4 and then 4 4 and 5 from row number 2nd to 5 something if I can do that then my purpose will be solved so how to do that the exact thing you have to do in your in your life projects okay in your application in your company write what you have to do so what if I do first okay and start my for loop but before that for loop we have one method so this reader object reader dot get row count method is there C and what is the sheet name machine name is this okay get row counting reader dot get row count method is there so get row count what exactly it will do get row count will give you an integer the total number of rows Gautreaux count means row to row count total number of rows how many rows are there five rows are there it will give you total number of rows okay so I will store in some integer variable let's see row count is equal to this so get row couch give me the row count of this particular sheet this is the sheet and total number of rows are 5 rows are there and stole some integer variable okay so total number of row count is available and then I'll start my for loop then int and start one variable instead of I I'll write from proper in let's your row or row number is equal to two I know that I'll start my row number equal to 2 why because I have to pick the data from second row right I have to pick the data from second row if I write row number is equal to 1 then it will pick the data from first row I don't need first name last name these column names I don't need I need the actual data from second row right so that's why I'm creating one variable int I equal to 2 or better I'll write draw number equal to 2 and then I less than what I less than 5 simple I'll write row number okay fine sure sure hello yeah okay sure richness okay so row numbers sorry participants but over number equal to 2 and row number less than equal to water less than equal to 5 so instead of fight can I write like this yes row count and row count will give you the exact count that you tomorrow row count is equal to 6 there are or tomorrow row count is equal to 10 there are 10 rows are available right so simple I will pass and so instead of 10 every time I'm getting some value get row found if there are 5 rows it will give you 5 there are 10 rows it will give you 10 right to row count less than equal to row number is less than equal to row count okay then whatever the row number is there and then a little easier row number by 1 plus plus simple instead of IEC I am using I insert of I am using row number okay to make it more appropriate name okay so roll number equal to 2 so my loop will start from row number equal to roll number is equal to 2 and then we're on am less than equal to row count y less than equal to I have written because I have to pick the first value also the fifth row also the last row also I have to pick so the row cover currently we have five so row number is less than equal to 5 so I have to pick fifth row also and then row number plus plus like this okay now what I will do I will store my variable reader dot get cell data what is your sheet name my sheet name is this okay what is your column name my column name is first name okay and what is your roll number my row number is this whatever the counter is going on this is my row number right so reader dot get cell data registration test data is my sheet name first name is my column name and row number is equal to two so first time loop will start okay roll number equal to two and then it will give you two and and store in some variable let's see string first name is equal to this and I'll print it system dot out dot println first name CS try to understand okay and I'll explain it again simple roll number equal to two row number less than equal to row count and row count is this this is my row count right and and then I'm fetching the value from that particular cell reader dot gate cell data is a method from this particular sheet from this particular column first name column and my math and row number from which row second row and what is the value of random row name is equal to two or maybe I will write I equal to 2 so I'll pass I over here and Rona misuk to means first kind row equal to roll number equal to two so give me the value from first name and second row it will store in this particular string variable and I'm printing it so let's run this program so what exactly it will do first time row number equal to 2 it will pass 2 over here and it will read the data Tom then row number and then row number plus press so row number will be 3 so random will be 3 and then it will pass 3 over here and then it will fetch the rate of this regime ax and then any root and then um read something like this right let's run it see it's giving the first first name first name values tom reshma an arrow then Ambreen and it's taking the value from second row tom reshma an arrow and Ambreen it's speaking the data from first not the first row from the second row right so this is also fine now similarly and get the data for other attributes so let's copy paste these things we have already written this thing and instead of this two and pass simple row number okay see so first time Grover number equal to 2 you will be row number will be initialized by 2 and whatever the values are available at the second row all the values will be printed then next time row number equal to 3 whatever the row number will be initialized with 3 then whatever the values are available and on third row then third row will be printed and 4 and then 5th right the row number is equal to roll number is equal to 6 6 less than equal to 5 condition is false it will come out of the for loop okay so let's run this program let's see it's running or not see if you see the data it's printing all the data okay it's printing from Tom Peter Sunnyvale California this is the first set of data then we have this is a second set of data okay then we have data for on a road and then be a data for Ambreen like this right so let's see if you want to make it more clear something like that system one or more println let's roll it see it's giving you separate data set of data this is for Tom this is for rasma this is for any road ok and the data is forth on gene right now we have 4 different set of data we have got so the data part is done get test data from excel file and this is called parameterization by using for loop for parameterization is always done by for loop ok this is called parameterization so parameterization is done okay fine now we have to write our code so simple this is my code webdriver code okay and we will write our code inside the for-loop C then I'm launching inside the for-loop only because we have to pick write the data one by one then chrome and URL launch and everything enter all these values one by one okay and that's it so let's run it again now see first time it will launch it will enter all the values first name last name blah blah blah and enter okay now see for second set of data it will enter the value which okay the error is there or maybe some okay for second set of data it's printing the data see a narrowed 3d and other things okay and then again for third set of data it will launch the browser for Ambreen this is last set of data right what I'm doing so if you see this is for Tom right this is for Rashmi this is for an erode and this is for Ambreen but the problem here is it's every time it's launching for browsers because for set of data is there four rows are there let you tomorrow 100 rows are there then it will launch 100 browsers right so this is again we have to optimize our code so how to do that what I'll do simple I'll pick this particular code the launching the browser code I am launching the browser inside my for loop right so I'll remove this code because again and again it's launching the browser so what I'll do I'll write this code above the for loop so this is only one time activity that this opened the browser enter the you URL pick the data from excel file and then enter the data okay enter the data so naughty to launch the browser again and again right otherwise let's see there are hundred rows it will launch 100 browsers let me close all these Chrome's and run it again okay getting a point so this is a webdriver code simple just immediately immediately after coming inside the main method I'm launching my webdriver Chrome get the data from excel file and then I'm starting my for loop and for loop just get all the column values and share all the values in the respective fields on the UI by using selenium webdriver code right now let's run it so it's launching the browser first name and first value Tom Peter and this one now see the problem so you let it run completely and tell you what is the problem that's a biggest problem see it's entering first time it enter Tom CL first time it enter Tom like this and fill all the values then immediately after that again it will try to enter a Sh'ma so ideally it should it will remove tom it should remove Tom and then it should enter Tom its render Asma right what exactly is doing now first it's entering tom and then it's entering Reshma immediately after that then it's entering any route immediately after that and then it's entering Ambreen like this same thing for tom last name is peter for Ray's my last name is K for any road last name is D and for um Dean last name is T so everything is getting concatenated everything is getting merged so how to resolve this problem right so what we have to do so the first time we are entering dom.find and we'll fill all the values of tom first name last name of tom city address and everything fine in the second set of data now I'm going to enter a narrow or asthma so what I'll do I want to remove this form first and there in duration and then enter the okay whatever the rasma attribute will be at the field and then third time what I have to do I have to enter any road so again I will remove Reshma from here and then I'll put an arrow here okay for all the elements I have to do that so how to do this thing do this thing first we have one method clear method so whenever you are using sendkeys method ways right so before send Keys we have to write this particular line dot clear not clear method and then enter the value okay clear and then enter dot clear okay and same thing for address two dot clear same thing for city dot clear okay but for the state we don't need to clear it because the state is a drop-down clear method is only applicable for next fields suppose first time left it will be California and same second time it will be New York third time it will be some other New Jersey or whatever it will select from a different different dropped of different values from the drop down okay but for send keys for zip code also we have to do that so whenever you are using send keys always it is a good practice first clear it and then enter the value clear it and then enter the value okay and for email address also dot clear and for email address to also dot clear okay so first I'm clearing the value and the rental value clear the value enter in the way like this and that should on it now see it's launching the Google Chrome now see the value first time it will enter Tom okay values of Tom then it will clear the value and raise my and all those thing and then foreign erode and then what I mean one by one so it's not concatenating it's not right appending with the previous value so every time it's clearing the value and then it's entering clear the value entering clear the value and enter right this is called parameterization okay this is called parameterization first three steps get the data from excel file and make sure you're launching your web driver out of the for loop otherwise every time if there are hundreds of data hundreds of rows are available in your excel 500 times Google Chrome will be launched okay so avoid this particular mistake and then get the data create all the variables first okay create all the variables and then for loop always remember guys for loop should start with row number two because the actual data is present okay and do number two okay so this is the thing you have to do and then and then you have to fill the data but filling the data also first clear the value and then enter the values clear send keys clear send keys always remember whenever you are using send keys in any program first clear it and then send keys sometimes what happens sometimes some default value is already available we see some you know web pages some forms are available where some values are already available in text field let's see this is the page first time I'm opening an Umbreon is already written what you have to do first we have to remove Ambreen first name here and then you have to enter the value this is a good practice lets you some thing is already written now you want to enter Naveen so what exactly it will do instead of removing this it will enter like this this is not my expectation my expectation is does remove Naveen for a test first and then enter Navi okay so this is called parameterization okay and how data-driven approach this is also called data-driven approach used to create data-driven framework or in some other what we call it data-driven frame of also data-driven means driving the data from excel file some other resources so why it is called data-driven data at a time of interview they will ask you what is data-driven data-driven means driving the test data from excel files or some files this is called data-driven approach or in other words we say parameterization data-driven is also called parameterization okay fine so please practice this particular parameterization code it's really really important in every project you will be using this thing I'll send I'll send you this excel sheet or Java class I will give you a link from where you can download this accelerated or Java no need to understand this particular code that what exactly I have written okay no need to do that you just need to use this class and try to create the folder structure with the package structure like this and maintain your excel file in this particular thing also in the next session the parameter is a data-driven part too I'll tell you how to write the data in excel file okay how to delete that sheet how to remove the sheet how to add columns and how to use the excel sheet concept we'll test mg okay that is the second part of session so in the next session we will cover those things okay the parameterization of your ad the rate test annotation how to do that what is the data provider in exchanging all those things we will cover in the next session okay so that's all for today and I'll see you in the next session then
Info
Channel: Naveen AutomationLabs
Views: 190,023
Rating: 4.8842974 out of 5
Keywords: Data Driven Framework in Selenium Webdriver Part 1, Data Driven, POI API, Apache POI, keyword driven framework in selenium webdriver, what is data driven framework, data driven framework in selenium guru99, how to read data from excel sheet in selenium webdriver using java, difference between data driven and keyword driven framework, hybrid framework in selenium webdriver example, how to read data from excel in selenium webdriver using poi, Naveen AutomationLabs, Selenium WebDriver
Id: sSNqjNzaP6s
Channel Id: undefined
Length: 61min 49sec (3709 seconds)
Published: Fri Sep 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.