Once you have learnt writing the Selenium Tests by implementing various different framework, the next step is to understand how to share the code repository with team, version control, Concepts of CI/CD and the tools that help in achieving that.
So the first step is to setup a sample test script with the help of Maven Project (You can setup a ordinary java project too, in which case the configuration steps in Jenkins would differ from what i’ve explained in this post). Below is my Test class
public class SimpleSearchTest {
WebDriver googleDriver;
@Test
public void searchTest(){
File file = new File("C:/Selenium/JarFiles/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
googleDriver = new ChromeDriver();
googleDriver.get("https://www.google.com/");
WebElement searchTxt = googleDriver.findElement(By.name("q"));
searchTxt.sendKeys("vishwas");
}
public void somef(){
}
}
So first lets see how to setup and maintain a local code repository and then shared code repository. A remote repository can be shared privately or with public.
Once you setup the repository, you can commit the code to this repository. Time stamp of the commit, developer name, commit message will be saved with the commit so that at anytime, one can see who did changes to central repository. Also, you can pull the repository to your local and start working on it anytime.
I used Git to create and share my code repository. You can find the detailed steps to setup GitHub in this link: Selenium Github Tutorial in Guru99
Points to Note:
- For the first time when you share the code, a local git repository is created by Git. For this to happen, you need to install Git in your local. The same website guru99 will help you with step by step process of installation
- If you want to commit it to GitHub(online central repo) then you will do Team–> commit
- You will notice a GitStaging window gets activated in your eclipse(note: i am using eclipse Neon. Git Plugin is pre-installed, so i didn’t install it again)
- Since Eclipse has git plugin, you need not again work on command prompt and pass the commands with file location etc, to commit the code, everything can be done in eclipse (i suggest you to watch is video tutorial so that you will appreciate how much of a headache of working on command prompt is eliminated by eclipseGit video tutorial)
- In GitStaging window, it will show you what files are ready to be staged to git Staging server and then committed to your remote repository. See the screenshot below

- You can select the files you want to push to the Staged changes window. Files are now ready to be committed to GitHub
- Enter the message, select the Author, contributor and click commit and push. Done.
- At any given time, you can also pull the version of code you have in GitHub and start working on it.
That is it, you are all set to use one of the most popular source version control system. Note that the free version of github is public repository – i.e anyone can search and locate your repository and see the code.
You can also explore other options like BitBucket-SourceTree for helping you with version control repository.
So now lets switch to the topic of build Automation i.e performing auto build of our Selenium Scripts.
There are several options available to do the job of performing build automation. But the most popular among the lot is Jenkins. I am going to discuss about the same below.
I suggest you to learn what-why-how of Jenkins by going through this edureka video
This learn-automation Video tutorial provides step by step details of creating a Jenkins Maven project and integrate it with your Selenium Test project (Maven based). In the video, the instructor has not used online repository(github) as source. However, the steps would remain the same even if you have your project in GitHub except the following:
- You need to select Git as your source repository (git plugin may needs to be installed)

- You need to specify the pom.xml path as /<projectName>/pom.xml

Save and that’s it. Done. You have setup auto-build job. Depending on build trigger you have selected, the build process will start, runs you test cases and reports the results.
Note that when you run the job, depending on which OS you are using, you may or may not get to see the Test run on browser. In my case, i am using windows 7. All i had to do was, make some changes to Jenkins service in windows services as mentioned here. Once done, i restarted my Jenkins. Next time when i ran the job, a small window opened as shown below.

When i clicked on View the message, I navigated to the server where Jenkins was running the Test. The browser window was seen there.