Github Integration with Selenium: Complete Tutorial
โก Smart Summary
GitHub integration with Selenium places the automation project in one shared remote repository, so every team member pulls the same code and Jenkins builds each change directly from that repository without any manual copying.
What is GitHub?
GitHub is a collaboration platform built on top of Git. It allows you to keep both a local and a remote copy of your project, so a project can be published among team members who use and update it from there.
Advantages of using GitHub for Selenium:
- When multiple people work on the same project they can update project details and inform other team members simultaneously.
- Jenkins can regularly build the project from the remote repository, which helps us keep track of failed builds.
Prerequisite for Selenium and GitHub Integration
Before we start Selenium and GitHub integration, we need to install the following components.
- Jenkins installation
- Maven installation
- Tomcat installation
You can find the installation steps in the following guides:
The screenshot below shows the Selenium Maven project we will share to GitHub.
Git Binaries Installation
Now let us start by installing the Git Binaries.
Step 1) Launch the browser and navigate to https://git-scm.com/
Step 2) Download the latest stable release.
Step 3) Click on the download for Windows, then begin the installation.
Step 4) Go to the download location or icon and run the installer.
Step 5) Click through the welcome screen and the General Public License.
Step 6) Click on the next button in the Git setup wizard.
Step 7) Read the GNU General Public License and click on next.
Step 8) In the next window,
- Select the directory where you want to install the Git Binaries, and
- Click on the next button
Step 9) Select the components you want to install and click on next.
Step 10) If you want to create a start menu folder for Git, leave the setting default and click on next.
Step 11) In this step,
- Select Use Git from the Windows Command Prompt so Git runs from the command line, and
- Click on next, leave the default setting and click next again.
Step 12) In this step,
- Select Use OpenSSH. It lets us run the command from the command line and sets the environment path.
- Click on the next button.
Step 13) In this step,
- Select “Checkout Windows-style, commit Unix-style line endings” (this controls how Git should treat line endings in text files).
- Click on the next button.
Step 14) In this step,
- Select Use MinTTY, the default terminal of MSys2, for Git Bash
- Click on the next button
The installer then copies the files across.
Open the command prompt, type “git” and hit Enter. The screen below confirms a successful installation.
Jenkins Git Plugin Install
With Git installed, Jenkins needs its own plugin to read a GitHub repository.
Step 1) Launch the browser and navigate to your Jenkins.
Step 2) Click on Manage Jenkins.
Step 3) Click on Manage Plugins. It will open another window.
Step 4) Click on the Available tab.
Step 5) In this step,
- Select the GitHub plugin, then
- Click on the Download now and install after restart button.
โ ๏ธ Current Jenkins UI: the entry is now Manage Jenkins > Plugins and the tab is Available plugins. The screens keep the older labels; the actions are unchanged.
Jenkins now installs the GitHub plugin and its dependencies. Once finished, restart your Tomcat server by calling the shutdown.bat file.
After restarting Tomcat and Jenkins we can see the plugins listed in the Installed tab.
Setting Up our Eclipse with GitHub Plugin
The update site for the EGit plugin is https://download.eclipse.org/egit/updates/
โ ๏ธ Version note: Eclipse IDE for Java Developers now bundles EGit. Check Window > Show View > Git first and skip this section if the view already exists.
Step 1) Launch Eclipse and then
- Click on the Help menu, then
- Click on Install New Software
Step 2) The screen below opens once we click on Install New Software. Now click on Add.
Step 3) In this step,
- Type the name “EGIT” and
- Enter the location https://download.eclipse.org/egit/updates/, then
- Click on OK.
Step 4) Then click on Select All and next.
Step 5) Click on next, accept the license agreement, then finish the installation and restart Eclipse.
Building a repository on Git
Step 1) Navigate to https://github.com/ and sign up for GitHub.
Step 2) Once you have successfully signed up, click on create new repository.
Step 3) In this step,
- Enter the name of the repository, and
- Click on Create repository
Testing Example Of Using Selenium with GitHub
Step 1) Once we are done with the new repository, launch Eclipse.
- Click on File
- Then click on New, and then
- Click on Other
Step 2) In this step,
- Select Maven Project and browse the location.
- Click on next
Step 3) In this step,
- Select the project name and location, then
- Click on next
Step 4) Click on next.
Step 5) In this step,
- Enter Group Id and
- Artifact Id, and
- Click on the Finish button.
As soon as you click on the Finish button, a project will be created.
Step 6) Now let us create a sample script.
Step 7) Now push the local repository to GitHub.
- Open Eclipse and then navigate to the project
- Right-click on the project and select Team, then
- Select Share Project
Step 8) Clicking Share Project opens another window. In this step,
- Select the local repository, and
- Click on Finish.
Once we click on Finish, the project structure changes to show that a local repository was created.
Step 9) In this step,
- Right-click on the project and Team, then
- Click on Commit
Step 10) In this step,
- Enter a commit message and
- Select the files we want to send to the GitHub repository
- Click on Commit and Push
โ ๏ธ Authentication note: GitHub stopped accepting account passwords for Git operations in August 2021. Supply a personal access token with the repo scope instead, or configure an SSH key.
The project icons then change, showing that the code was committed and pushed to GitHub.
The GitHub repository confirms the project was pushed.
Now we execute the project from GitHub in Jenkins.
Step 11) Launch the browser and open your Jenkins.
Step 12) Click on New Item.
Step 13) In this step,
- Enter the item name
- Select Maven Project
- Click on the OK button
Step 14) In this step, we will configure GitHub in Jenkins.
- Click on Git, and
- Enter the repository URI
- Click on Add Repository
With multiple repositories in GitHub, add the name in the Refspec field.
We can get the URI from the GitHub repository page.
Step 15) In this step,
- Add the pom.xml file location in the textbox and
- Specify the goals and options for Maven, then
- Select the option for how to run the test
- Click on the Save button.
Step 16) The screen below appears. Build the project by clicking on Build.
Step 17) It will show the build. Click on the build number or the build date.
Step 18) The screen below appears. Click on Console Output.
Finally, we can verify that our build completed successfully. The same job can then feed a CI/CD pipeline or a freestyle project.















































