Cucumber - jvm (Cucumber Options) with Selenium WebDriver - Part 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to selenium and click member training surveys in the first session we have already seen that what is what do you mean by behavioral driven development and what do you mean back to humor and how to create feature file step definition file and the runner class and how to create the scenario and everything with the help of gherkin keywords and ok and how to write the same thing in a step definition file in the form of selenium in Java code and how to create the reader class with the ok with the couple of options and how to execute your you know first cucumber class and first cucumber test case and how to generate the report and everything some basic stuff we have seen ok so today in this particular topic I am going to cover another important topic which is very important for your framework point of view your project point of view as well as your interview point of view also definitely they will ask this kind of question if you are going with cucumber I mean we applying for cucumber with selenium and definitely they will ask ok what are different cucumber options are available okay so today I am going to cover in this session cucumber options ok so there are different remember options we have so first remember option we have that is called drier okay I'll tell you what do you mean by clicking bird options and everything features that we have already seen what do you mean by features we have another one is that glue ok then we have these other timber options are available tags after that we have another very important that is called monochrome okay monochrome is available and then we have format what kind of format of a report you want to generate and then we have split okay so definitely they will ask you at a time of interview okay what are the different cue more options are available and what is the purpose of each and every option they might ask you this question definitely and you can implement these options in your framework also okay so II all these things will be defined over here okay in your honor class in your underclass it will be defined okay all these go Kimber options okay this tag only this particular tag okay how to define the tag and everything you have a defined all these tags in your feature file I'll tell you how to define that okay in your feature file okay but all these we have to make sure that okay all these entries of for all these options we have to define inside the run little as how to do that let's do it one by one okay so so so far yesterday we have seen this is my login feature dot feature file I have created and all these things we have written and one step definition file also we have written with all these annotations and everything the proper steps okay with respect to the login dot feature we have written and this is a third component that test runner dot Java I'll better I'll move it over here so this is the first component then second component and then third component or under on Java that we have created now let's see what our other options are available so first option is that is called dry run what do you mean by drier and drier and means if you really want to check that all the steps that you have written in your feature file okay let's see you have written around 15 or 20 or maybe let's see 100 we are you know steps you have written so so far we have written only one two three four five steps we have written let's you tomorrow we have ten steps or 20 steps and it's really difficult to manage that okay I mean sometime it happens or okay that we have to make sure for each and every step there is a step definition a notation that we have defined it's one-to-one mapping right right so at least for every step at least one annotation is available or not what happens I see I have written 10 steps or 20 steps some time what happens that I forget to write B forget to write the specific method the specific annotation we forget let's see the user is on home page okay then user is on home page this annotation we have written over here that user on homepage let's see I forget that I didn't write I miss that let's see let me comment it right so how many step definitions are there I mean how many steps are there five steps but how many step definitions I have written over here only four it means I missed something at the rate then user is on homepage I miss this particular step in step definition class okay and you never know so what exactly you'll do immediately you will do a dryer and dryer and means simple just check immediately that looking everything is fine or not whatever the the mapping is perfect or not between feature file and the step definition file okay so again I'll write one comma and simple you have to write simple dry run is equal to true if dryer an option the Specht this particular option that you have to use under add the rate remember options okay a dryer an equal to two if your dryer is equal to true immediately if you try to run it it will not execute your test cases immediately it will check the mapping it will check the mapping it will test your mapping is correct or not simple so if you run it okay see immediately all the test cases it's not going to execute it will simple say that okay yes for that particular feature okay all three or four or five okay the five mapping is perfectly fine and everything is green okay but ideally it should give you currently it should give you error that we have not defined that user is on home page just a minute let me check why it is not giving error I delete should because we have commented that particular line already right okay so what exactly happening guys if you dry run is equal to true it means it will check the mapping is perfectly fine or not but it will not give any failure in j-unit report so in the output if you see for this particular step we have this particular method for our title of login page is free CRM H of 11 over here this method is available over here for third step method is available for fourth step method is also available over here you can see that user user clicks on login button this is a method that we have written and the last step is user is on homepage but the method is missing over here so immediately you will get to know that which method is missing okay for for which step the method is missing so let's see I will comment this particular line also okay now if I run with dryer and equal to true let's run it again now you will see that for two steps for this particular step it is missing and for this particular step also this is missing so immediately you will get to know that okay these two steps are ok the step definitions are missing for these two steps so immediately you will write the whole for that so it will really helpful it will be really helpful at the time of ways when you have n number of steps are there because right now I have just written only 5 steps for login feature lets do tomorrow you have the complete framework and so many features files are there and so many steps are there in that case right and so many scenarios are there in that case so definitely it will help you okay guys moved aside there it is smoke I will tell you later what is this so it will really help you which step definition you missed ok so this is the purpose of dry run and they will ask you at a time of interview and once the dry run is true and everything is fine you make it false simple and once you make it false then then if you run it then it will execute your test cases ok see it will execute a test cases launching the browser so always make sure that ok dry run is equal to false so that you can execute your test cases if dry run is equal to true in that case always it will be it will check that the proper step definitions are missing or not or proper step definitions are you have written or not okay with respect to each and every steps available in login dot feature file right so this is a good practice always make it first time dry or equal to true executed check everything is fine then make it once ok cool let me uncomment these things sorry okay now what I have to do another is after dryer and let me close this browser after dryer and we have features so features we have already seen that features means this is the features features means base features means what where exactly a feature file is available so you can give login dot feature on whatever the feature comma-separated values also you can give if you have five features or something like that you can give five features names also or you can give the folder name also directly okay under your okay in which folder in which package it is available you can give the direct package name also you can give okay so this is about features that we have already covered now the third option is Glu Glu means it's very important okay simple that we have already written meaner yesterday the glue means we're exactly our step definitions files are available so my step definition file is available in this particular package or maybe some folder or may be the complete package path you have to give so step definitions is a package name that we have to write it over here so glue means the path of step definition file okay so I'll write this is what I'll write in commenting form this is for features means the path of the feature file okay Glu means glue means the path of the step definition files right they will ask you at a time of interview and you have to explain like this the path of the step definition files right after that we have after glue we have tags tags I'll tell you later after some time monochrome another one is monochrome monochrome means display the output in a readable format okay see right now we are getting this particular output fine if you see that we are getting this 32 32 M right you can see the 32 M 32 M sometimes we are getting this 90 M hash 0 M okay with these brackets on all those things so it is not very much a readable format and if you see the output also one scenario 33 M 1 define 0m so these random numbers are coming right undefined in all those things so these are not very readable format so to make it more readable okay the output if you want to make it more readable in that case you have to use monochrome so I'll be using monochrome monochrome is equal to you have to set it monochrome is equal to 2 if monochrome is equal to true it means it will generate pretty output okay it will generate readable format output okay so the what is the purpose of monochrome monochrome display the console output ok display the console output in a proper readable format okay so this is a readable definition okay okay so this is the purpose of monochrome now let's run it let's see how exactly is generating output No so if you see test case is are running it's launching the browser it's fine and and if you see the output it's printing on the console and see it's no it's it's not showing on the one test case got failed remember that we deliberately passing that ciear MPR oh one two three remember in the first session okay so obviously this particular test case is getting failed deliberately we are making it fail because our solution is getting failed we were expecting one two three but it's you adding some CR MPR only but if you see the output now it's very pretty much output pretty output with this particular that given user is already at login page and this is the proper method they have written write log instead definition dot this this is a method name and there is no 90m or 3m or bracket or something like that now it's not coming right so monochrome is always you have to use guys monochrome means generate very readable format okay generate readable format and so an output it's very very important base ok so this is what we have to use monochrome option internet class that you have to use like this monochrome equal to two if monochrome equal to falsely if I make it false again if I run it it will generate some bad output it will execute your test cases that is fine but it will generate some bad output ok again I will show it to you so it's running the third one see in j-unit it will show you that in which step see again it's giving 32 M or 31 m 90 M hash or something like that so it's not very readable format okay so always make it readable equal to two okay after that we have let me close these two browsers okay days after that what we have after monochrome we have format so format yesterday we have seen that if you want to generate any pretty format pretty format means in the console if you want to generate proper steps like this in that case okay you have to use pretty and if you want to generate any HTML output also in that case you have to use HTML code and test output like that okay fine if you want to generate any JSON output also that okay I want to generate my output in the form of JSON format okay so what you have to write comma here you have to write comma 1 tag is then I'll give you what tag yeah this is the JSON tag okay comma Jason : okay and which file you want to generate in which folder you want to generate let's see my folder name is Jason output slash my file name is 2 to member dot Jason ok so you have to write like this if you want to generate any HTML file you have to write HTML and test output it will generate the HTML report okay if you want to generate your report in JSON format you have to write Jason : this is my JSON output is is a folder it will create automatically and then one file will be created KooKoo member dot JSON file will be created ok so let's run it okay so it will generate one JSON file okay so if you see this it launched it executing the third step and then it will execute fourth and fifth okay how quit is fine test one test case step it got failed I'll go to my package right click on it and just refresh it and you will see that JSON output folder got created Jason underscore output in under which we have one quick umber dot JSON file got created if you double-click on it this is the JSON file okay and this particular JSON file you can use anywhere if you want to share with anyone you can share although nobody will be able to understand that okay what exactly this particular file is saying so if you say that if you see that okay element line three free CRM login test scenario with this particular ID type and all those things keyword they have written and this is a step how much time it got passed okay with this given keyword it got passed this is a title of that particular given keyword it's coming in the form of JSON object and you can show it to any developer already anyone and you can generate some UI also with this particular report most some people they do like that okay they pick this particular jason and then they generate their own UI e to display the to display the report of cucumber output and everything just a put okay they can generate the very good test report also with the help of this particular jason okay so but generally we don't do that I don't like this option that remember adjacent but if it is available then you can tell at the time of interview also if you want to generate any j-unit XML also the reporting XML also in that case what you have to do again comma simply have to write J unit I have that tag name give you yeah J unit and in which folder again let's see J unit underscore XML folder please create and let's see Q member dot eczema I want to generate like this okay so in that case it will generate J unit to come verified also and I'll show you what exactly the format so that's a direct but the runtime once execution is done it will create one j-unit underscore XML so whatever the folder name guys you want to give you can give any folder name Naveen underscore examiner free CRM underscore XML or JSON also you can give any output name or whatever whatever the folder name you want to give okay so if you see that J unit underscore example folder got created and tokuma dot XML file got generated and if you double click on it okay so if you see that this is a it will generate the output like this pass pass pass somewhere I really liked it if you really want to quickly if you want to see that okay which desk is got past failed with step got pass fail it will show you like this given user is already your login page pass second step pass third step password step pass but this the user is or home page got failed and what is the reason this is the reason behind that right so I really like this particular approach somewhere that cucumber or exit and it and immediately I'll check and you can share this report to anyone right so in format format is always used for what format is used today's to generate the reporting formats to generate different types of reporting okay different type of reporting means you can generate and they will ask you type of interviews through quick remember what are different reports you can generate we can generate HTML report we can generate JSON report and we can generate examine report and this is the format of XML report case ok fine so this is option format option is there we close escrow after that we strict now strict is also somewhere very useful how to use stricter strict is equal to what you have to use strict is make it true it means what do you mean my strict strict means it will fail execution if there are any pending steps are there okay let's see you have made it dry around is equal to false okay but if you have written is strict strictly you have written that is strict is equal to true it means what exactly it will do it will fail the execution if there are any undefined or pending steps are there let's see any undefined step means let's see this particular step I have not defined immediately and if you have written like this that string equal to true it means strictly it will follow all the rules the mapping between feature file and the step definition fine okay so if it is currently all the steps are defined properly right right between this and this so obviously it will run perfectly fine so if you run it let's run it again without any error it will run okay although the the last step will be failed because of assertion that is a different thing okay so all the test cases are running fine fine I mean working fine this is the assertion problem because deliberately we are making it failed I'll do one thing let's remove this one two three to make it more clear okay now run it again so that all the test cases will be passed okay let's run it again right so fine it's now in third step arrow is on third step now right this arrow and then all the test cases got passed and you will see that all the steps test steps got passed right and without any failure and you are getting monochrome output also the very good pretty output and all the readable format also we are getting we are getting all kind of reports also a J unit report and JSON report an XML report and index dot HTML also we are getting HTML report and in the Kakuma option if you see that it's trickle to true it means everything is fine it means all the steps we have written properly okay with respect to each and every step the proper strip definition we have written now let's see I'll make this particular thing as a comment it means then user is on homepage I haven't defined over here right and the iron is also let's see once somewhere you are you are not using the iron and we have written the strict equal to true now if you run this program okay guys now if you run this program let's run it so you will see fine it is generate okay launching the browser entering the URL and everything and let's see what exactly it's it okay so strict equal to 2 it is executing your test cases okay it will not like that it will not execute your test cases it will execute your test cases but the user is on home page we haven't defined so it will it is saying that pending exception it means the execution I mean the step definition is pending to do implement me okay it saying please implement so it immediately it will say that you can implement missing steps with the code snippet blow so opposite will give you the code snippet like this that at the rate then user is on home page is missing okay in the step definition fine okay guys so this is important okay so strict also we have to use always okay sometimes that we forget that mapping and you execute it and then in the morning we'll get to know I missed it so better to do it first of all dry run and if still like you're you forget to use a dryer and but still you're making aesthetical to - it means that each and every step properly defined or not and image it you tomorrow you will get to know that okay these are the out of hundred these other ten steps are there that I haven't defined inside the step definition file okay so for that obviously I have to write the annotation and all those things in a step definition file for that particular step okay so these are the different options are available so what do you mean by strict strict means it will check if any the step definition is not defined or I would say any step is not defined inside I would say in step definition file okay and what do you mean well dryer and dry and as I have already told you dry run is to check the mapping is proper between feature file and step definition file the mapping is not missed okay like this so guys they will ask you at a time of interview what are the different compare options are available okay and please explain Lachie glue please explain step definition please explain like monochrome what do you mean my strict okay what do you mean by dryer and right all these things you have to explain like that okay if you are going for face to face also sometime they might ask you at a time of interview that okay okay on paper also encoding assignment also if they are giving and if you are writing any Kimball things they will ask you like this and you can implement like this so you must know about all these quick timber options are there okay in fact in your project also you can use this and if you are joining any new project and they are using all these options so don't be afraid that okay oh I mean haven't covered these things so please go through this thing and then I think it's very very simple lace very simple okay so you can use it and then please try to create a number of features feature files number of scenarios try to create bit different please around 7 to 8 different steps try to convert them into a step definition ok comment it and then with check with our I'll check with the strict option and check how exactly it's giving you the output ok how exactly it's getting failed or not like this you can practice that it's that's why Kakuma is very simple things ok people are so scared with cucumber that ok no it's very difficult and I cannot learn be ready framework or something like that but with all these our format blue features dryer and strict all these are okay all these keywords are available in the form of behavioral ok so that's why this is called behavioral driven development framework and all these keyword gherkin keywords we are using in all those stuff ok so that's why bdd framework is important is getting value you know it's very famous in the market now ok guys so let me close all these browsers ok so this is the second session and after that we will learn that how to parameterize the things with the help of you know examples keyword and data table keyword is there okay what is in our your outline is very very important they will ask you what is the difference between scenario and scenario outline we will cover those things also and then we will cover this tags option also guys okay we will cover this particular tags option also ok this tags or do you mean what do you mean by tax okay so let me quickly cover tags okay I will I'll I'll cover tags in the next session because we have to create multiple scenarios in that case ok so tag is pending and but most of the curricular options that we have covered because in tags we have to use somewhere in feature Phi and I'll tell you how to do that and tag is the most important interview question please ok so that's all for this particular session and then if you really like this video guys please okay subscribe it share with others and other thing is that please don't jump into this particular topic directly now you have to first you have to watch this particular video is this first video kimber jvm bdd framework with selenium part 1 that you have to okay you have to watch and then jump into the second part okay so let me know if you have any issues and you can your questions everything in the comment section and definitely I will try to reply over there okay guys thank you so much thanks for watching and please subscribe to the channel and press the bell icon okay so that you will be notified for that what are the different videos are coming in future okay thank you so much
Info
Channel: Naveen AutomationLabs
Views: 122,182
Rating: undefined out of 5
Keywords: Selenium, Cucumber, BDD, Feature File in Cucumber, selenium webdriver with cucumber example in eclipse, what is cucumber framework, cucumber java step by step tutorial, cucumber selenium testng, cucumber java example, cucumber testing interview questions, Cucumber - jvm (Cucumber Options) with Selenium WebDriver, Introduction to Cucumber with Selenium, Cucumber - jvm with Selenium WebDriver
Id: 9uB7zfN6cAo
Channel Id: undefined
Length: 28min 34sec (1714 seconds)
Published: Wed Nov 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.