{{announcement.body}}
{{announcement.title}}

Adding a Selenium-Maven Project From Eclipse to GitHub Repository

DZone 's Guide to

Adding a Selenium-Maven Project From Eclipse to GitHub Repository

How to add a Selenium project created in Eclipse using Maven to GitHub public Repository.

· Open Source Zone ·
Free Resource

In this article, we will understand how to create a simple Selenium project using Maven in Eclipse and we will see how to push the project to GitHub Repository.

How to Create Selenium Test in Eclipse?

Step 1: File -> New -> Project -> Maven Project

maven project

Step 2: Check “Create a simple project (skip archetype selection) and say “Next”

simple project

Step 3: Name Group Id and Artifact Id as “MySeleniumProject” and say “Finish”. You can name as any name as you wish

configure project

Step 4: Create a new package “mySeleniumPackage” under src/test/java of our Maven project and say “Finish”.

new java package

Step 5: Create a new class “OpenFacebook” under mySeleniumPackage and enable main()

new java class

Step 6: Update the pom.xml file of the Maven project with latest Selenium and TestNG dependencies

code

Step 7: Create a Selenium test to open Facebook home page in Firefox browser by loading the geckodriver.exe and get the title of the webpage

code

Step 8: Create a xml file named “testing.xml” in our Maven project to run the created testcase. Add the below code. Mention the package name and the class name where we have our Selenium test in the format packagename.classname

Please note:- This step is optional and it is required to run the test as batch and if we need to run the test in any continuous integration server like Jenkins

code

Step 9: Run the testing.xml file as TestNG Suite to ensure everything is working fine in our local system

***********************************************************************************************

How to create a public GIT Repository?

Step 1: Open www.github.com

Step 2: Sign Up and register a free account in github.com

Step 3: Login to www.github.com and create a new repository selecting “New” button

repositories

Step 4: Give a name for your repository “SeleniumProject”, select Public and say “Create repository”. Providing “Public” access enables anyone to see your repository. If you want to restrict access to your repository, you can select as “Private”

create new repository

Step 5: This creates a public repository in github.com and it can be accessed using the URL – https://github.com/remijullian/SeleniumProject.git

How to Push Your Selenium Project to GitHub

Step 1: Install GIT locally in system. Go to URL -> https://git-scm.com/download/win and download GIT for Windows based on your operating system whether it is 32 bit or 64 bit.

Step 2: Install GIT in the local system by following the installation steps. This step is important to create a local repository in our system.

Step 3: Go to Eclipse, select your project “MySeleniumProject” -> Right Click -> Team -> Share Project

Step 4: Configure Git repository. This step is to create a local repository of our Selenium project in our system. Check “Use or create repository in parent folder of project” and select “Create Repository” and say “Finish”. This creates a .git file in the physical location of the selenium project. In our case, the local repository is created at “C:\RemiFiles\Backup4\Projects\Selenium\MySeleniumProject.git”

configure git repository

Step 5: Our project in eclipse is connected to local repository. If we want to push the project to remote repository, right click the project -> Team -> Commit

commit

Step 6: Eclipse will open a “Git Staging” window. We will find 3 sections – Unstaged Changes, Staged Changes and Commit Message.

Step 7: Unstaged Changes are the new files that needs to get updated in the shared repository.   If we need to add code to shared repository, we need to move Unstaged Changes to Staged Changes. Once moved, provide a “Commit message” and select “Commit and Push”. Commit message enables others to understand what changes has been made to the existing code in Git Repository

git staging

Step 8: Give the details of the shared repository where we wish to push the Selenium code. Also give the Authentication credentials to connect to shared repository and push the code

destination of git repository

Step 9: Accept the confirmation message on the details of the shared repository where to push the files. Click the “Finish” button

push configuration

Step 10: Confirm the credentials once again to push

confirm credentials

Step 11: Once the project gets pushed successfully to remote repository, we will get a confirmation message as below:

push results

Step 12: Go to remote repository and refresh the page. We can able to see the Selenium project contents got updated there along with the commit message we have issued in eclipse

project in github

Conclusion

This is how we can create a Selenium project in eclipse and update in GIT repository. We can further clone the project if we need a local copy on a different system or pull the project to update the local repository with the recent changes made in the remote repository.

Thanks for reading this article. For any queries please reach out to me.

Topics:
git and github, maven, open source, selenium, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}