What is GitHub?
GitHub is a Collaboration platform. It is built on top of git. It allows you and others to collaborate on projects from anywhere. A project which you can publish it among your team members as they can use it and update it from there itself. GitHub allows you to create, store, change, merge, and collaborate on files or code.
Advantages of Using GitHub for Selenium.
Since most of the operations are preferred locally, it allows huge benefits in terms of speed. It provides good backup
When multiple people work on the same project, they can update project details and inform other team members simultaneously.
Here the chance of losing data is very low as it provides the multiple copies of it.
Basic Terminologies
Let us become familiar with the basic terminologies associated with GitHub.
1. Pull Request: If you have made changes in code/script, to show the other collaborators you send a pull request.
2. Repository: You can simply, treat it as a storage area of your workplace that contains all your documentation files and the history of changes.
3. Fork: It is a copy of other’s repository in your account in which you can make changes and it won’t affect the original code.
4. Commit: Whatever the changes you make in your files will come under commit. Every change is saved under a particular name or ID which is also called “revision”.
5. Branching: When you extract a portion /section of code from the main or remote track of your software, then it is called ‘branch’ and the process is known as Branching.
Difference Between Git and GitHub
While learning about GitHub you will come across the term “git” which is commonly confused with GitHub itself by so many people that it has started its own discussions.
So in order to learn more about GitHub it only makes sense that before we move any further with how to use GitHub let’s first clear out any and all confusions between git and GitHub.
So here I have listed some key differences between these two. Let’s take a quick look at these to understand both of these individually.
Git | GitHub |
Git is a tool to execute version control. | GitHub is a platform that utilizes Git to carry out its functionalities. |
It is a software and in order to be used it has to be installed. | It is web based hosting service so there is no hassle of installation. |
It is a command line tool. | It provides a graphical user interface. |
Git provides features like management of edited files. | It has some additional features of its own like task management along with the features that come with the benefit of using git. |
Prerequisite for Selenium and Github Integration
Before we start selenium and github integration, we need to install the following components.
1. Jenkins Installation.
2. Maven Installation.
3. Tomcat Installation.
4. Git Installation.
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
Step 3) In this step,
1. Enter the name of the repository and
2. click on create repository
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
Step 2) In this step,
1. Select Maven Project and browse the location.
2. Click on next
Step 3) In this step,
1. Give GroupID and Artifcat ID then
2. Click on Finish
As soon as you click on finish button, a project will be created.
Step 4) Now lets create a sample script, in the sample Script I wrote code to get the title of the webpage of NumpyNinja.
Step 5) 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.
Step 6) 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.
3.Once we click on Finish, we can see the change in the project structure that we have created a local repository.
Now it’s time to push our code to Git Hub Repository
Step 7) In this step,
1. Right-click on the project and team then
2. Click on commit
Step 8) In this step,
1. Select the files which we want to send to Git Hub repository, it is called as Staging area.
2. Enter a commit message and
3. Click on commit and push
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.
We can verify in the Git hub in the repository that our project is successfully pushed into repository
Now it’s time for executing our project from Git Hub in Jenkins
Step 9) Launch browser and open your Jenkins.
Step10) Click on new Item.
Step 11) In this step,
1. Enter Item name
2. Select Maven Project
3. Click on ok button.
Step 12) In this step, we will click on manage Jenkins under Dashboard
Step 13) Click on Tools, We will give installation details for JDK, Git, Ant, Maven
You can give the details like for JDK Installations,
1. Any name under the Name
2. Path of the jdk in your local System.
You can give the details like for Git Installations,
1. Any name under Name.
2. Give the path to Git executable as git or full path of Git from your system.
You can give the details like for Ant Installations,
1. Any name under Name.
2. Click on Install automatically, choose the version.
You can give the details like for Maven Installations,
1. Any name under Name.
2. Click on Install automatically, choose the version.
Step 14) In this step, we will configure Git Hub in Jenkins
1. Click on Git and
2. Click on Add repository
3. Enter the Repository URI
If you have multiple repositories in Git Hub, you need to add name Refspec field of the repository.
We can get the URI in 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.
Step 16) once we click on save below screen will appear,
Now we can build our project click on build.
Step 17) It show the Build, click on build Number or the build date.
Step 18) we click on build number below screen will appear where we can see the console output in this step, click on the console output.
Finally, we can verify that our build is successfully completed/executed.
Nice Blog
Very informative and clear explanation