Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 112 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<allure.version>2.35.2</allure.version>
<allure.maven.version>2.15.2</allure.maven.version>
<playwright.version>1.60.0</playwright.version>
<aspectj.version>1.9.24</aspectj.version>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.60.0</version>
<version>${playwright.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -38,16 +40,122 @@
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-jupiter</artifactId>
<version>${allure.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
<version>2.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-bom</artifactId>
<version>${allure.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>

<configuration>
<release>${maven.compiler.release}</release>

<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>

<fork>true</fork>

<executable>
/Users/erhanbatu/Library/Java/JavaVirtualMachines/temurin-21.0.11/Contents/Home/bin/javac
</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.6</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.6</version>

<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>

<configuration>
<jvm>
/Users/erhanbatu/Library/Java/JavaVirtualMachines/temurin-21.0.11/Contents/Home/bin/java
</jvm>

<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>

<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>

<systemPropertyVariables>
<allure.results.directory>
${project.build.directory}/allure-results
</allure.results.directory>
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.version}</version>
<configuration>
<reportVersion>2.44.0</reportVersion>
<resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
</configuration>
<executions>
<execution>
<id>allure-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.serenitydojo.playwright.toolshop.catalog.pageobjects.ProductList;
import com.serenitydojo.playwright.toolshop.catalog.pageobjects.SearchComponent;
import com.serenitydojo.playwright.toolshop.fixtures.PlaywrightTestCase;
import com.serenitydojo.playwright.toolshop.fixtures.ScreenshotManager;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.assertj.core.api.Assertions;
Expand Down Expand Up @@ -31,7 +32,9 @@ void whenSearchingByKeyword() {
SearchComponent searchComponent = new SearchComponent(page);
ProductList productList = new ProductList(page);

ScreenshotManager.takeScreenshot(page, "ss1");
searchComponent.searchBy("tape");
ScreenshotManager.takeScreenshot(page, "ss2");

var matchingProducts = productList.getProductNames();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.microsoft.playwright.Page;
import com.microsoft.playwright.options.AriaRole;
import com.serenitydojo.playwright.toolshop.fixtures.PlaywrightTestCase;
import io.qameta.allure.Step;


public class ProductDetails {
private final Page page;

Expand All @@ -27,5 +29,6 @@ public void addToCart() {
page.getByRole(AriaRole.ALERT).click();
}
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.microsoft.playwright.Page;
import com.serenitydojo.playwright.toolshop.fixtures.ProductSummary;
import com.serenitydojo.playwright.toolshop.fixtures.ScreenshotManager;
import io.qameta.allure.Step;

import java.util.List;
Expand Down Expand Up @@ -31,6 +32,7 @@ public List<ProductSummary> getProductSummaries() {
@Step("View product details")
public void viewProductDetails(String productName) {
page.locator(".card").getByText(productName).click();
ScreenshotManager.takeScreenshot(page,"view product details");
}

public String getSearchCompletedMessage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.serenitydojo.playwright.toolshop.fixtures;

import com.microsoft.playwright.*;
import io.qameta.allure.Allure;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

import java.io.ByteArrayInputStream;
import java.util.Arrays;

public abstract class PlaywrightTestCase {
Expand Down Expand Up @@ -38,9 +40,17 @@ void setUpBrowserContext() {

@AfterEach
void closeContext() {
takeScreenshot("End of test");
browserContext.close();
}

protected void takeScreenshot(String name){
var screenshot = page.screenshot(
new Page.ScreenshotOptions().setFullPage(true)
);
Allure.addAttachment(name, new ByteArrayInputStream(screenshot));
}

@AfterAll
static void tearDown() {
browser.get().close();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.serenitydojo.playwright.toolshop.fixtures;

import com.microsoft.playwright.Page;
import io.qameta.allure.Allure;

import java.io.ByteArrayInputStream;

public class ScreenshotManager {

public static void takeScreenshot(Page page, String name){
var screenshot = page.screenshot(
new Page.ScreenshotOptions().setFullPage(true)
);
Allure.addAttachment(name, new ByteArrayInputStream(screenshot));
}
}
1 change: 1 addition & 0 deletions src/test/resources/allure.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allure.results.directory=target/allure-results