Creating Selenium Gradle Project in Eclipse



Creating Selenium Gradle Project in Eclipse


In this Gradle Tutorial, we will look into what is Gradle, few major advantages of Gradle and how to write and execute our test into eclipse using Gradle.



What is Gradle? 

Gradle is open-source Build management and automation system based on Groovy-based Domain-specific language instead of XML files, unlike maven or ant. It is been created and disturbed by Apache.


Advantages of Gradle

ü Dependency and distribution management.
ü Integration with Source code management tool like GIT.
ü We can build scripts with a functional programming language.
ü Single Build tool to support multiple programming languages.
ü It has DSL for creating and writing build tasks.




In this section we will be creating our first Java Selenium program along with TestNG and Gradle as a build automation tool.

To Start working with Gradle we need to install Gradle plugin into our eclipse for that we need to follow below steps:

1)     In Eclipse Click on HelpàEclipse Market Place.

2)     Search for Gradle Plugin



3)     Install the plugin if already not installed. Please make sure to restart your eclipse after installation.


Now to Create our first Gradle project in eclipse we need to perform the below steps:

1)     FileàNewàProject type Gradle in wizards.

2)     We will get option of Gradle project. Please select that.


3)     Click on Next and provide name of the project


4)     Click on Finish.




Now we would be able to see that along with our basic project structure there are two more new files named “build.gradle” and “settings.gradle” are generated.


 settings.gradle file would be used to specify which files we need to include in our build.

build.gradle is the heart of our project in which we need to specify all our dependencies, plugins and repository information the same way we do it in our maven project.

We can also delete the by default package created in src/java and src/test folder.

Now to start working with the Gradle project we need to put the Gradle dependencies in our build.gradle file.

In this section for learning purpose I would be creating simple selenium program along with TestNG.

For this purpose we need to go to maven repository and copy the Gradle dependencies of selenium and testing.


This dependencies we need to copy into the dependencies section of our build.gradle file.



Once this is done we need to click to do right click on project àGradleàRefresh Gradle project this will download all the dependencies in our local.



Now we can create any selenium program for e.g to enter any value in google home page along with its corresponding testing.xml file as well.


Now to execute this we have two options.



1)     We can directly execute this with the help of testing.xml as we usually do.

2)     In Our build.gradle we can create one new task lets name it as a test in this we need to give values like.


To execute this right-click on build.gradle, Select Run as àRun configurations.

Here we need to select our gradle project and in arguments Tab, we need to run the command gradle test.





 Now click on run to execute our first Gradle test.

Happy Learning...!!!




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post