Github Integration with Selenium: Complete Tutorial

What is GitHub?

Git Hub is a Collaboration platform. It is built on top of git. It allows you to keep both local and remote copies of your project. A project which you can publish it among your team members as they can use it and update it from there itself.

Advantages of Using Git Hub For Selenium.

  • When multiple people work on the same project they can update project details and inform other team members simultaneously.
  • Jenkins can help us to regularly build the project from the remote repository this helps us to keep track of failed builds.

Prerequisite for Selenium and github Integration

Before we start selenium and git hub integration, we need to install the following components.

  1. Jenkins Installation.
  2. Maven Installation.
  3. Tomcat Installation.

You can find this installation steps in the following links:

1) Maven and Jenkins installation Guide (https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html)

2) Tomcat Installation Guide (https://www.guru99.com/apache.html)

Prerequisite for Selenium and Github Integration

Git Binaries Installation

Now let us start by installing “Git Binaries”.

Step 1) Launch the Browser and navigate to URL- https://git-scm.com/

Step 2) Download the latest stable release.

Step 3) Click on downloads for windows once the file is downloaded we can begin with our installation.

Git Binaries Installation

Step 4) Go to the download location or icon and run the installer.

Step 5) Click through welcome and General Public license.

Step 6) Click on “next” button in git setup wizard

Git Binaries Installation

Step 7) Read the GNU General Public License and click on next

Git Binaries Installation

Another window will pop up,

Step 8) In this step,

  1. Select the Directory where you want to install “Git Binaries” and
  2. Click on next button

Git Binaries Installation

Step 9) Select the component which you want to install and click on next

Git Binaries Installation

Step 10) If you want to create a start menu folder for Git, leave the setting default and click on next.

Git Binaries Installation

Step 11) In this step,

  1. Select Use Git from the Windows Command Prompt to run Git from the command line and
  2. Click on next.

Git Binaries Installation

Leave the default setting and click on next to install.

Step 12) In this step,

  1. Select Use Open SSH It will help us to execute the command from the command line, and it will set the environmental path.
  2. Click on next button.

Git Binaries Installation

Step 13) In this step,

  1. Select “Checkout windows-style, commit Unix-style line ending”.(how the git hub should treat line endings in text files).
  2. Click on next button.

Git Binaries Installation

Step 14) In this step,

  1. Select Use MinTTY is the default terminal of MSys2 for Git Bash
  2. Click on next button

Git Binaries Installation

Git Binaries Installation

Once git is installed successfully, you can access the git.

Open Command prompt and type “git” and hit “Enter” If you see below screen means it is installed successfully

Git Binaries Installation

Jenkins Git Plugin Install

Now let’s start with Jenkins Git Plugin Installation.

Step 1) Launch the Browser and navigate to your Jenkins.

Step 2) Click on Manage Jenkins.

Jenkins Git Plugin Install

Step 3) Click on Manage Plugins, it will open another window

Jenkins Git Plugin Install

Step 4) Click on Available TAB

Jenkins Git Plugin Install

Step 5) In this step,

  1. Select GitHub plugin then
  2. Click on Download now and install after restart button.

Jenkins Git Plugin Install

Now it will install the following plugins.

Once the Installation is finished. Restart your Tomcat server by calling the “shutdown.bat” file

Jenkins Git Plugin Install

After Restarting the tomcat and Jenkins we can see plugins are installed in the “Installed” TAB.

Jenkins Git Plugin Install

Setting Up our Eclipse with GitHub Plugin

Now let’s install GitHub Plugin for Eclipse.

URI for EGit Plugin location https://download.eclipse.org/egit/updates/

Step 1) Launch Eclipse and then

  1. Click on help button then
  2. Click on install new software

Setting Up Eclipse with GitHub Plugin

Step 2) The below screen will open once we click on the install new software. Now click on add

Setting Up Eclipse with GitHub Plugin

Step 3) In this step,

  1. Type the name “EGIT” and
  2. Enter the location https://download.eclipse.org/egit/updates/ then
  3. Click on ok.

