Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
96fcac3
Sample code for module 4
wakaleo Sep 29, 2024
27f7e1f
Added github actions
wakaleo Sep 29, 2024
667b7fa
Added github actions
wakaleo Sep 29, 2024
e8aaca0
Sample solution
wakaleo Sep 29, 2024
2ab2cb2
Sample solution
wakaleo Oct 1, 2024
f2de3d4
Sample code
wakaleo Oct 3, 2024
356db5a
Sample locators
wakaleo Oct 5, 2024
7fe5610
Sample code for locators
wakaleo Nov 2, 2024
2de8ad6
Sample code for forms
wakaleo Nov 2, 2024
6652af2
Updated sample code
wakaleo Nov 2, 2024
086ec86
Added AssertJ examples
wakaleo Nov 2, 2024
c376b81
Assertj examples
wakaleo Nov 2, 2024
5b7d639
Added examples of wait conditions
wakaleo Nov 2, 2024
1e23c02
Sample code for waits
wakaleo Nov 3, 2024
4d29422
Sample code
wakaleo Nov 4, 2024
06596e2
Updated sample code
wakaleo Nov 5, 2024
6a6644e
Completed sample code
wakaleo Nov 5, 2024
327f38d
Sample code
wakaleo Nov 5, 2024
a1d0d7d
Live coding
wakaleo Nov 5, 2024
1ca022e
Improved the reliability of the API tests
wakaleo Nov 6, 2024
51b8f53
Updated sample code
wakaleo Nov 5, 2024
a935049
Completed sample code
wakaleo Nov 5, 2024
b1e64a1
Live coding
wakaleo Nov 5, 2024
519fbed
Sample code
wakaleo Nov 6, 2024
db6eaf6
Merge branch 'sample-code/module-13-page-objects' of https://github.c…
wakaleo Nov 6, 2024
e9a853b
Sample code
wakaleo Nov 11, 2024
540b70e
Parallel execution
wakaleo Nov 11, 2024
6207131
Sample allure code
wakaleo Nov 11, 2024
fd29a09
Sample solution for Cucumber
wakaleo Nov 12, 2024
41462f5
Sample code
wakaleo Nov 17, 2024
e688905
Data tables
wakaleo Nov 17, 2024
9b67d82
Cucumber sample code
wakaleo Nov 17, 2024
a7313a4
Updated readme
wakaleo Nov 17, 2024
b11efa5
Updated readme
wakaleo Nov 20, 2024
1e34ff0
Sample solution
wakaleo Nov 23, 2024
ab225d0
Sample code
wakaleo Nov 23, 2024
b373e1b
Merged updates
wakaleo Nov 24, 2024
ff430d2
Sample API tests
wakaleo Dec 18, 2024
fbe0935
Added login tests
wakaleo Dec 18, 2024
0b049d0
Added login tests
wakaleo Dec 18, 2024
f08c85f
Completed code sample
wakaleo Dec 19, 2024
0de2a25
Updated user address structure to reflect latest API changes
wakaleo Jun 4, 2025
628609f
Removed parallel execution for some of the tests to avoid flaky test …
wakaleo Jun 4, 2025
a5a2af8
Updated dependencies to Playwright 1.57.0 and JUnit 6.0.1
wakaleo Dec 10, 2025
3505d5f
initial commit
aab1 May 23, 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
52 changes: 52 additions & 0 deletions .github/workflows/playwright-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Playwright Tests

# Trigger the workflow on every push to any branch
on:
push:
branches:
- '**' # Run on every branch for every commit
pull_request:
branches:
- '**' # Run on every pull request for any branch

