Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4d45c19
first initial
Jul 13, 2026
01182e0
Section3 lesson
Jul 13, 2026
ca252f9
Merge pull request #1 from ErhanBatu/feature/Section3
ErhanBatu Jul 13, 2026
f9de268
Section4 lesson part1
Jul 13, 2026
ffc9dcb
Merge pull request #2 from ErhanBatu/feature/Section4
ErhanBatu Jul 13, 2026
a49d1d3
Section4 lesson part2
Jul 13, 2026
3757ecf
Merge pull request #3 from ErhanBatu/feature/Section4
ErhanBatu Jul 13, 2026
d96b4aa
Section5 part1
Jul 14, 2026
82dfab8
Merge pull request #4 from ErhanBatu/feature/Section5
ErhanBatu Jul 14, 2026
fc5cd6c
Section5 part2
Jul 15, 2026
20ae82b
Merge pull request #5 from ErhanBatu/feature/Section5
ErhanBatu Jul 15, 2026
61497b3
Section6
Jul 15, 2026
7ba1299
Merge pull request #6 from ErhanBatu/feature/section6
ErhanBatu Jul 15, 2026
049baf2
Section7
Jul 27, 2026
6d09019
Merge pull request #7 from ErhanBatu/feature/section7
ErhanBatu Jul 27, 2026
5bd0c24
API
Jul 31, 2026
27b5a3a
Merge pull request #8 from ErhanBatu/feature/section7
ErhanBatu Jul 31, 2026
6dc56bb
Mock out API
Jul 31, 2026
3c457f4
Merge pull request #9 from ErhanBatu/feature/section11
ErhanBatu Jul 31, 2026
b6da19b
Section12
Jul 31, 2026
abd7375
Merge pull request #10 from ErhanBatu/feature/section12
ErhanBatu Jul 31, 2026
12a01a4
Tracing
Jul 31, 2026
c582feb
Merge pull request #11 from ErhanBatu/feature/section13
ErhanBatu Jul 31, 2026
4d130ec
Section 15 parallel execution
Aug 1, 2026
87291d4
Merge pull request #12 from ErhanBatu/feature/section14
ErhanBatu Aug 1, 2026
3e8ef63
Allure reporting
Aug 2, 2026
f683501
Merge pull request #13 from ErhanBatu/feature/section15
ErhanBatu Aug 2, 2026
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
135 changes: 132 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +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 @@ -27,6 +31,131 @@
<version>5.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-jupiter</artifactId>
<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
@@ -1,15 +1,67 @@
package com.serenitydojo.playwright;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import com.microsoft.playwright.*;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.*;

import java.util.Arrays;

//This annotation allows you to do test without creating playwright environment and browser
//@UsePlaywright
public class ASimplePlaywrightTest {

private static Playwright playwright;
private static Browser browser;
private static BrowserContext browserContext;
Page page;

@BeforeAll
public static void setUpBrowser(){
playwright = Playwright.create();
browser = playwright.chromium().launch(
new BrowserType.LaunchOptions()
.setHeadless(false)
.setArgs(Arrays.asList("--no-sandbox", "--disable-extensions","--disable-gpu"))
);
//this allows paralel execution
browserContext = browser.newContext();

}

@BeforeEach
public void setUp(){
page = browser.newPage();
}

@AfterAll
public static void tearDown(){
browser.close();
playwright.close();
}

@Test
void shouldShowThePageTitle() {
// TODO: Write your first playwright test here

page.navigate("https://practicesoftwaretesting.com/");
String title = page.title();
Assertions.assertTrue(title.contains("Practice Software Testing"));

}

@Test
void shouldSearchByKeyword(){

page.navigate("https://practicesoftwaretesting.com/");
page.locator("[placeholder=Search]").fill("Pliers");
//this is basically sort of xpath
page.locator("button:has-text('Search')").click();

//this will look for the element with card
int matchingSearchResults = page.locator(".card").count();
System.out.println(matchingSearchResults);

Assertions.assertTrue(matchingSearchResults>0);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.serenitydojo.playwright;

import com.microsoft.playwright.*;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.options.AriaRole;
import org.junit.jupiter.api.*;

import java.util.Arrays;
import java.util.List;

@UsePlaywright(HeadlessChromeOptions.class)
public class AddingItemsToTheCartTest {

@DisplayName("Search for pliers")
@Test
void searchForPliers(Page page){
page.navigate("https://practicesoftwaretesting.com/");
// page.locator("[placeholder='Search']").fill("pliers");
page.getByPlaceholder("Search").fill("pliers");
page.getByRole(AriaRole.BUTTON,
new Page.GetByRoleOptions().setName("Search")).click();

Locator products = page.locator(".card").filter(
new Locator.FilterOptions()
.setHas(page.getByAltText("Pliers"))
.setHasNot(page.getByText("Out of stock"))
);

List<String> productNames = products.locator("h5").allTextContents();
System.out.println(productNames);

}














}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.serenitydojo.playwright;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

@UsePlaywright(AnAnnotatedPlaywrightTest.MyOptions.class)
public class AnAnnotatedPlaywrightTest {

public static class MyOptions implements OptionsFactory{

@Override
public Options getOptions() {
return new Options()
.setHeadless(false)
.setLaunchOptions(
new BrowserType.LaunchOptions()
.setArgs(Arrays.asList("--no-sandbox", "--disable-extensions","--disable-gpu"))
);
}
}
@Test
void shouldShowThePageTitle(Page page) {
// TODO: Write your first playwright test here

page.navigate("https://practicesoftwaretesting.com/");
String title = page.title();
Assertions.assertTrue(title.contains("Practice Software Testing"));

}

@Test
void shouldSearchByKeyword(Page page){

page.navigate("https://practicesoftwaretesting.com/");
page.locator("[placeholder=Search]").fill("Pliers");
//this is basically sort of xpath
page.locator("button:has-text('Search')").click();

//this will look for the element with card
int matchingSearchResults = page.locator(".card").count();
System.out.println(matchingSearchResults);

Assertions.assertTrue(matchingSearchResults>0);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.serenitydojo.playwright;

import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;

import java.util.Arrays;

public class HeadlessChromeOptions implements OptionsFactory {


@Override
public Options getOptions() {
return new Options().setLaunchOptions(
new BrowserType.LaunchOptions().setHeadless(false)
.setArgs(Arrays.asList("--no-sandbox", "--disable-extensions", "--disable-gpu"))
)
.setTestIdAttribute("data-test");
}



}
Loading