Setting Up Eclipse with GitHub Plugin

Step 4) Then click on select all and next

Setting Up Eclipse with GitHub Plugin

Step 5) Click on next and click accept the license agreement then finish the installation.

Then restart the eclipse.

Setting Up Eclipse with GitHub Plugin

Building a repository on Git

Step 1) Navigate to Git Hub URI: https://github.com/ sign up for git hub

Step 2) Once you have been successfully signed up then click on create new repository

Building a Repository on Git

Step 3) In this step,

  1. Enter the name of the repository and
  2. click on create repositoryBuilding a Repository on Git

Testing Example Of Using Selenium with Git Hub.

Step 1) Once we are done with the new repository, Launch Eclipse

  1. Click on file
  2. Then click on new button and then
  3. Click on other

Testing Example Of Using Selenium with Git Hub

Step 2) In this step,

  1. Select Maven Project and browse the location.
  2. Click on next

Testing Example Of Using Selenium with Git Hub

Step 3) In this step,

  1. Select project name and location then
  2. Click on next

Testing Example Of Using Selenium with Git Hub

Step 4) Click on next

Testing Example Of Using Selenium with Git Hub

Step 5) In this step,

  1. Enter Group Id and
  2. Artifact Id and
  3. Click on Finish button.

Testing Example Of Using Selenium with Git Hub

As soon as you click on finish button, a project will be created.

Step 6)

Now let’s create a sample script

Testing Example Of Using Selenium with Git Hub

Let’s push the code/local repository to Git Hub.

Step 7) In this step,

  1. Open eclipse and then navigate to the project
  2. Right-click on the project and Select “team” then
  3. Select share project

Testing Example Of Using Selenium with Git Hub

Step 8) Once we click on the “Share Project” in above screen, we will get another window

In this step,

  1. Select the local repository and
  2. Click on finish.

Testing Example Of Using Selenium with Git Hub

Once we click on Finish, we can see the change in the project structure that we have created a local repository.

Testing Example Of Using Selenium with Git Hub

Now it’s time to push our code to Git Hub Repository

Step 9) In this step,

  1. Right-click on the project and team then
  2. Click on commit

Testing Example Of Using Selenium with Git Hub

Step 10) In this step,

  1. Enter a commit message and
  2. Select the files which we want to send to Git Hub repository
  3. Click on commit and push

Testing Example Of Using Selenium with Git Hub

Once you are done with it, you could see the icons in the project is being changed it says that we have successfully pushed and committed our code to Git Hub

Testing Example Of Using Selenium with Git Hub

We can verify in the Git hub in the repository that our project is successfully pushed into repository

Testing Example Of Using Selenium with Git Hub

Now it’s time for executing our project from Git Hub in Jenkins

Step 11) Launch browser and open your Jenkins.

Step 12) Click on new Item.

Testing Example Of Using Selenium with Git Hub

Step 13) In this step,

  1. Enter Item name
  2. Select Maven Project
  3. Click on ok button

Testing Example Of Using Selenium with Git Hub

Step 14) In this step, we will configure Git Hub in Jenkins

  1. Click on Git and
  2. Enter the Repository URI
  3. Click on Add repository

If you have multiple repositories in Git Hub, you need to add name Refspec field of the repository.

Testing Example Of Using Selenium with Git Hub

We can get the URI in Git Hub

Testing Example Of Using Selenium with Git Hub

Step 15) In this step,

  1. Add the pom.xml file location in the textbox and
  2. Specify the goals and options for Maven then
  3. Select option on how to run the test
  4. Click on save button.

Testing Example Of Using Selenium with Git Hub

Step 16) once we click on save below screen will appear,

Now we can build our project click on build.

Testing Example Of Using Selenium with Git Hub

Step 17) It will show the Build, click on build Number or the build date.

Testing Example Of Using Selenium with Git Hub

Step 18) once we click on build number below screen will appear where we can see the console output in this step, click on the console output.

Testing Example Of Using Selenium with Git Hub

Finally, we can verify that our build is successfully completed/executed.

Testing Example Of Using Selenium with Git Hub