Allure Report in Selenium

Profile picture for user arilio666

This article will show how we can set up allure reports in selenium java.

1.) Allure Installation And Setup

  • Go to this link here , and the allure download should start.
  • Extract the zip file and copy the bin path into the environmental variable path.
  • Now when we try to check the version using the allure --version, it should popup.

2.) POM

<properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <aspectj.version>1.9.9.1</aspectj.version>
    </properties>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
    
                
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                    
                        <source>1.8</source>
                        <target>1.8</target>
                        <fork>true</fork>
                        <!--<executable>C:\Program Files\Java\jdk1.8.0_121\bin\javac.exe</executable> -->
                        <executable>${env.JAVA_HOME}\bin\javac.exe</executable>
                    </configuration>
                </plugin>
                
            </plugins>
        </pluginManagement>
    </build>
    
    
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
   <groupId>org.aspectj</groupId>
   <artifactId>aspectjweaver</artifactId>
   <version>1.9.19</version>
</dependency>
    <dependency>
 <groupId>io.qameta.allure</groupId>
 <artifactId>allure-testng</artifactId>
 <version>2.17.3</version>
</dependency>
  • Add these dependencies and surefire plugins into the pom file before proceeding.

3.) Clean

Go to your maven project folder and open the terminal, and type in:

mvn clean test

4.) Run Test.

Let us run this testng test and generate the report.

public class PopUp {
    @Test
    public void popUp() throws Throwable {
        WebDriverManager.chromedriver().setup();
        ChromeDriver driver = new ChromeDriver();
        driver.get("https://www.programsbuzz.com/");
        driver.manage().window().maximize();
        Thread.sleep(3000);
        List<WebElement> elementTexts = driver.findElements(By.xpath("//div[@class='header__main__left']"));
        for (WebElement webElement : elementTexts) {
            System.out.println(webElement.getText());
        }
    }
}

Type in:

 allure serve allure-results
  • Reports should be opened from the temp directory, where reports are generated after every run.
  • This is what the allure report looks like.