Skip to content

mk868/selenium-example-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Selenium Example Project

Project base for automated testing using Selenium & java. To show the application in action, several pages and page fragments for https://www.saucedemo.com/ have been implemented.

Assumptions

  • Use Selenium with Page Object Model (POM) pattern.

  • Avoiding calling Thread.sleep(…​) in favor of WebDriverWait.until(…​) with custom expected conditions.

  • WebDriver injected into test classes:

    • We can define the implementation and configuration of WebDriver in a test XML file,

    • We can reuse WebDriver in all test scope classes.

  • Reports with Allure framework.

Test XML definition

Look at the testng.xml file. In the configuration file, we can specify the browser and its configuration to be used in the test.

<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >

<suite name="all">
  <!-- run tests on Firefox with a FullHD window size -->
  <test name="test1">
    <parameter name="browser" value="firefox FullHD"/>
    <classes>
      <class name="mk.automation.test.LoginTest"/>
    </classes>
  </test>
  <!-- run tests on Chrome with a default window size -->
  <test name="test2">
    <parameter name="browser" value="chrome"/>
    <classes>
      <class name="mk.automation.test.LoginTest"/>
    </classes>
  </test>
  <!-- run tests on Chrome with a window size 800x600 -->
  <test name="test3">
    <parameter name="browser" value="chrome 800x600"/>
    <classes>
      <class name="mk.automation.test.LoginTest"/>
      <class name="mk.automation.test.ProductsPageTest"/>
    </classes>
  </test>
</suite>

Implementation

The list of interesting classes:

How to run

Preparation

Required software:

  • Maven 3.8.x or later

  • JDK 17

  • Firefox

  • geckodriver

  • Google Chrome

Run tests with maven

To run tests call:

mvn test

Reports

To display reports type in shell:

cd ./target/site/allure-maven-plugin
jwebserver -p 8080

Or use maven:

mvn allure:serve

Technical Info

What’s used:

  • Java 17

  • TestNG

  • Selenium 4.x

  • Allure

  • Guice

About

Sample test automation project using Selenium and java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages