[Selenium+Java] Upload Selenium Script to GitHub

Original URL: https://www.guru99.com/selenium-github.html

Upload Selenium Script to 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.

[Selenium+Java] Upload Selenium Script to GitHub_第1张图片

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

  • Git Binaries Installation

  • Jenkins Git Plugin Install

  • Setting Up our Eclipse with GitHub Plugin

  • Building a repository on Git

  • Testing

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.

[Selenium+Java] Upload Selenium Script to GitHub_第2张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第3张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第4张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第5张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第6张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第7张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第8张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第9张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第10张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第11张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第12张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第13张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第14张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第15张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第16张图片

Step 4) Then click on select all and next

[Selenium+Java] Upload Selenium Script to GitHub_第17张图片

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

Then restart the eclipse.

[Selenium+Java] Upload Selenium Script to GitHub_第18张图片

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 repository[Selenium+Java] Upload Selenium Script to GitHub_第19张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第20张图片

Step 2) In this step,

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

[Selenium+Java] Upload Selenium Script to GitHub_第21张图片

Step 3) In this step,

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

[Selenium+Java] Upload Selenium Script to GitHub_第22张图片

Step 4) Click on next

[Selenium+Java] Upload Selenium Script to GitHub_第23张图片

Step 5) In this step,

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

[Selenium+Java] Upload Selenium Script to GitHub_第24张图片

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

Step 6)

Now let's create a sample script

[Selenium+Java] Upload Selenium Script to GitHub_第25张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第26张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第27张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第28张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第29张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第30张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第31张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第32张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第33张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第34张图片

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

Now we can build our project click on build.

[Selenium+Java] Upload Selenium Script to GitHub_第35张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第36张图片

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.

[Selenium+Java] Upload Selenium Script to GitHub_第37张图片

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

[Selenium+Java] Upload Selenium Script to GitHub_第38张图片

This article is contributed by Chaitanya Pujari

 

转载于:https://www.cnblogs.com/alicegu2009/p/9098817.html

你可能感兴趣的:([Selenium+Java] Upload Selenium Script to GitHub)