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.

Upload Selenium Script to GitHub

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.

In this tutorial, you will learn

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 (/maven-jenkins-with-selenium-complete-tutorial.html)

2) Tomcat Installation Guide (/apache.html)

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.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

Step 14) In this step,

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

Upload Selenium Script to GitHub

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

Step 4) Click on Available TAB

Upload Selenium Script to GitHub

Step 5) In this step,

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

Upload Selenium Script to GitHub

Now it will install the following plugins.

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

Setting Up our Eclipse with GitHub Plugin

Now let's install GitHub Plugin for Eclipse.

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

Step 1) Launch Eclipse and then

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

Step 3) In this step,

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

Upload Selenium Script to GitHub

Step 4) Then click on select all and next

Upload Selenium Script to GitHub

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

Then restart the eclipse.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

Step 3) In this step,

  1. Enter the name of the repository and
  2. click on create repositoryUpload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

Step 2) In this step,

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

Upload Selenium Script to GitHub

Step 3) In this step,

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

Upload Selenium Script to GitHub

Step 4) Click on next

Upload Selenium Script to GitHub

Step 5) In this step,

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

Upload Selenium Script to GitHub

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

Step 6)

Now let's create a sample script

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

Step 13) In this step,

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

We can get the URI in Git Hub

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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

Now we can build our project click on build.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

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.

Upload Selenium Script to GitHub

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

Upload Selenium Script to GitHub

This article is contributed by Chaitanya Pujari

 

YOU MIGHT LIKE: