In this blog we will be utilizing Playwright Java to generate allure reports.
Topics that we will cover:
- Add aspectj version in the properties section of pom.xml
- Add 3 properties in the properties section of pom.xml
- Add maven allure testng dependency
- Add ‘aspectjweaver’ setting in pom.xml
- Maven install
- Run any sample testng test
- Manually install allure commandline
- Execute “allure serve allure-results”
- POM.xml
- Source code
Add aspectj version in the properties section of pom.xml
Copy below section
<properties>
<aspectj.version>1.8.10</aspectj.version>
</properties>
Paste it in the propertes section of pom.xml

Add 3 properties in the properties section of pom.xml
We will now copy and paste 3 properties in ‘properties’ tag section
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

Add maven allure testng dependency
Next we will copy the latest (stable) maven allure testng dependency
https://mvnrepository.com/artifact/io.qameta.allure/allure-testng/2.26.0

Save xml.
Add ‘aspectjweaver’ setting in pom.xml
Copy below snippet

Save xml.
Maven install
Right click xml > Run As > Maven Install

“BUILD SUCCESS” message should be seen in console

The test gets passed

Manually install allure commandline
Go to
https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/
Look for the latest version

Click latest version and look for windows zip file

Click the zip file to download the same

Copy the above path upto bin folder

Open command propmt and execute ‘allure --version’ command to see the allure version


Execute “allure serve allure-results”
Execute the command “allure serve allure-results”


The report gets launched and it shows the overview of 1 test that was executed successfully

Below is ‘Graphs’ representation

This is how allure report can be generated using playwright.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rahulshettyacademy</groupId>
<artifactId>PlaywrightJava</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<aspectj.version>1.8.10</aspectj.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.40.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.26.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}\org\aspectj\aspectjweaver\${aspectj.version}\aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Source code
package com.rsa.playwrightjava;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
public class Blog28_TestNGTest_PWJava {
private Browser browser;
private Page page;
@BeforeMethod
public void setUp() {
Playwright playwright = Playwright.create();
browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
page = browser.newPage();
}
@Test
public void test_1() {
page.navigate("https://the-internet.herokuapp.com/iframe");
Locator frame1 = page.frameLocator("#mce_0_ifr").locator("html");
frame1.click();
frame1.type("https://rahulshettyacademy.com");
}
@AfterMethod
public void tearDown() {
page.pause();
browser.close();
page.close();
}
}
Thanks.