jobs:
test:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository code
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Set up JDK 17 (adjust if you're using a different version)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

# Step 3: Install Maven 3.9.9
- name: Setup Maven Action
uses: s4u/setup-maven-action@v1.7.0
with:
checkout-fetch-depth: 0
java-version: 17
java-distribution: temurin
maven-version: 3.9.9

# Step 4: Verify Maven installation
- name: Verify Maven version
run: mvn --version

# Step 5: Cache Maven dependencies
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven

# Step 4: Run Maven to execute Playwright tests
- name: Run Playwright Tests
run: mvn verify
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ buildNumber.properties
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
.idea
.allure
allure-results
.idea
133 changes: 131 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,131 @@
# playwright-in-java-sample-code
Sample code for the Serenity Dojo Playwright In Java course.
# Mastering Modern Test Automation With Playwright In Java

This repository contains the sample code for the **[Mastering Modern Test Automation With Playwright In Java](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/?referralCode=06560D474D519B88409D)** course. It is designed to complement your learning experience, providing hands-on examples and exercises for each module of the course.

## About the Course

Modern web testing demands modern solutions, and Playwright has emerged as the go-to testing framework for dynamic web applications. By combining the power of Playwright with Java's enterprise-grade ecosystem, this course will equip you with the skills needed to build reliable, maintainable test automation frameworks.

**Key Highlights:**
- Superior auto-wait and asynchronous testing capabilities
- Multi-browser support for Chromium, Firefox, and WebKit
- Network interception and mocking capabilities
- Rich debugging and codegen tools
- Seamless integration with Java tools like JUnit and Cucumber

You’ll learn:
- Playwright fundamentals, architecture, and best practices
- Writing robust tests for modern web applications
- Using advanced features like API mocking, parallel execution, and CI/CD integration
- Behavior-Driven Development (BDD) using Cucumber
- Generating professional test reports with Allure
- Leveraging AI tools to accelerate test writing

### Access the Course Material
Enroll in the course and access all the learning resources here: [Mastering Modern Test Automation With Playwright In Java](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/?referralCode=06560D474D519B88409D)

---

## Git Branches and Corresponding Udemy Course Modules

The branch structure of this repository follows the convention `sample-code/<module-name>`. Each branch corresponds to a module in the course and contains the sample code for that specific topic. Some of the module branches include:

The table below maps each Git branch in this repository to its corresponding Udemy course module. Click the links to access the relevant lecture directly.

| **Module** | **Git Branch** | **Udemy Lecture Link** |
|--------------------|--------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| Start Here | `sample-code/start-here` | [Start Here](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46063725#overview) |
| Module 3 | `sample-code/module-3-my-first-playwright-test` | [My First Playwright Test](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46077299#overview) |
| Module 4 | `sample-code/module-4-interacting-with-elements` | [Interacting With Field Elements](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46649323#overview) |
| Module 5 | `sample-code/module-5-refactoring` | [Refactoring](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46077309#overview) |
| Module 6 | `sample-code/module-6-browser-options` | [Browser Options](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46110387#overview) |
| Module 7 | `sample-code/module-7-browser-contexts` | [Browser Contexts](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46145035#overview) |
| Module 8 | `sample-code/module-8-locators` | [Locators](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46178143#overview) |
| Module 9 | `sample-code/module-9-forms` | [Forms](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46649323#overview) |
| Module 10 | `sample-code/module-10-assertions` | [Assertions](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46280267#overview) |
| Module 11 | `sample-code/module-11-waits` | [Waits](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46680609#overview) |
| Module 12 | `sample-code/module-12-mocking-api-calls` | [Mocking API Calls](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46728327#overview) |
| Module 13 | `sample-code/module-13-page-objects` | [Page Objects](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46723143#overview) |
| Module 14 | `sample-code/module-14-organizing-your-tests` | [Organizing Your Tests](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46833089#overview) |
| Module 15 | `sample-code/module-15-parallel-execution` | [Parallel Execution](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46835495#overview) |
| Module 16 | `sample-code/module-16-allure-reporting` | [Allure Reporting](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46849301#overview) |
| Module 17 | `sample-code/module-17-cucumber` | [Cucumber](https://www.udemy.com/course/mastering-modern-test-automation-with-playwright-in-java/learn/lecture/46906341#overview) |

---

## How to Use This Repository

The exercises in this repository are designed to build on each other in a sequential order, providing you with a progressive learning experience. Here's how you can make the most of the exercises:

### Step 1: Starting the Exercises
Begin your journey into Playwright and Java test automation by setting up your workspace. You have two options to start:

1. **Use the `sample-code/start-here` branch:**
This branch contains a basic starting point with all the necessary configuration files (like a Maven pom.xml file) to help you get started quickly.
2. **Start with an empty Maven project:**
If you prefer to set up everything from scratch, you can create your own Maven project and follow along with the course to configure it step by step. This approach is great for reinforcing your understanding of the setup process.

### Step 2: Follow Along With the Coding Exercises
Each course module introduces new concepts and techniques, with corresponding exercises for hands-on practice. Follow these steps as you progress:

1. **Follow the Exercises in Order:**
The modules are designed to build upon each other. Completing them in order ensures you gain a solid understanding of each concept before moving to the next.
2. **Reference the Module-Specific Sample Code:**
Each module's sample code is available in the corresponding branch, named sample-code/<module-name>. For example:
- sample-code/module-3-my-first-playwright-test
- sample-code/module-6-browser-options
You can check out these branches to view the sample solution for each module if you get stuck or want to see how the exercises are implemented.

3. **Work on the Exercises in Your Own Branch:**
Create your own branch to experiment with the exercises. For example:
```bash
git checkout -b module-3-exercises
```
This approach allows you to practice and experiment without affecting the main codebase or other branches.

Feel free to submit pull requests or raise issues if you find bugs or areas for improvement.

### Step 3: Using Sample Solutions to Unblock Yourself
If you encounter challenges while working through an exercise:

1. Check the Sample Solution:
Switch to the branch for the current module to review the sample code and compare it with your own:
```bash
git checkout sample-code/<module-name>
```

2. **Learn From the Solution:**
Pay attention to how the concepts are applied and implemented. Take note of any differences between your code and the solution, and try to understand why those differences exist.

### **Step 4: Starting Fresh at Any Point**
If you want to start over or reset your work for a specific module:

1. **Checkout the Previous Module's Sample Code:**
Each module builds on the previous one, and the starting point for a module is the final state of the previous module. For example:
If you are working on Module 5 and want to start fresh, check out the code from sample-code/module-4-interacting-with-elements.
Use the following command:
```bash
git checkout sample-code/<previous-module-name>
```

2. **Create a New Branch From the Previous Module:**
After checking out the previous module's sample code, create a new branch to start your work:
```bash
git checkout -b module-5-exercises
```

3. **Continue From the Reset State:**
Use the previous module's code as the starting point for the new module, and continue with the exercises.


### Step 5: Submitting Your Work
If you are following along as part of the [Serenity Dojo coaching program](http://serenitydojo.academy), you will be able to get feedback about your work from one of the Serenity Dojo coaches. Here is how you do that:

1. Push Your Changes to Your Repository:
Push your completed exercises to your forked repository to save your work:
```bash
git push origin <your-branch-name>
```

2. Share Your Branch:
If requested, share the branch link with your instructor or team for review.
121 changes: 119 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,138 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<allure.version>2.29.0</allure.version>
<aspectj.version>1.9.21</aspectj.version>
</properties>

<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>

<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.47.0</version>
<version>1.48.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.1</version>
<version>5.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.20.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.20.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.20.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
</dependency>
<dependency>
<groupId>com.deque.html.axe-core</groupId>
<artifactId>playwright</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit-platform</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber7-jvm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.datafaker</groupId>
<artifactId>datafaker</artifactId>
<version>2.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.3</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>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.15.0</version>
<configuration>
<reportVersion>${allure.version}</reportVersion>
<resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

This file was deleted.

Loading