what up everyone welcome back to the channel Jahmal here and in today's video i'm going to
be showing you how you can get started with the combo framework scenario outline so the scenario
alkaline keyword can be used to run the same scenario multiple times with different combination
of values so this is what we're going to be using today so what we're going to be doing is taking a
look at these two scenarios so given that it is 12 cucumbers when i eat 5 cucumbers then i
should have 7 cucumbers in the next scenario um eat 5 o'clock given that i have 22 combos
when i eat five i should have 15 etc etc so what we're going to do is collapse these two similar
scenarios and put them in a scenario outline instead of having these two expanded scenarios
we can compact it and make it reduce and look nice like this so with the examples you can see that
this is how you set them up the scenario outline is run one for each row in the example section
and you can use these delimited parameters to store your values and get your thing parameterized
so enough of the yapping what we're gonna do is just hop back into the eclipse and we're
gonna get this tested and pretty much set it up just like what we have here on the example page
but we're going to be using our own website and get going so let's hop into it
all right so what i'm going to do is just launch eclipse and we're going to continue with
our gherkin test and project i'm just going to close this previous project i've been working on
so what i'm going to do is hop over to my feature file and i already have it open
so we're going to continue where we add some other scenarios so in here i have of two scenarios in my
feature currently the user clicks on the last of people and selects the silly key peak and i
also have another one just using the debug tag and pretty much the same scenario so what we're
going to do is we add a third scenario and this is going to be a scenario outline so i'm just going
to put scenario outline give it a number of three and in this testing we're going to say the user
clicks each category on the home page all right so that's going to be our test for today i'm just
going to launch that website so we'll be back on shop.angularplus.com so this is the home page so
once we're here we're going to click each of these categories the canvas the luster and the acrylic
prints so that's what our test case is about today so i'm just going to reorganize and get my screen
set up nicely so there we go i'm going to start off by saying given the users on the home page
next we're going to say when the user clicks the category and then we're going to use the
category tags so this is what we're going to be using to input our values from our example table
all right so next what we're going to do say then the page breadcrumbs displays and
we're going to end with the title tags next i'm just going to start building my examples table
so we're going to do is add this pipe and then say category
this pipe symbol and then title piper okay so that's how you're supposed to set it up
and now the for the category i'm just going to go back to the home page
and we have canvas luster and acrylic so i'm just going to go and inspect this page and just grab
these text so we have canvas print the next one is luster paper and then we have acrylic prints
all right i'm just going to add these um titles
in my table so i'm just going to say canvas print next is the title so for the title
what we're going to do is simply just click on let's say the canvas prints
and we're just going to copy this breadcrumb title at the top and it says canvas prints
next we have the lust of people
i'm just going to put luster paper here all right that looks good next we're just going
to add the acrylic prints and then add the acrylic print type acrylic prints title
okay let's give it some space make sure your formatting look good and i think we should be
ready to go so now we're just going to make sure all these pages look alike so acrylic prints
we have lots of prints acrylic prints what you want to do is just simply click save now we have
these yellow indicators letting us know that our step definition is not found so what i'm going to
do is i'm going to comment these two scenarios at the top and i'm going to click save again
all right now we reappeared so this is letting us know that we don't have these step definitions
created so what i'm going to do is just simply click run as and run as a cucumber feature
but now it's showing me that i have an error so it's showing me that my
path has been changed so i'm going to go to the feature i'm going to go to run as
run configuration and under the feature path i'm just going to make sure that everything looks
up-to-date make sure my feature is very supposed to so i'm going to do is yep now it's on the git
folder so i'm just going to update my feature path i'm just going to copy my new location
and what i'm going to do is head back over to the feature run run configuration and what i'm going
to do is update that feature path and add my slash okay that looks good so now everything is good i'm
going to hit apply hit close i'm just gonna clear the console and if i run as a cucumber feature now
everything should run all right there we go so the browser launched so now we have our
statements brought back that look good we do have some exceptional tone at the top it ran the given
statement since we already have that created so just try to do some work but um you can
see that there was some nulls on the other steps right okay so that's why that's fine but what we
want to do is pretty much scroll down and what we want to do is copy our new step definitions
this is what we need and what you want to do is just copy and then you want to put this
inside of your step definitions so i have it in comm jamal step depths i'm just going to pay to
paste it towards the bottom that looks good i'm just going to get rid of these generic statements
all right that looks good what i'm going to do is just get my screens resized so i can get ready for
my scripting and capturing some of these elements
all right so i have my feature file at the bottom step definition to the top
so i'm ready to go so the first thing i'm going to do is start defining a new element
i'm going to call this category canvas prints
and this is equal to driver.find element i'm going to use by dot xpath
okay that looks good and to speed things up i'm just going to copy this
and paste it into my other similar categories so the luster and as well as the acrylic
and now what i'm going to do is just hop over to my google i'm going to inspect and put my
pointer over the canvas i'm just going to get that x pad for that i'm just going to paste it in here
all right next i'm just going to do this for the other two for the luster paper now acrylic so i'm
just going to speed through this real quick it's just the same process i'm just going to
copy the x pass and paste them in all right now that we have all our category elements
defined what we're going to do is just going to copy the category canvas prints at a dot click
um function to it all right next i'm going to do this as well for the luster let's copy and
click and i'm going to do this for the acrylic all right each of my methods now are clicking
on each of these elements so that looks good next we're going to work on the breadcrumbs
so what i'm going to do is create a new element and i'm going to call this element
breadcrumb canvas and this is going to be equal to driver.find element and i'm going to say by.xpath
and again i'm just going to copy this into the other statements as well
so i'm going gonna do is copy the xpath and then i'm just gonna paste it in my element
all right so now i'm gonna do the same thing for the last of people i'm gonna inspect it
and since it's in the same position and we're using xpath
i'm thinking x path may be the same but i'm just going to paste it and let's see
all right so it is the same so yep it's in the same position so these expats are
definitely the same so what i'm just going to do is just scroll down towards the bottom and
i'm going to paste that x path right there as well i know that looks good
now that i have that what i'm just going to say is breadcrumb that is displayed
and that's just going to make sure that these are in fact displayed next i could just add a simple
asserts um true statement and we're just going to import my assert true statement as well and then
i can just say canvas page displayed and then i can set the other parameter as true okay and we
can copy and paste this for the other as well so i'm just going to speed through this really quick
all right everything looks good now now i'm just going to be ready to do our tests
so given the users on the home page that's what we're currently at now
when the user clicks the category so you're going to click the canvas to lost the andy acrylic
each of these under the category section and then the page breadcrumb displays we have the title
canvas luster paper and acrylic print okay and what i'm going to do is simply
click right click and do run as and i'm just going to do a junit test
all right everything launched
now i was really really quick so everything just ran the browser didn't close that means
my after step is probably disabled but that's still the beauty of that scenario oakland
it did three scenarios in just one scenario it just keeps everything nice and compact for you
all right so what i'm gonna do is just simply add some weights after these clicks so we can
run that test again and we can see um these the three scenarios being run
because it ran really quick the first time so i'm just going to slow it down a little bit so it may
take a little longer but we can actually see it open up my hooks class and in here what i'm going
to do is i have my b4 so inside my b4 annotation all is just doing a set in the driver for me
i have some of these other steps disabled so i'm just gonna uncomment my after so after the
the test run what it needs to do is just quit the driver and then restart again and then fire
up a new driver so let's see what happens i'm just going to click run run as and run as a junit test
all right so it launched so now we're on the canvas page we see the way it's working
and now we have an exception okay so we have two field one pass so the second scenarios didn't run
we have an issue with the session id is null so something with the drivers happening so let's take
a look at that what i'm going to do real quick is just make sure that the after method is working
all right now that we added back the after class that's going to start to
act a little funky what i'm going to do is uncomment my first test scenario
and i'm just going to change this to test2 and i'm just going to run as a junit test
and let's see let's see what happens this time so it's launched it's running
we got to the silly peak print that's what that scenario wanted and it closed the browser
okay so our hooks and everything is running x how we expected but now that we're using the scenario
outline and the browser is closing and relaunching i have to add some more logic
so i'm just going to say if driver equal no um build a driver else just
use the existing driver next and after class what i'm going to do is add another if statement as
well so in here i'm just going to say if driver is equal null let's say return get out of this method
if not quit the the driver and set the driver to null all right so that's what that's going to do
and i'm going to hop over to my driver manager and i'm going to take out this logic since my hooks is
already doing this for me and i'm just going to format this a little better all right everything
looks good and i'm just going to click save all right so with those changes what i'm going to do
is change my tag to test 2 and give the scenario oakline another run and let's see what happened
all right so the first scenario ran now we on the lust of people so that's good and lastly
we're on the acrylic prints everything is running exactly we did not get that exception
which is good and now we have our pass it took about 20 seconds for this to execute
but that's how you can set up your scenario oakline and that's the beauty of the scenario
outline so there you have it everyone that's how you can get started with the scenario
oakline and this is one of the examples we just did in my next video i'm going to touch base a
little bit on the document strengths and set up a scenario alkaline with that as well but that's
pretty much it what i'm going to do right now is just simply take out these weights fire up
the test again and that's how you can get set up with your scenario outline using your cucumber
framework making sure um making these slight edits and changes to your hooks as well just
to accommodate for the multiple runs and setup so if you guys found this video helpful please
feel free to smash the like button subscribe to the channel and i'll see you on another video