DEV Community

Anne Quinkenstein
Anne Quinkenstein

Posted on


Building a Selenium Framework

Create a Maven Project

1. Create new Maven Project

-> Maven - new Project - maven-quickstart - GroupID + ArtifactID

2. Add all Dependencies in pom.xml

Add from Maven Repro: Selenium & TestNG

3. Create Base and utility functions

Create base Class in main/java & add Browser Invocation

  • create a resources Package in main/java
  • create a file "" to store data in a central place store things like browser = chrome
  • envoce it in the base.file
Properties prop = Properties(); 
FileInputStream fis = new FileInputStream("//home//helloworld//Documents//Code//Ecplise//SampleProject//E2EProject//src//main//java//SampleProject//"); 
String browsername = prop.getProperty("browser");
Enter fullscreen mode Exit fullscreen mode

Find absolute path of in rightclick Properties
put it in the FileInputStream

if (browserName == "chrome") 
            System.setProperty("", "C://home//helloworld//chromedriver"); 
driver = new ChromeDriver(); 
} else if .... 
// instead of former implicitly Wait: 
new WebDriverWait(driver, Duration.ofSeconds(10));
return driver; 
Enter fullscreen mode Exit fullscreen mode

4. Organizing Page objects

  • Adding Tests
  • Datadriving/ Prameterizing Tests
  • Converting into TestNG Framework
  • TestNG Listeners
  • Screenshot on Test Failures
  • Creating Excellent HTML reports for Test Results
  • Jenkins Continuous Integration

Top comments (0)

5 Websites To Learn Frontend Web Development Faster 💨

>> Check out this classic DEV post <<