Selenium with Java using Cucumber Demo | Setup Cucumber… — Transcript

Introduction to Cucumber with Java for BDD, comparing TDD vs BDD, and setup in Eclipse & IntelliJ IDE for automation testing.

Key Takeaways

  • TDD is primarily for technical users and focuses on functional testing using tools like TestNG.
  • BDD enables collaboration between technical and non-technical stakeholders by focusing on acceptance criteria.
  • Cucumber is a widely used tool for implementing BDD in Java automation projects.
  • BDD test cases are written in a way that non-IT people can understand the test scenarios and outcomes.
  • Setting up Cucumber in popular IDEs like Eclipse and IntelliJ is essential for effective BDD implementation.

Summary

  • Explains the difference between Test-Driven Development (TDD) and Behavior-Driven Development (BDD).
  • Discusses limitations of TDD frameworks like TestNG for non-technical stakeholders.
  • Introduces BDD as a framework bridging the gap between technical and non-technical team members.
  • Highlights Cucumber as a popular tool to implement BDD in Java automation.
  • Describes how TDD focuses on functional test cases while BDD focuses on acceptance test cases.
  • Explains the roles of different team members like testers, developers, and product owners in BDD.
  • Mentions other BDD tools like SpecFlow alongside Cucumber.
  • Emphasizes the importance of writing automation tests understandable by both technical and non-technical people.
  • Outlines the agenda including setup and configuration of Cucumber in Eclipse and IntelliJ IDE.
  • Provides context on how BDD improves collaboration and clarity in automated testing.

Full Transcript — Download SRT & Markdown

00:01
Speaker A
So today is the first session for Cucumber. So first of all, let us understand what is test-driven development and behavior-driven development frameworks. And then I will talk about a little bit of media tools which are available currently
00:17
Speaker A
in the market. And then we will see the basic introduction about what is exactly Cucumber. And then we'll go for a setup and configuration things. Okay, so this is the agenda for today. So I'm going to discuss very basic stuff
00:31
Speaker A
as part of today's session. So first of all, let us understand two things: test-driven development versus behavior-driven development because before learning Cucumber, we need to understand a few basic concepts because we cannot directly jump into Cucumber.
00:47
Speaker A
So first we need to understand why Cucumber is there. Why this BDD framework came into the market, right? So these things we have to be very, very clear. So even in the integral prospect, this is very important. So what is exactly TDD versus
01:00
Speaker A
BDD? Okay, so TDD means test-driven development versus BDD means behavior-driven development. So what exactly is TDD, test-driven development? So let me just give you one example. So in TestNG, we have done Selenium with TestNG framework. We have implemented Selenium with TestNG framework. So as part
01:23
Speaker A
of Selenium with TestNG framework, so what are the things we have created as part of the framework? So we have created page objects, we have created some utility classes, we have created test cases, we have maintained the properties files, we have
01:39
Speaker A
generated the reports, and also we have created different TestNG methods within the test cases. So we have done a lot of things by using Selenium along with the TestNG. Suppose if you are providing this particular framework to some other people or some
01:55
Speaker A
non-technical guy. So we don't know exactly what about Selenium or they don't know anything about Java, anything else. They don't have any knowledge about the technicality. So they're completely non-IT guy. So if you share this particular framework to somebody else, so
02:13
Speaker A
they cannot understand anything. So for them, it is completely new stuff. They cannot understand anything. Even so, they don't afford a little bit TestNG, all these things, and it is also very difficult to understand your framework if you provide somebody else. So
02:27
Speaker A
that's one thing. The other thing is if you just notice this particular approach.
02:33
Speaker A
So here why we are creating this test case, how we are creating this test case, we need a requirement. First, we need to have a manual test case. So first we need to understand the test cases accordingly. We will directly create the TestNG classes.
02:45
Speaker A
Means every TestNG class is considered as a test case. And inside the TestNG classes, we created multiple TestNG methods. Right? So what TestNG methods we created? So why we have created TestNG methods? Because test case contains the steps. So for all these steps, we created TestNG methods within the test cases. So this is a test-driven test development because we already have one test case based on this we have created the test cases directly
03:00
Speaker A
and whatever test methods we created inside the TestNG classes, they can understand only the technical guy. So whoever already knows about TestNG or Selenium, so they can only understand these test cases but others cannot understand them, right? So
03:16
Speaker A
this is basically our TDD approach, just test-driven development approach based upon your test cases. We can directly jump into the test cases and you can implement your test cases. I can run them. So this is a basic approach. But the main problem
03:30
Speaker A
with this approach is only the non-technical people can understand this approach in not a sorry only technical people can understand this approach. Whoever is knowing TestNG or some other programming skill, they can understand what you have exactly created inside the
03:45
Speaker A
framework. Okay, so suppose I want to share this particular framework to somebody else, so they cannot understand this. Suppose they are the non-technical way, they cannot understand this. So I need to fill this particular gap. So my framework or whatever
04:01
Speaker A
code I have written should be able to be understandable by everybody in the team.
04:16
Speaker A
So not only technical people, even the non-technical people also should be able to understand my code. So that's my criteria. So especially if you take a team in your real-time environment, so testing team will be there, developers will be there, managers or
04:21
Speaker A
their leads are there, product managers, product owners, so they are the exact people who are getting the requirement from the business or customers, right? So for those requirements, again, we will convert them into scenarios and test cases, then we do automation. And testers
04:35
Speaker A
or developers can understand your automation test cases, but management level like obviously BU or business analyst or product owner, so whoever is getting the requirements or whoever defines the requirements, they don't know exactly what have developed, right? What are the test
04:50
Speaker A
cases we have created as part of automation? They don't know because they are not technical people, right? So to fill this particular gap, so technical once you have designed a framework, that should be able to be understandable by technical people and
05:07
Speaker A
also non-technical people. So to fill that particular gap, there is another framework came into market that's called the BDD framework. So this is called as a BDD.
05:21
Speaker A
Behavior Driven Development Framework. Behavior Driven Development Framework. So by using this particular framework, we can also design our test cases, everything. But this particular framework can be easily understandable by the non-technical people also. Okay.
05:32
Speaker A
Here TDD we can achieve by using TestNG. TestNG is a framework. So by using TestNG we can achieve TDD. So this is an example of the TDD framework. So TDD is nothing but a test-driven development. It is a
05:52
Speaker A
concept. To achieve that particular framework concept, we use TestNG as a tool. Similarly, if you want to achieve BDD framework, we have multiple tools. So Cucumber is one of the two. And we have also SpecFlow. So SpecFlow is also there.
06:07
Speaker A
So there are multiple tools that are available which will also support BDD framework. And basically in the TestNG, we automate functional test cases. Functional test cases. Whereas in BDD we focus more on acceptance test cases.
06:24
Speaker A
So what is the difference between functional and acceptance? So functional test cases means very detailed level. So each and every validation we have to perform. So functionality of application whether it is working according to customer requirement or not. When you come to the
06:41
Speaker A
acceptance testing, we need to test or we don't test every scenario in detail but we will test the scenarios as a user perspective. As a user, how I am going to work with the application. So only those scenarios will be covered as part
06:57
Speaker A
of BDD framework. So even validations also will be there but those validations not much as like TDD. So TDD is completely functional based.
07:11
Speaker A
Functional test cases we can automate. When you come to the BDD, we focus on acceptance test cases. So these test cases will be provided or will be defined by the BU or business unit or business owner, product owners. So they are defining
07:22
Speaker A
this acceptance criteria. They will prepare the test scenarios, all these things. So TDD framework we can achieve by using TestNG. Whereas BDD framework we can also achieve by using Cucumber, SpecFlow. So now Cucumber is one of the tools which will
07:38
Speaker A
support BDD framework. So by using this BDD framework we can automate your test cases just like a TestNG. But in BDD it can easily understandable by everybody.
07:56
Speaker A
So even the people who are non-IT, they can also understand your test cases and everything. So there's a basic difference between TDD and BDD. So why BDD came into picture? To fill the gap between technical as well as non-technical people. So if you
08:07
Speaker A
write your all testing test cases, everything framework...
08:25
Speaker A
write your all testing test cases, everything framework is implemented by using TDD framework. So that can be understandable by only the technical people. Whereas if you define the framework, if you create your framework automation test cases in BDD approach, that can be
08:41
Speaker A
understandable by Technical as well as not technical people. That's one thing. The other important thing is for example, for example, there are multiple people are working on multiple things. So for example here, who will return the requirement? So
08:59
Speaker A
product owner, so there will be product manager will be there. The responsibilities are same exactly. The names can be different from one company to another company. So normally the product manager will be there. So he is responsible for defining the
09:15
Speaker A
requirements. So product manager. So in the agile process, we call them as epics and stories. So requirement is nothing but a larger requirement is nothing but a epic. And if a smaller requirement means a story. So in agile process, we use
09:32
Speaker A
different terms. So product manager is responsible for writing the epics or stories. That means both are requirements. from where he will get this requirement from the customer. So from the customer, he will get the requirements. So these requirements, so these stories will be provided to the QA as well as the
09:56
Speaker A
dev team. So dev and QA teams should able to understand these stories or epics everything. So developers will develop the product according to their Rex their stories and QA will like over test their stories according to the requirement or
10:12
Speaker A
stories point so here again if you see product manager Product manager is responsible for defining the requirement But our QA is testing the requirements developer is implementing the requirements right? But there is a big gap between these people because QA as dev or the technical people whereas product managers
10:36
Speaker A
are not technical people so they don't know the technicality inside. So if suppose product manager is provided all the stories, APICS and everything to the team QI as well as dev how these people will know whether the dev is implemented all
10:53
Speaker A
the requirement and the same way how he will know whether QI is tested all the requirement which he has provided. He doesn't know about technical stuff. But this is just a belief system. Just he will trust them. Nothing else. But as
11:10
Speaker A
a technically 100% he doesn't know about what they have implemented internally until unless he start working with the product. So how we can fill this particular gap? How product manager will understand how they are exactly implementing? So here again BDD
11:26
Speaker A
came into picture. So if these people are using this BDD framework then Product manager also can easily understand whatever they are implementing and also whatever they are testing. That's the most important thing. Okay, so forgot about development. So development is
11:43
Speaker A
a little deeper concept, but more technical stuff will be there, but especially at least to QA point of view, he has to know what exactly, what are the features they have tested? What are the features they have automated? That's the most important. Right,
11:58
Speaker A
so BGD framework will fill that particular gap between Technical and non-technical guys and even product manager who is a owner of the requirements he can easily Understand what the QA is tested. He can just check what is exactly tested or not
12:15
Speaker A
So that's another guarantee so the behavior driven framework will be so BDD behavior driven development framework So to implement this kind of framework we have multiple tools available. So Cucumber is very popular tool currently in the market So we can use
12:33
Speaker A
Cucumber along with the Selenium. So Selenium with TestNG we have seen how we can use. But Selenium with Cucumber also we can use. So now this is a basic background about TDD and BDD. Now we also discussed about the tools. So
12:50
Speaker A
there are two tools currently available in the market. Cucumber is very well known product to everybody. So Cucumber is a BDD framework it will support it. And Specflow is also there in the market. So this will also support BDD approach. Now come to
13:06
Speaker A
the Cucumber. So what exactly Cucumber is? Cucumber is a framework. It is again built-in framework. We can say simply built-in framework by which we can automate user acceptance test cases and it will support BDD approach.
13:23
Speaker A
Behavior driven development approach. It is supported. Okay, so Cucumber is a tool which is available in the market. It is also open source tool which is available in the market by which we can implement our test cases using BDD approach. Behavior driven development approach. Okay. So that's a simple
13:45
Speaker A
understanding of what is exactly Cucumber is. So I already told you here how the BDD approach, why it came into market. So same thing Cucumber will fill the gap between the IT and non-IT people. so even everybody can understand what exactly the QIP2
14:00
Speaker A
is written in automation how they are executing what they are executing everything is completely transparent so everybody will know exactly what QIP2 has written and what they are executing even the product manager also can look into that he can easily understand what they
14:15
Speaker A
are written internally so it is very very simple Kukumar is very easiest one when you compare with a test engine Kukumar is very very easy the simple English language can also easily understand Alright, so now we have understood very basic stuff about what
14:30
Speaker A
is TDD, what is BDD and what is exactly Cucumber use. Now, in our sessions I am going to show you Cucumber with Selenium. So, Selenium with Cucumber. So, on top of Selenium, how we can use Cucumber framework. So, in the
14:47
Speaker A
previous sessions I have shown you how to use TestNG framework on top of Selenium.
14:52
Speaker A
So we have installed testng library on top of selenium and we have automated test cases by using testng classes we created testng methods. That approach is completely different. Now we are going to add Cucumber framework on top of selenium. So here also we
15:09
Speaker A
need to use selenium. Selenium is a base. So on top of selenium webdriver we are also additionally adding Cucumber framework. So here we can use any kind of IDE.
15:21
Speaker A
In Selenium classes, I already told you, we already use Eclipse IDE. So Eclipse is also IDE where we can work with Selenium, TestNJ, Jail, even Cucumber also we can configure with Eclipse IDE. So in Eclipse IDE everything is possible. So we already learned
15:37
Speaker A
how to use Eclipse IDE earlier. So in our sessions, especially Cucumber and Rust API sessions, I am going to show you a new IDE which is IntelliJ. which is very very good and very having good look and feel and nowadays in the people
15:53
Speaker A
most of the people are prefer to use intellij okay so this is another ide apart from eclipse also there if you want to practice everything you can also still practice on eclipse and also you can practice with intellij so i suggest you guys
16:08
Speaker A
go for intellij as a new editor if you already know about eclipse you've already done a lot of things in editor so eclipse editor So in our sessions especially Cucumber or industry API sessions I'm going to use IntelliJ as an IDE or editor
16:23
Speaker A
where we can write our automation scripts. So now I'm going to show you how to set up a IntelliJ IDE on Windows. IntelliJ IDE on Windows and then I will show you how to configure Cucumber plugin within the IntelliJ IDE and once you configure this particular
16:46
Speaker A
plugin and we need to also add certain number of dependencies that's most important okay so we will create anyway Maven project so we are going to use IntelliJ as an IDE so here I'm going to write so in our sessions we are
17:01
Speaker A
going to use selenium selenium plus Cucumber so for using these combinations I am using IntelliJ as an IDE because IntelliJ is very very attractive very good look and feel we have lot of options are also available and I am also going
17:24
Speaker A
to use Maven so what is the use of Maven so if you have created Maven project in IntelliJ we will get pom.xml all the dependencies we can directly specify in the pom.xml So we don't need to download any specific JARS manually. So that's
17:40
Speaker A
another advantage of Maven. And in future, we can also run our test cases through command prompt, Jenkins, and anywhere you want. So directly, IntelliJ itself, I will create a Maven project directly instead of creating normal Java project. Right? So once you've created your
17:56
Speaker A
Maven project, then we will get pom.xml. So inside the pom.xml, we will add certain number of dependencies which is required for Cucumber. ok so there are so many dependencies are there we have to specify all the dependencies in the format
18:12
Speaker A
XML after the creation of Maven project inside the IntelliJ right so then the project setup will be ready so now I'm going to show you how to set up IntelliJ ID on Windows and IntelliJ plugin is also required
18:29
Speaker A
along with we need to also download our different jar files so I'm not going to download manually I'm just create the maven project and inside the pom.xml I will add required dependencies ok so intallyj is an IDE I am going
18:45
Speaker A
to use maven as a plugin within the IDE because it will provide pom.xml where I will add all the dependencies add all required right so dependencies as a one thing And then we will move forward later. So first thing, let us set up IntelliJ IDE. How to install,
19:07
Speaker A
how to download and install IntelliJ IDE. And then I will create a simple Maven project in IntelliJ IDE. And once you create your Maven project, it will automatically come with Java itself. So we will create Java programs, Selenium scripts. Everything is
19:24
Speaker A
same guys. Only thing is we will additionally add Cucumber. so whatever we have done eclipse same thing same way we can do intelligent also only thing is the ui options will be little bit changes that's the only difference everything is same okay so
19:39
Speaker A
i will also show you how to set up cucumber in eclipse also so people who are interested still using if you want to use still eclipse you guys can also use eclipse i will show you both the editors eclipse how to configure
19:53
Speaker A
cucumber in eclipse as well as how to configure same cucumber in intellij IDE so what I suggest you is we already done eclipse in civilian classes so I suggest you to learn intellij practice everything in intellij IDE so this is the latest one
20:09
Speaker A
okay alright so the first step is first we need to install IDE intellij IDE we require right so how to install intellij IDE So what I am going to do here is I am just go and just give
20:24
Speaker A
you one URL So here a small 9 minutes video is available How to download IntelliJ and install on Windows Ok so please watch this recording This will give you a clear idea how to download and install IntelliJ on Windows operating system So let me just play this one
20:48
Speaker A
So you can just watch this one. So in this video, how to download and install IntelliJ IDE on Windows. So here I have clearly explained how to download and how to install IntelliJ IDE on Windows operating system. So this is the UI. This is basically and also how to write a
21:09
Speaker A
simple Java programming IntelliJ. It's very very simple. you guys can go through this. And this editor is available in two modes. We can say dark law mode and also default mode. I'll show you both. So please watch this video. It will give you
21:25
Speaker A
very simple. It's very very simple. Just download some exe file. Click on exe file.
21:30
Speaker A
Go to next next next. It will download and install. So once you open this particular intellij. Once you install this intellij IDE. So it will be like this. Once you open it will be like this. So you have to create your new projects
21:45
Speaker A
here. There are so many options will be there. And by default, the theme will be like this. So let me just show you, this is a simple theme. So this is an existing project I'm showing here. So this is a basic theme you
21:59
Speaker A
can see. And if you want to change the theme, just go to settings, file settings. And once you go to settings here, you can just change the appearance. So once you apply so your changes will be there. So this is a dark thing
22:14
Speaker A
you can use any one of the team So for visibility purpose the white color is good. So I'm just taking the white color itself Okay, so this is default intelligent All right, so this is a basically intelligent so
22:30
Speaker A
by default you don't see anything here So this is a blank UI you will see okay So once you install this IntelliJ IDE, the first thing is we can directly create a Java project, you can write Java programs. How we
22:44
Speaker A
have used Eclipse, same way we can do that. So as a first step, once we have installed this IntelliJ, the second step is, so this is step one. So now the step two is create Maven project. What I am saying is create a maven project. So why do
23:09
Speaker A
they use of directly creating maven project because it will get a form.xml. Inside the form.xml directly add cucumber dependencies. So you start downloading all the stuff.
23:20
Speaker A
So how to create a maven project I will show you now. So go to IntelliJ, just go to file, new and here select the project. Click on the project. So once you click on the project it will show
23:33
Speaker A
you this particular window. So we will see Java. So if you select only Java, it will get Java project. So Android project, Gradle project, Groovy, Kotlin. So there are multiple new options are there. So we need to select the Maven option.
23:49
Speaker A
Select the Maven. And here, by default, it will take your Java, whichever is installed in your system. If not, you can just configure the path. So click on the new Ping your Java path. And then click on Next. Now here group id
24:03
Speaker A
artifact id. In Eclipse also we can provide the same thing. So here I am saying seleniumcucumba. So this is the group id artifact id. Click on the next. Now this is the name of the project.
24:19
Speaker A
Seleniumcucumba is the name of the project. So where it is creating under this particular location. This is your project location. Name of the project is seleniumcucumba. Click on the finish. and it is asking new projects can either be opened in the new
24:35
Speaker A
window or replace the project in the existing window so if you already have opened some project here then you can just this window or new window you can use one of them so you can say this window it will open on the same
24:49
Speaker A
window or else it will open another window now if you just click on the project here right so now you can see the tree structure it is just like a eclipse So here you say Maven projects need to be imported. Something is showing.
25:00
Speaker A
So click on import changes. Import changes. OK. So this is the first thing you need to do. So by default, you will get a form.xml also. This is your Maven project you created. And if you expand this one, you will see form.xml. Right.
25:17
Speaker A
So this is a form.xml code. So by default, it is give you like this.
25:22
Speaker A
So with this, what I have done is step two, we created Maven project. Now in the step three, we need to update form.xml because we need to download all the dependencies related to selenium as well as cucumber.
25:39
Speaker A
So here update form.xml update form.xml with all required cucumber with all required cucumber and selenium dependencies so update form.xml with all required cucumber and selenium dependencies so what are those dependencies we require so that's the most important thing so what are the dependencies we require to work with the selenium with cucumber
26:21
Speaker A
so here I will list it out so most of the people will do lot of mistakes here finally they will run into some issues. This is a very very crucial step. If the palm.xml is successfully updated, it will not run into any issues
26:33
Speaker A
in future. So we need to carefully update palm.xml with proper dependencies. So here I am going to give you some names of dependencies. Later I will show you how to download an app. This is one dependency. Cucumber core and Cucumber
26:49
Speaker A
HTML. This is another dependency. and there is one more dependency called cobertura so this is another dependency we required and the most important one is cucumber java is another dependency we required and cucumber jvm devs this is another dependency we required and especially for reporting
27:18
Speaker A
purpose we need cucumber reporting dependency and then ham crust dependency ham crust core is also required and finally we also require one more dependency so these are the different dependencies which we need to add into palm.xml to work with the cucumber okay and selenium java
27:42
Speaker A
should be there because we are going to work with the selenium itself so selenium java dependency also will record so these are all dependencies which we need to add into this palm.xml right so now I'm going to update
27:55
Speaker A
form.xml with all required dependencies from where you need to get these dependencies so let's go to maven repository MVN repository website so that is official website for MVN repository so from there we can get it the dependencies what you
28:13
Speaker A
have to do is just to search for this let's say cucumber core when you search for the cucumber core so here you will see multiple options cucumber jvm core cucumber jvm core here so you will be confused which one we need to
28:28
Speaker A
download right so the latest one is I you are not a good package I he thought our cooks is a package but this is become older one ok so this is outdated so the latest one is they have all the packages everything is
28:43
Speaker A
morning to the latest one that's for I would or so all these dependencies are we need to download or add dependencies only from io.cucumber because these things also available inside info.cooks some people will download this because this is
29:00
Speaker A
older versions of cucumber and the latest cucumber the package is io.cucumber so we need to go to io.cucumber now once you go to io.cucumber so just cucumber code right let me just copy So, Cucumber core. So, click on
29:19
Speaker A
this Cucumber core. Now, it will show you all the versions. Let's go to the latest version 4.4.0. 4.4.0. So, this is the dependency. Now, copy this and go to and here before project, we add manually one tag called dependencies. So, dependencies.
29:41
Speaker A
Inside the dependencies tag, add required dependencies. So, these are first dependencies. ok this is the first difference similarly we should also download required dependencies from a one repository and add all the dependencies to your palm at xml so now search
29:59
Speaker A
for cucumber html and cucumber html is also available in two packages infocourse iowa so this is the latest one go to iowa cucumber package cucumber html so 0 dot 0.2.7 is the only one version is available so select on this particular version copy
30:20
Speaker A
the dependency go to IntelliJ and add here and let me add rest of them so here coberg chura so this is another dependency we require and this is a basically supported dependency for Cucumber so if you search here It
30:36
Speaker A
will give you Kubernetes code coverage and there are two options several net.sourceforce.kubakura and kubakura there are two things are there. So you have to download this from net.sourceforce.kubakura so this is the latest one. Click on this. This is for just code
30:52
Speaker A
coverage. Let me just go to the latest one and 2.1.1 is the latest copy this one and go to indelij and paste it over here. So this is another dependency. So the next one is Cucumber Java. So let's
31:10
Speaker A
search for Cucumber Java. Press Enter. Now again this is available in both the packages.
31:15
Speaker A
IvoCucumber, InfoCooks. Just go to IvoCucumber. Always every dependency we need to get it from IvoCucumber. So click on the first option. Now these are all different versions. The latest version go to 4.4.0. Copy this.
31:33
Speaker A
Okay so this is Cucumber Java. 4.4 or 0 now come back here and post paste it over here and after that the next one is cucumber J unit so again go to same thing search for cucumber J unit
31:52
Speaker A
ok now cucumber J unit is available in multiple things so info cookies also there I will cook on my results so again need to go for Iowa cucumber so click on this So I will share this form.xml anyway so we can
32:07
Speaker A
copy paste the same entries. You don't need to go everything. So click on the new link. Copy this one. So paste it over here. So this is your Cucumber JUnit dependency. The next one is Cucumber JVM Depths.
32:25
Speaker A
Go here. Search for this. Now this is also available in two packages. We need to get it from iwo.cucumber. So click on the first one. So 106 is the latest one. Click on 106. Copy this.
32:43
Speaker A
And paste it over. So still we have four more dependencies. Cucumber reporting. Again go here. Cucumber reporting. So Cucumber reporting which we need to get it from netmasterthom. So this is the first one.
33:02
Speaker A
Both are same almost. So we need to get it from Cucumber reporting. and go to 470 is the latest one click on this the first one copy and go to intellij and paste it over here and the next one is hamcrust core
33:19
Speaker A
again go here hamcrust core so hamcrust core is there in the org hamcrust package okay that we need to download so click on this and here 2.1 is the latest click on the 2.1 capture this dependency and paste and we have a gherkin so copy this gherkin
33:43
Speaker A
again go to the same one so this is i.o.cucumber info books there are two things are there you need to always go for i.o.cucumber so click on the gherkin so click on the latest version so the gherkin latest version is 6.0.7 is available
33:59
Speaker A
but currently the this cucumber supported gherkin languages 5.1.0 so till 5.1.0 itself the cucumber is tested on this cucumber is basically tested on these versions ok so cucumber is not supporting currently these versions ok I will share that document so in the cucumber official documentation they have
34:22
Speaker A
given this kind of information so they have not tested these versions on cucumber you may run into some issues so that's the reason I have to download 5.1.0 ok so this one So copy this and little older but till here the Cucumber is tested. So other versions are also available later
34:43
Speaker A
version but the Cucumber is not tested on the Sputler versions. They are not certified basically. So 5.1.0 is a Gherkin language. Now these are all Cucumber related plugins. Whatever we downloaded, whatever we have added so far these are all
34:59
Speaker A
Cucumber related, Cucumber specific dependencies we required. we are also going to work with selenium along with the cucumber so we need to also have selenium jars so for that we need to also get selenium java so go to again it will download selenium jar friends so selenium java now the latest version
35:19
Speaker A
is this one 59 capture this now selenium java depend is also added so along with this here cucumber by default supports JUnit ok so jt is also by default there. Cucumber is also supported by testng but by default we are also going to use JUnit along with the Cucumber internally. So
35:43
Speaker A
we need to also download JUnit plugin. So just go to again main one. Search for JUnit. So JUnit we need to download only from JUnit. Don't go for another package. Just click on the JUnit. So these are all beta versions are available but they are not stable. So stable version
36:04
Speaker A
is 4.12. I am clicking on 4.12, copy this and copy. So this is the last dependency. So far we have downloaded required dependency. Still here, these are all cucumber dependencies still here. And this is selenium java dependency and
36:22
Speaker A
then junit dependency also have added. So once we have added everything into the pom.dxml, then save the palm.xml then it will download all the jar files and we added them to the external libraries. If you expand this external libraries you
36:41
Speaker A
will see different jar files which are added here. So these are all the different jars we have downloaded through these dependencies. So this is the first step. First we have downloaded IntelliJ and install on Windows operating system then we created a new Maven project in IntelliJ and
37:04
Speaker A
it is by default provided PompDxml and PompDxml is updated with all Cucumber and Selenium dependencies ok this is the first now the next step we need to do still not completed configuration next step is this is very very important so IntelliJ Cucumber plugin we need to add IntelliJ
37:28
Speaker A
Cucumber plug-in need to add I'll tell you how to add this Cucumber plug-in we need to add IntelliJ Cucumber plug-in so how we can add this just go to IntelliJ and select your project go to the file and Here you will see a Project structure right so go to the project structure
37:53
Speaker A
and and here you will see somewhere in the plugin sorry guys not here select your project go to the file go to settings ok go to the settings so once you go to the settings you will see this particular window in this
38:09
Speaker A
particular window you should go to the plugins part so here you will see one option called plugins here it is a plugins so in this plugins section just search for cucumber here just type cucumber So once you search for cucumber,
38:26
Speaker A
it will show you cucumber for Java right now select this one Okay, so once you selected this one, so you have to be which is already installed in my system So it is comes under install but in your case it will show
38:41
Speaker A
you install button here Okay, so we have to click on install then cucumber for Java will be installed then your IntelliJ IDE will be restarted so then only it will appear here So once we have installed this cucumber for Java, so we need
38:55
Speaker A
to select this Butler project then click on OK button. Now this Butler project we also added IntelliJcucumber plugin. So I already installed this IntelliJcucumber plugin earlier. So that's the reason you are able to see directly here. Inside the plugins,
39:13
Speaker A
if I search for Cucumber, just you will see this Butler entry under installed tab.
39:20
Speaker A
But in your case, you will not see here. So as soon as you open this one, once you search for cucumber, it will show you in this list, some of them. So you need to select that one. Here you will see install button.
39:31
Speaker A
So you need to click on the install button, then cucumber for java will be installed on your IntelliJ IDE. So this is the most important step. Okay.
39:42
Speaker A
So already I have installed this, selected and then okay. So my plugins have added to my project. So all the plugins. Added to the butler project so this is another steps so four steps one is we have downloaded installed intelligent ID and
39:59
Speaker A
windows and we created your maven project then updated form with XML with all your dependencies then we have added intelligent cucumber so over Java for Java right so what is the name of that one so let's go and
40:14
Speaker A
check go to file and settings plugins cucumber for Java So IntelliJ, Cucumber for Java plugin which we need to add. So how to add select your project and go to the file select your project I am writing the navigation select project go to the file
40:40
Speaker A
okay so go to the file and settings settings so once you added the settings inside the settings you will see the plugins inside this plugins inside the plugins tab and here search for cucumber for Java so search for this particular option you need to search for so once you search
41:16
Speaker A
here it will give you in this but let me select that but let me click on install you will get install option and once your installation is done your ID will be restarted automatically so this is the first so this is another step
41:30
Speaker A
which we need to do that so intelligent cucumber for Java plugin we need to add the next one is the last step is fifth one is we need to add JUnit library and Hamcrest. So JUnit and Hamcrest.
42:00
Speaker A
Hamcrest is a supported library for JUnit. Hamcrest libraries for your project. So this is the last step please. so if you just notice our form that example in the form that XML I already added jail to job right and also hamcrest also have added but still we need
42:25
Speaker A
to add these two libraries from your Java location not from Java location these two by default come with Cine are intelligent ID so by default these two libraries come with your IntelliJ ID so those two libraries which we need to add
42:42
Speaker A
to your project additionally So I will show you how to do this particular step very important So let's go to IntelliJ again So right click on your project Right so not rightly just select your project go to file and project structure it is just similar to
43:04
Speaker A
in Eclipse we have added build path right so right click on project go to build path add jar file so same flow will be there here in intelj select your project go to the file project structure and here just go to modules
43:19
Speaker A
level ok modules level so inside the modules level we have already added all these jar files now additionally we need to click on this plus button add so click plus button is representing add so click on add and library we are
43:35
Speaker A
going to add which from which one so Java click on library Java now here we need to go to IntelliJ location where you have installed your IntelliJ you need to go to that particular location so by default your IntelliJ is installed under
43:53
Speaker A
program files under this you will see one option called JetBrains inside this you need to go to intelligent idea community edition this is a folder expand this one and here you will see the leap folder go to the leap
44:09
Speaker A
folder then here you will see few more jar files so inside the jar files if you see jail jar file you will see here somewhere so if you just notice here yeah here it is okay this is that these two things are there here just go and 4.1 want
44:30
Speaker A
to just select that one okay, and Then click on ok button selected Okay, so now it is added other one is again go to plus button go to library Java and Go to the same location again, so go to your program files Under program files jet means this is
44:54
Speaker A
a location where my intelligent is installed and Now go to the first ones here this is the location go to the lib folder now hamcrest package will be there jar files hamcrest somewhere it should be there Let me fetch it here
45:18
Speaker A
So let's start from the beginning Just select one of them Search for H press H only H should show you ham crest also somewhere it should be there So yeah, here it is so ham crest core select this ok now
45:42
Speaker A
again ok so now these two packages additionally we have added and Then click on apply and then ok so these are the additional things which we need to do this so we need to add the ham crest libraries to your project and
45:57
Speaker A
IntelliJ installation location from lib directory or we can say lib folder ok so these are the five steps so once we have done this now my project is ready to implement the Cucumber framework on top of Sylvia ok so
46:19
Speaker A
now it just like Eclipse it will also create a SRC main test everything will be there hierarchy so under test Java we are going to create all of us so these are the steps which we need to follow to set up selenium plus
46:34
Speaker A
cucumber on IntelliJ IDE ok so selenium plus cucumber on IntelliJ IDE we need to follow these steps now I will also show you how we can do the configuration on Eclipse especially people are using Eclipse they can also
46:50
Speaker A
do the same thing now I'm going to show you Cillium plus Cucumber on Eclipse this is also very simple so this is Cucumber on Intelligent right so now I'm going to show you how to do the setup on Eclipse
47:14
Speaker A
so now I'm going to open my Eclipse this is my Eclipse the first and most important thing is here as usual we need to first have, we already have Eclipse, I am not going to install Eclipse again so we need to start from
47:28
Speaker A
the sputlust step so here so these steps are common in Eclipse also till here so creating Maven project, updating pom.xml with these dependencies same but this step is little different these two steps are different 4th, 5th will not applicable for
47:45
Speaker A
Eclipse but Eclipse is having different steps now 2nd and 3rd step is exactly the same So, CyanCucumber on Eclipse. So, the first thing is install Java and Eclipse. These are the prerequisites. So, the second step is in the Eclipse, we
48:06
Speaker A
need to do the same steps. Second and third steps are exactly the same. So, we need to create a Maven project and then we need to update the form. I'll show you now. So, now go to Eclipse. I'm creating new project go
48:22
Speaker A
to file new maven project so go to other so select maven project next so click on the next click on again next so here we need to provide the name of the project ok so here I'm going to create
48:40
Speaker A
so in intelj we have given selenium cucumber so here I'll say selenium right so selenium cucumber project let's say something one we only have something so it is given so same thing you can give here click on a finish now it is created a new
49:01
Speaker A
name on project so where it is created here it is great so selenium cucumber project one so inside this it is created two default packages we can just remove them we don't require and palm read xml is there so open the palm read
49:18
Speaker A
xml so by default jl dependency already there we can just remove this one and we will add our own dependencies now whatever dependencies I already added in my IntelliJ IDE.xml I can copy the same exactly all the dependencies
49:35
Speaker A
ok I am copying the same stuff ctrl c and I am putting here so now I have added all the dependencies now save the file so once you have saved is downloaded all maven dependencies so you can see all the
49:53
Speaker A
maven dependencies and here the first line it will give you some error but in intelligent IDE we didn't get this error because this is coming from Eclipse okay so to solve this we need to add one more dependency especially in Eclipse
50:10
Speaker A
so that dependency is we need to add I'll show you that so we already had it somewhere just get you from there to socket this is another dependency which we need to add I'll tell you what is this one so here tools is a dependency from calm dark Sun so
50:33
Speaker A
what is this one is he only to specify the location of tools or jar find so you can find this tool bar jar file in your Java location so if it just go to the Java location wherever you have installed My Java is
50:48
Speaker A
installed under program files Go to Java So I have multiple versions of Java You can just go to one of these Java Just go to JDK And go to lib folder You will see tools.java So again similarly if you just go to 11
51:05
Speaker A
or 12 or latest versions of JDK You don't see that Butler file Okay So 3 versions you don't see that Butler file Just go to JDK 12 lib folder so here you don't see tools.jar file ok so in older versions of Java is
51:21
Speaker A
having this particular file so what you guys can do is I will share this tool.jar file and just copy the same jar file exactly in the location of lib folder suppose if you have installed JDK 10.11 whatever it can be just go to the lib folder and copy here tools.jar and after
51:43
Speaker A
that copy this complete path and specify that path here see program files JDK and I put that particular file under levent lib under tools.java file but from JDK 10 onwards you don't see this particular file inside this particular folder and
52:01
Speaker A
older versions of JDK like JDK 8 or 9 is having this particular file ok but for resolving this particular issue we need to add this one so otherwise it is not required If you get an issue like this, you need to add this
52:16
Speaker A
additionally or else not required. And IntelliJ we don't require this. So now I have updated this formred xml with the same dependencies, cucumber and psyllium dependencies. So now inside this particular project it is added all the maven dependencies
52:33
Speaker A
here. So this is the one thing. So we have added creation and maven project we have done and updated formred xml with all your dependencies. And the next step is very very important. Step 4 is we need to add
52:52
Speaker A
Cucumber plugin for Eclipse. Cucumber plugin for Eclipse. So in the previous step here we have added Cucumber for Java plugin for IntelliJ.
53:05
Speaker A
But here we need to add Cucumber plugin for Eclipse. It will not by default come with Eclipse. We have to add it. So go to Eclipse. go to window go to help menu and Eclipse marketplace we can install this from marketplace
53:23
Speaker A
marketplace so where this marketplace available inside the help menu so from help marketplace so now go to help menu Eclipse marketplace so inside the Eclipse marketplace and here you need to search for Cucumber let it open ok so in the find
53:54
Speaker A
search button just type Cucumber ok just click on the go button so once you click on the go button it will show you two different plugins guys so one is Cucumber Eclipse plugin the other one is natural so these two
54:09
Speaker A
things are very important so here to marketplace and search for cucumber search for cucumber then you will see two options natural cucumber it is like you have to install natural less but it is plugin but eclipse like so both you
54:40
Speaker A
need to install work So just select both of them. So first install first one and then install the second one. So I haven't installed second one for now and I can also click on install. It will automatically install. So natural and boomer eclipse plugin. So
55:01
Speaker A
these two things are required in your eclipse. So it will take some time after that your eclipse will be restarted and then these plugins will be available. So this is the fourth step phase. Once we have done this done your setup is done
55:18
Speaker A
So these are the four steps we need to follow if you are using Selen cucumber on eclipse ID And if you want to use Cucumber selenium on IntelliJ IDE then you follow the five steps Right So with this we have completed still it is downloading
55:42
Speaker A
let it complete So with this we have done the setup on IntelliJ IDE and also Eclipse IDE. So now you can practice either in Eclipse IDE or IntelliJ IDE. So we have done the IntelliJ setup. So till now
56:01
Speaker A
we have done setup IntelliJ IDE and also Eclipse on Windows. So IntelliJCucumber plugin we have installed. Now I am discussing about few important things. Cucumber feature file, step definition file, jail, test runner file and then Gerkin Keyboard.
56:22
Speaker A
So let us see what are exactly these things. How Cucumber works. So in detail I will discuss in the next session. First today what are these three things actually how these are going to work. So let it complete it.
56:37
Speaker A
Before starting Cucumber, because we already done the setup in Eclipse as well as IntelliJ, so now we are ready to write our Silvium along with the Cucumber scripts. Now how exactly Cucumber works? So how everybody will able to understand Cucumber scripts?
56:55
Speaker A
Even before, initially I told you that even non-technical people also can understand Cucumber. So how exactly this is going to work? Now I'll show you exactly how working process of Cucumber. How exactly Cucumber works. That's most important. So let me
57:13
Speaker A
open my board. So how exactly Cucumber works, what are the files we require? And here I'll talk about what is exactly feature file, definition file, test runner class.
57:23
Speaker A
These three are very, very important in Cucumber. Okay. So the first thing is, so first we will compare 3D approach and then come back to the cucumber, how the execution process will go on. So first I will show you exactly how this
57:41
Speaker A
is going to work. Just a moment, let me minimize all of them. Accept and finish in Eclipse. It will go on like this, so I am just minimizing. So now let's see how this is going to work. So in testng, so
57:56
Speaker A
selenium with testng, how we have done is, we have created a project and we have added selenium jars and testng jars. So normally we have a test cases and we have created a testng test case. This is testng class.
58:13
Speaker A
This is your testng class. Inside the testng class we have created test methods. Test method 1, test method 2 and etc. So every method is specified with annotations.
58:25
Speaker A
So these test classes have executed through testng XML file. This XML file executed these test cases or one test case or multiple test cases and it is generated the report So in testng we have done this process our test cases for every test case we created a testng classes multiple testng classes
58:48
Speaker A
in every testng class we created multiple test methods and These test classes we have executed through testng XML and it is generated the reports. So this is the process we have done So in every step, so test case has to
59:03
Speaker A
be done by the test engineer and automation script we need to implement by automation engineer, execution, everything is done by the testers and technical people. Right?
59:13
Speaker A
Now when you come to the Cucumber, BDD approach, how things are happening. So initially the first point in the Cucumber is, it will start with the feature file.
59:25
Speaker A
Very, very important. Please focus guys. This is called as a feature file. The entry point is a feature file. the entry point is feature file so what is exactly the feature file contains so this particular feature file will be written
59:42
Speaker A
in very simple English language all the test cases or test scenarios will be written inside the feature file in general English language which everybody can understand and but additionally we use it a number of keywords so like gherkin keywords we
59:58
Speaker A
have like a Scenario feature scenario when then and so there are certain number of keywords available So those keywords are called as a gherkin keywords gherkin is a language Okay, so here gherkin Gherkin is a language Okay, so gherkin is a language
60:22
Speaker A
which contains which contains certain number of keywords These keywords are very very simple just like a English language simple keywords So by using those keywords, we will write our test scenarios inside the feature file so feature file contains a
60:45
Speaker A
Even if you go for any application or product contains many number of features for every feature contains a number of scenarios right so in the feature file for every feature in your application you will create one feature file and every feature can contains
61:01
Speaker A
multiple test scenarios like say here I will say specify the name of the feature and Different scenarios. I will specify there's a scenario one scenario two and so on and this is an entry point in Cucumber or BDD framework feature file is a
61:17
Speaker A
very very important and is an entry point So who will create this feature file?
61:22
Speaker A
So this feature file can be created by anybody like test engineer can create a or even product managers or product people also can create this feature file is very simple it's not much technical it's very very simple you can easily read and understand
61:39
Speaker A
what is the feature what are the test scenarios we are going to test will be part of your feature file so the feature name and every feature contains multiple test scenarios and every scenario contains multiple steps Every scenario contains multiple steps. So these steps we will create by using Gherkin keywords.
62:02
Speaker A
Like scenario and then when given. So these are the different keywords we have to use. I will show you how to create a feature file in a few minutes.
62:10
Speaker A
So let us understand. So feature file is an entry point in Cucumber where I will specify the feature name along with the scenarios and every scenario contains a number of steps. Okay, this is a feature file. So everybody can understand this particular feature
62:25
Speaker A
file and everybody can create their own feature file. Even non-technical guys also can easily create their feature files. Okay. This is the entry point. Now, once you create this particular feature file, now the feature file name can be anything but the
62:41
Speaker A
extension of the file will be feature. The extension of the feature file will be .feature. So once you created this particular feature file, For every scenario and steps we need to create a step definition file.
62:57
Speaker A
This is called as a step, this is just a Java class. And here we will write step definitions. What are the step definitions?
63:09
Speaker A
Suppose let us say login is my scenario. Feature is my login test. Login I want to verify. With multiple inputs, invalid, valid, or multiple types. I want to open the login page, I want to open the application, I need to
63:27
Speaker A
provide the username, I need to provide the password, then click on the sign in, then check working home page is displayed or not. So they are called steps. So these steps we will be written in English language, simple by using Gherkin. And whatever
63:41
Speaker A
steps we have written, for every step, you have to write corresponding method here. those methods we will include the code for these particular steps that is called as a step definition so for every step we have defined in this particular scenario
64:00
Speaker A
having corresponding method and this method is implemented the definition of the steps the selenium code we have to write inside the methods but again we are writing the selenium code guys but here the thing is We cannot miss any one of the steps. That's the most important. Because everybody will see
64:22
Speaker A
only feature file. Nobody will see your step definition file or any other files. Because if you see the feature file, whatever steps you have mentioned in the feature file, you must implement every step in the step definition file. It will not allow you
64:38
Speaker A
to leave any one of the steps. So that gives you a guarantee to other people like non-technical people or suppose product manager. he will know the feature file so if you include this feature file in your automation so that's again just a confirmation
64:55
Speaker A
because by seeing the feature file suppose if he is able to see all the steps in the feature file that means you must implement those features you must write the step definition for every step in your scenarios so you cannot skip it so
65:10
Speaker A
if the product manager sees this feature file in your project so that will give you the guarantee have implemented all the step division for every step because if you specify some step you must specify some step okay so the second stage is step
65:25
Speaker A
definition file we will create all the methods for these steps so this is second so feature file step definition step definition file is more technical again it is just like a test engine matters testing class be created right it is similar so for every step the feature file we will
65:46
Speaker A
have corresponding step definition file and all the steps we will implement inside the step definition file and after that we need to run this particular step definition file how to run this so if we have a single feature
66:04
Speaker A
file okay if you have a single feature file you can run feature file directly suppose you can also run specific scenario also if you want can run the feature file directly suppose if you have multiple feature files then you have to create
66:20
Speaker A
one test runner class JUnit class this is your this is called as a test runner class this is the main class this is basically JUnit class and here we need to write some piece of code and this particular test runner
66:37
Speaker A
class will execute talk to the feature file and feature file steps will be read and these steps will again use step definition file. So this is the main important file. So test runner execution will start from here. But we can still execute our
66:53
Speaker A
feature file without having test runner, but only one feature file we can execute. Multiple feature files we cannot execute. So first entry point is feature files. Our work will start with the feature file. So once you are able to create our feature file,
67:09
Speaker A
then we need to implement step definitions for the particular feature file and then we need to get a test runner class and here we will call the we will specify the feature file location and step definition file location so these two
67:25
Speaker A
are very important so step definition file and feature file so these two files locations we need to specify inside the test runner class and when you run your test runner class Internally it will go to the particular feature file and read all the
67:42
Speaker A
steps and executes corresponding step definitions So this is end-to-end process of cucumber. So how cucumber exactly works? So this is a way cucumber works So if you want to work with the cucumber the first thing is we need to know how to create a feature file Then how to
68:01
Speaker A
write a step definition file and how to write test runner test runner to JUnit class So feature file, step definition file and test runner. These two are important components. Right. Now I'm going to show you very, very basic example. How
68:19
Speaker A
to create a feature file, step definition file, and I will create test runner class.
68:24
Speaker A
And then I will show you very basic test case by using Selenium along with the Cucumba. Okay. Now let's go to IntelliJ. So what I'm going to do is I'm going to implement all the stuff inside the test Java. Okay. So
68:39
Speaker A
here, I will create a new package. So this package, I will name it as, so this package, I will name it as, okay, so let's start Feature File, Creation of Feature File.
68:56
Speaker A
So where I will create Feature File, you can create at the project level or main test, anywhere you can create a Feature File, okay? So to store all the Feature Files, first I will create a new folder. So how to create a folder?
69:07
Speaker A
Right click on your project. New. Directory. So directory is nothing but a folder. So click on the folder. So here I will name it as a features. Features. So this is the directory. So inside the folder I can create any number of feature
69:23
Speaker A
files. Now I am going to create my first feature file in Cucumba. Okay. So let's create. So my feature file is I will give you new file take a new file select the features new file and here we need
69:41
Speaker A
to give some name to the feature file so here i'm giving orange hrm dot feature okay so all of our hrm test cases test scenarios i will write inside the feature file so click on ok button okay now the feature file icon
69:59
Speaker A
will be like this ok so here we need to write all of our features feature along with all the scenarios what is the feature file contains feature file contains a scenario so what is the feature I am going to test in this particular
70:12
Speaker A
application that we have to specify first so feature is these are keywords feature okay scenario given then and I will use it a number of get in keywords so but we can easily read It is readable. So feature is,
70:29
Speaker A
let's say I will give some name list, orangehrm login. So this is a feature I'm going to test for orangehrm application. Login is one feature. So as part of this, what is my first scenario I want to check is? So before
70:46
Speaker A
checking the login, I can first launch the page and need to perform certain things.
70:51
Speaker A
So the first scenario I'm going to create is, I need to create a scenario.
70:56
Speaker A
It's my keyword. Scenario what is the scenario? I'm going to check in this application is I will check logo presence on orange HRM homepage Orange HRM homepage so this is my scenario I want to verify logo presence on orange HRM homepage
71:18
Speaker A
and To check this we need to have multiple steps and those steps we need to include by using Gherkin keywords so here there are number of working keywords available so I will show you what are those keywords even though it is simple
71:33
Speaker A
English language we need to use a certain number of Gherkin keywords now let me just use a certain number of keywords I will show you what exactly the keywords are just a second ok so there are certain number of keywords available so one is feature one is scenario
71:55
Speaker A
and scenario outline is also there I will show you those and feature is one of the key word which we need to specify the first line of the feature file the first line of the feature file should be feature colon name of the
72:09
Speaker A
feature any name you can specify what is the feature you are going to test on the Butler application you have to specify now in this particular feature you can have any number of scenarios so if you want to define one scenario I will
72:22
Speaker A
say scenario colon logo presence on or in hrm this is one scenario i'm going to test so if you want to test this we need to write certain number of steps so those steps we need to use right using these keywords given
72:37
Speaker A
when then and so these keywords will always start with the uppercase letters so these keywords will start with the uppercase letters so what is it meant by feature and scenario means feature is a keyword where we can specify the name of
72:53
Speaker A
the feature and scenario is another keyword where we need to specify the name of the scenario and scenario keywords can be created any number because one feature can have any number of scenarios but in the same feature file I cannot create more than
73:08
Speaker A
one feature only one feature we can have any number of scenarios but again every scenario will have number of steps so see this very simple English language I'm writing the steps so here I mentioned what are the keywords given is a keyword under
73:22
Speaker A
this we will specify the you said the context like prerequisites and inside the when keyword we specify certain kind of action or interaction or certain condition so this is a prerequisite just remember as a thumbroot given is representing a some pre condition ok and when is representing certain action
73:46
Speaker A
or a condition and then representing some output so when I do some action what is an output you will get So prerequisite when is nothing but an action or a condition then representing the output or after then if you want to verify
74:03
Speaker A
something or if you want to check multiple output you can use AND key. So simply say given is a prerequisite and when is a action or condition then representing an outcome or output. and representing the continuation of them so if you have to check multiple output you can
74:23
Speaker A
specify and and and ok so these are very basic gherkin keywords so there are so many other keywords also there I will also introduce those keywords as and when it required now first of all I created some feature and scenario name also
74:38
Speaker A
given so here I will write this scenario how to test logo presence on orange HRM homepage so here I am going to write the steps first step is need to start always with the given keyword even ok and given
74:56
Speaker A
so feature and scenario will be followed by the colon but the rest of the keywords will not follow by any so given I this is a pretty busy as I said given contains a pretty quick right so what is the pretty piece when
75:10
Speaker A
a given I launch this my previous I launched a chrome browser launch chrome browser this is a pre-requisite after opening the browser what you will do action so when I open orange HRM homepage or orange HRM homepage is the first one given part
75:36
Speaker A
where prerequisite we need to specify I'll launch my chrome browser there's a free request so what is the reaction here when I open orange HRM homepage URL or URL Then, and what I need to do here, after opening, then I need to verify.
75:51
Speaker A
That is the output, right? So then, I verify, I verify that the logo present on page. Okay?
76:04
Speaker A
And after verification, and close browser. So this is very, very simple. So by reading this, you will be very, very clear what we are going to test on our page. So what is the feature? OrangeHRM login. So what is
76:19
Speaker A
the scenario you are going to test as part of this feature? Logo presence on HRM homepage. And what is the given? I launch my Chrome browser, then I open orangeHRM homepage URL, then I verify that the logo present on the page or not. And then finally, and close browser.
76:41
Speaker A
So these are keywords, given, when, then and these statements are up to you and how you are creating. This is up to you. But every statement will be easily readable by anybody else. So if you see this, even non-technical people also can easily
76:57
Speaker A
understand this particular feature file. So this is very, very basic. So that's the reason the feature files can be created by anyone. Even product manager create, QI create, dev create. So because these feature files are very simple to write.
77:14
Speaker A
So if you have a manual test cases and we can also convert those manual test cases into BDD approach. This is called BDD approach. And like this we can add any number of scenarios. So for now I am strict to this Butler scenario
77:29
Speaker A
and the rest of the scenarios I will show you in the next session. Let us try to implement this scenario. So what I said here is the first point is creation of feature files. Now we created our feature file. So what is the
77:41
Speaker A
feature file contains the feature, name of the feature, what is the scenario we are going to test and what are the steps will be created by using Gherkin keywords.
77:52
Speaker A
Given is representing precondition, when is representing an action, then representing some outcome and if they want to verify something else or some actions I can say end.
78:03
Speaker A
Okay, so now I am going to implement these Butler steps. How to implement? The next step is we need to create step definitions file. So step definition file is a Java class and test runner is also a Java class. Both
78:18
Speaker A
are Java classes. So what I will do is I will create a package. So for storing features, I created a directory. So later you can also add more number of features. But to create these Java classes, I will create a package. So go
78:33
Speaker A
to test Java here. I will create a new package. And here I will write step definitions. Step definitions.
78:45
Speaker A
Okay, this is a package. Inside this package, I will create a Java Cloud. And I will need another package. That is another package. So test runner. Two packages I created. So for this particular feature file scenarios, I will create step definition class files inside the step definition.
79:06
Speaker A
Let me just properly rename it. step with definitions okay and test run at last will be created in service to package step definition package contains again guys three things we have discussing here one is feature file the other one is step definition file and test runner so three components I shown you
79:28
Speaker A
feature file the first you need to create then corresponding step definition file we need to create then we need to run these two using test runners Because these two are classes, I created two different packages in my Intelligent. And Feature file is just
79:42
Speaker A
a file I created inside the features folder or directory. Okay, now let us try to implement step definitions. So how we can implement step definitions? So let me create a new class under step definition, create a new Java class. Now
79:59
Speaker A
it is little different than Eclipse case. So UI is little different. So right click on step definitions. I am taking a new Java class. So here I am writing orangehrm steps. So .java it will automatically add. Orangehrm steps. So this particular class file should contains all the methods
80:21
Speaker A
corresponding to your feature file. But how we are going to write a method? So for every step in a feature file, starting from given, these are exactly steps. Synod is not a step. So these four are the steps. For every step we need
80:38
Speaker A
to create a corresponding method here. So how we are going to create. So how this feature file will be able to understand this one. That's most important.
80:49
Speaker A
So to do this what I'm going to do is you no need to write anything manually here. The method you don't need to write manually. So I will show you the simplest way to write all methods. What I can do is just execute
81:02
Speaker A
this particular file. So how to execute feature file is. Right click here, run feature orange hrm. So just run the feature file and then see what is exactly happening. I run my feature file, I still not implemented anything. I just run my
81:19
Speaker A
feature file. Okay. Now once you run your feature file, it is successfully running. Now if you see this Butler output, all my steps got failure.
81:30
Speaker A
Why? Because I haven't implemented any method for them. So now see this output exactly. What this information is, one scenarios. That means in the feature file we have only one scenario. And which contains the four steps which are undefined. Steps are
81:48
Speaker A
not undefined. The another advantage here is, you can see here, it is giving us a suggestion. You can implement missing steps with the snippets below. So these stepness by default will be generated by Cucumber. So this is very very important
82:06
Speaker A
feature and very useful feature from Kukuma. So if it is not generated here we have to write these methods manually in the step definition file. So I am just copying these steps as these. Okay so whatever steps are, four
82:22
Speaker A
steps only right. So the four steps I am copying and go to your steps file and paste it over here. Okay I paste it over here.
82:34
Speaker A
So if you just observe here, okay so in orange HRM for every feature there are four steps are there. For four steps there are four methods created.
82:46
Speaker A
First one, second, third and four methods created. And you need to observe. So how we can just map these methods. So if you see this, the given is I launch Chrome browser. For this particular step this is the method implemented. Because here
83:01
Speaker A
it should exactly match. this just a second in this I launch Chrome browser and the second step I open orange HRM home page so even in the middle also I open orange HRM home page and the third step is I verify that the logo
83:21
Speaker A
present on page so here I verify that the logo present on page and finally here close browser the corresponding step Okay, for every step in your scenario, there will be corresponding method, step definition. This is called step definition will be created.
83:39
Speaker A
But this is just a skeleton it is provided, but we need to implement this method. How we got this method? Once you execute your feature file, it will give you whatever steps are not implemented so far. For those steps, it will give you
83:54
Speaker A
snippet. So just copy the sticknet and provide here. and why these keywords are giving in the red color because we haven't imported proper package so whenever you are adding this given like this it will give you a certain number of packages here
84:10
Speaker A
so given keyword which we need to import from cucumber api java.en so once you imported this one error is gone so these all keywords available inside the same package so when it says star here all keywords will be matched
84:26
Speaker A
because all the keywords are present in the same thing so when I say start here we no need to import this Butler package for every keyword ok so this is a package which we have imported now errors are gone and one
84:40
Speaker A
more so this Butler thing we can just remove it we not require this we have to write our own selenium code inside this particular methods ok so if we just go back and see the feature file So this is a feature file. Now
84:56
Speaker A
previously it is highlighted like this, but it is gone now. Because for every step there is a corresponding method is created in the step definition file. Now we need to implement these methods using Selenium. So now I am going to
85:12
Speaker A
implement by using Selenium. It's very very simple now. So you all you guys know about Selenium. So you can simply do that. Now I am creating WebDriver object, WebDriver. moment web driver because I'm going to use a classic over just a second
85:33
Speaker A
so the beauty of intelligent is as soon as you are writing some class it will give you auto suggestions this is very very useful approach so here I'm going to use web drive web driver driver is equal to currently I'm not sending anything
85:48
Speaker A
I will assign this driver inside the method so web driver object to create Now let us implement these methods by using selenium script. The first one is I launch Chrome browser. So what we need to do here, I need to launch my Chrome
86:01
Speaker A
browser. For that we need to add some selenium. So here I'm adding selenium. System.setProperty, webdriver.chrome.driver key value and location of my Chrome driver.
86:13
Speaker A
And this Chrome driver class which we need to import. So when I type here Chrome driver auto-selection we give you. So this particular statement This one will launch my driver or launch my Chrome browser. So this step is implemented.
86:29
Speaker A
Now the second step. As soon as open the orange HRM homepage we need to open here. How to open driver.getURLF application.
86:41
Speaker A
So here I am going to provide URLF application. I'll say orange HRM application URL. Right. So now this particular method will open the URLF application. then here I need to verify the logo present on so these methods by default in generated if you know if you want you can
87:01
Speaker A
also change this method names okay template is given by default like this if you want you can also change the names of the method but you should not change these things because these text will exactly mapping with the steps which are written in
87:15
Speaker A
the feature file okay so now I have implemented this one here I have opened the URL Now here I need to check the logo present or not. So how to check logo present or not? Capture this element, inspect that orange HRM.
87:31
Speaker A
So here image capture the XPath for this. And go to IntelliJ. Now capture that logo. So driver.findElement by.Xpath specify the XPath dot. So this is pointing to the image. So what I am verifying is I need to check
87:52
Speaker A
whether displayed or not. So A is displayed. So this method will give you status.
87:58
Speaker A
A boolean value. I am storing that boolean value in a variable called status. So now I will verify on asset command. Asset dot and asset dot asset equals asset dot sorry asset dot asset equals and here specify the Which package is important it is important
88:23
Speaker A
J unit package here. We are not going to use testing you can always import J unit so as a dot asset equals and What is our expected? So our expected is True, right? So what is our actual so actually is
88:38
Speaker A
this one? That's you specify So both are same my logo is present or as my this test method will fail now in the closed browser I will close my driver dot quit that way so now we have implemented
88:57
Speaker A
all the matters see given so if you just one more thing notice here I'll say given when then and I said last one is end but here it is automatically generated then so that then and so both are
89:13
Speaker A
equal okay but when I say first time then second time you can use and instead of then ok so it is not good right then then then if I use multiple then source it is not so I can say say end because it
89:26
Speaker A
is still following still it is continuing but when I creating the keyword here it will automatically update then ok so now we can also change it and here nothing wrong ok this is also fine alright so now I have implemented
89:42
Speaker A
all the steps for steps which are defined in the feature So this is how we need to create a step definition file. That's the second step. Now I created my feature file, created my step definition file. Now we need to execute
89:58
Speaker A
test runner JUnit class. So we can create this later also because currently I have only one feature file. I can run feature file directly. So let us run my feature file and test whether it's working fine or not. So go to feature file.
90:12
Speaker A
So currently I have only one scenario. I am running my feature so how to run right click run the scenario okay so now I have run my feature file now observe what happens so now it is starting my JDK so I launching Chrome browser it is trying to launch my Chrome
90:33
Speaker A
browser yes it is launching my Chrome browser open the URL so as soon as my open URL is done my logo test is complete now you can see here is only one scenario got passed and there are four steps are there in one
90:46
Speaker A
scenario all the four steps got passed okay so this is how we need to execute your feature suppose if you have one more scenario you can also execute that patler scenario so just right click here on patler scenario execute the specific scenario or
91:03
Speaker A
if you want to run the complete all the scenarios from one feature you can just put cursor here now run only feature file feature or in hrm this is also fine if you want to run a specific scenario just right click here run
91:15
Speaker A
here okay in the next session I'll show you multiple scenarios so but this is not right way of execution because it will not generate any report nothing it just execute your step definition file now if you want to generate any report
91:31
Speaker A
all these things we need to create another one test runner class that is the third component So we create a feature file, step definition file and test runner class. That we need to create. There's a JUnit class. Where we have to
91:45
Speaker A
create? We already created one package. So inside this package I will create new. This is also Java class. So I will name it as test runner.
91:59
Speaker A
Test runner. So now I'm going to show you how to use this. So inside the class we are not going to write anything. So this is a JUnit class.
92:08
Speaker A
Inside the class we are not going to write anything but here we need to write something. What is that is at the rate we need to specify the runWithCucumber.class So this has to specify. So this cucumber should be imported from
92:34
Speaker A
run with package so that we need to import so we already imported right so let it import so this is already imported so here cucumber dot class is giving some error let's see cucumber from apaj unit dot class okay this is the
92:56
Speaker A
right row so we need to import this one also now this is one thing and the other thing is at the rate Cucumber options we have to define so inside the class. We are not going to write anything Okay, only the these things
93:10
Speaker A
we need to update run with Cucumber class and Cucumber options we need to define So in the Cucumber options how we can specify Cucumber options is here we need to specify where exactly my feature file is available and step definition file is available
93:25
Speaker A
so here I need to use what keyword called features is equal to the double quotations I need to specify where is exactly my feature file is available so this is my feature file right click and get the path so here there is an
93:40
Speaker A
option is there it will give you direct path of the file so here file path so click on the file path and it will give you path or else copy there will be one more option so here copy path ok so just copy
93:56
Speaker A
path and specify here So here we use forward slashes users slash slash admin slash slash and these are all forward slashes forward slashes features slashes and origin term.feature. So this is a feature file and comma and where is the step
94:19
Speaker A
definition file. So that also we need to specify by using a glue keyword. There is a keyword called a glue. So by using this particular keyword we need to specify where exactly my step to definition file is there. So we no need to
94:33
Speaker A
specify exactly the step definition file name. We have to just specify the package name.
94:39
Speaker A
So that is step definitions. Step definitions. So and whatever step definition files are there everything will be executed according to the feature file. So only specify the step definition. And gloop is a keyword.
94:57
Speaker A
for now just I'm introducing only these two options inside the option so these are blue keyword and feature file and blue keyword so these are cucumber options you can write in the single line or you can write in the
95:12
Speaker A
multiple lines so it is there are two backers on there and just remove that okay so this is how we need to create your J unit test run or class so inside the class we no need to run anything it's a blank above
95:26
Speaker A
this class we need to add two options enter it run with cucumber class is a parameter and enter it cucumber options features and you so there are multiple options also there even if you want to generate we need to add some other options
95:40
Speaker A
in the next session I'll talk about different type of options here but currently I told you only two options one is features the other one is glue so inside the features we need to specify the location of your feature file along with the
95:53
Speaker A
name of the feature file But in the glue keyword we need to specify only the name of the package. So where exactly our orange hrp steps are implemented. This package name agreed. So now when I run my test runner class this will know
96:08
Speaker A
about feature file and this will know about step definition. So it will integrate both and execute my test cases. Okay. So this is my test runner class. Now let me execute my test runner class. Right click run test runner.
96:23
Speaker A
So once I run my test runner. it will start executing our my step definitions so now it is large my Chrome browser open the URL it's a logo test is completed so my test got passed once in our new part pass and inside the scenario there are four steps but
96:45
Speaker A
passed okay so this is how we need to implement this a feature file this first step corresponding step definition file. How we got this one?
96:57
Speaker A
When you run your feature file, it will automatically generated these methods. But internal body have removed and have implemented my own script, cilium script inside this methods.
97:09
Speaker A
And to integrate these two, I created test run by class. Here we specify the feature file location and blue. So blue representing where is exactly my step definitions are written. So this is how the cucumber works. So this is
97:25
Speaker A
end to end working style of cucumber VDD framework. So everybody can easily understand the feature find. Even if you miss one step, suppose in the orange HRM step definition, let us see, I missed this particular thing. I'm just commenting this particular method, see
97:40
Speaker A
what happens. So I'm just commenting this one. Comment with, so I have commented this code. Now if you just go to feature file, now you can see the given step is highlighted. So what does it mean?
97:58
Speaker A
The corresponding step is not available in the step definition file. So we have just commented this. So that's the reason it is giving error. So if you run your file also it will not execute. It will throw an error. So what does that
98:10
Speaker A
mean is for every step we must implement the step definition method we have to implement. So anybody will see this particular feature file, they come to know they don't see any errors or any haliations here they will come to know that
98:27
Speaker A
every step is having some step definition okay so this is a confirmation so that's all about cucumber framework so this is how we need to write your basic test so how to create a feature file by using gherkin key words how
98:42
Speaker A
to create how to implement step definitions for the particular feature file and how to implement test or not So for steps definition and for runner class I have created two different packages and all feature files will be created inside the features folder. So
98:57
Speaker A
you can add any number of features and every feature can have any number of scenarios, you can have any number of step definitions but always you have only one test runner class. Ok, so this is how we need to work with the
99:11
Speaker A
Cucumber. This is the very basic stuff we have discussed. We have discussed our Cucumber feature file, how to create a feature file. step definition file how to create a jr test run at last even in the eclipse also you have to do the
99:24
Speaker A
same thing okay so that's all for today so today I have seen I've shown you how to install Cucumber and Cm setup on IntelliJ IDE as well as Eclipse so first to do this one and do volume 1
99:41
Speaker A
IDE either go for Eclipse or go for IntelliJ I suggest you guys go for IntelliJ there's a latest one And in tomorrow session I will discuss a few more important options in the program. Alright, so that's all for this session guys.
99:55
Speaker A
If you have any queries, you can ask them.
Topics:CucumberJavaBDDTDDTestNGSeleniumAutomation TestingBehavior Driven DevelopmentSetup CucumberEclipse IDE

Frequently Asked Questions

What is the main difference between TDD and BDD?

TDD focuses on test cases created by technical users for functional testing, while BDD focuses on acceptance test cases written in a way that both technical and non-technical stakeholders can understand.

Why is Cucumber used in BDD?

Cucumber is used in BDD because it allows writing test scenarios in a human-readable format that bridges the communication gap between technical and non-technical team members.

Can non-technical people understand automation tests in BDD?

Yes, BDD frameworks like Cucumber are designed so that non-technical people such as product owners and business analysts can easily understand the test cases and scenarios.

Get More with the Söz AI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries, speaker detection, and unlimited transcriptions.

Or transcribe another YouTube video here →