Selenium with Maven

To execute Selenium with local maven Repository we need to follow the steps –

1. First create a Maven Project. Goto File -> New->Others -> Select Maven Project

2. Click on Next and make a check on “Create a simple project”

3. Click on Next and you need to provide the following information and after that click Finish

4. Now in Project Explorer you can see the following structure

5. Click on “pom.xml” and we will find the repository location as –

      <name>Central Repository</name>

6. Now if we have changed our maven default repository location (.m2 folder) , we need to set it in eclipse
A. Click on Windows and Navigate to Preferences

B. Select User Settings under Maven option

C. Browse the settings.xml from Maven’s conf folder and it will change the local repository path.

7. Click Ok and again open “pom.xml” and change the repository node as –

          <name>Local project libraries</name>

8. Now add dependencies in “pom.xml”


9. Now Create a sample test class

10. And the sample code should look like –

package com.testwebsite;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class FirstTest {
	public WebDriver driver;
	private String baseUrl;
	public void test1()
		baseUrl = "";		
		driver = new FirefoxDriver();
		try {
		} catch (InterruptedException e)             


11. After executing this code (as testng code) we will get the testng report.

That’s it 🙂

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *