Skip to content

Commit 8e3b9df

Browse files
committed
Added github actions
1 parent 96fcac3 commit 8e3b9df

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Playwright Tests
2+
3+
# Trigger the workflow on every push to any branch
4+
on:
5+
push:
6+
branches:
7+
- '**' # Run on every branch for every commit
8+
pull_request:
9+
branches:
10+
- '**' # Run on every pull request for any branch
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
# Step 1: Check out the repository code
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
# Step 2: Set up JDK 17 (adjust if you're using a different version)
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '17'
26+
distribution: 'adopt'
27+
28+
# Step 3: Cache Maven dependencies to speed up future builds
29+
- name: Cache Maven dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.m2
33+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
34+
restore-keys: |
35+
${{ runner.os }}-maven
36+
37+
# Step 4: Run Maven to execute Playwright tests
38+
- name: Run Playwright Tests
39+
run: mvn verify
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
11
package com.serenitydojo.playwright;
22

3-
import com.microsoft.playwright.Browser;
43
import com.microsoft.playwright.Page;
5-
import com.microsoft.playwright.Playwright;
6-
import com.microsoft.playwright.impl.AssertionsTimeout;
4+
import com.microsoft.playwright.junit.UsePlaywright;
75
import org.junit.jupiter.api.Assertions;
86
import org.junit.jupiter.api.Test;
97

8+
@UsePlaywright
109
public class ASimplePlaywrightTest {
1110

1211
@Test
13-
void shouldShowThePageTitle() {
14-
Playwright playwright = Playwright.create();
15-
Browser browser = playwright.chromium().launch();
16-
Page page = browser.newPage();
17-
12+
void shouldShowThePageTitle(Page page) {
1813
page.navigate("https://practicesoftwaretesting.com");
1914
String title = page.title();
2015

2116
Assertions.assertTrue(title.contains("Practice Software Testing"));
22-
23-
browser.close();
24-
playwright.close();
2517
}
2618

2719
@Test
28-
void shouldShowSearchTermsInTheTitle() {
29-
Playwright playwright = Playwright.create();
30-
Browser browser = playwright.chromium().launch();
31-
Page page = browser.newPage();
32-
20+
void shouldShowSearchTermsInTheTitle(Page page) {
3321
page.navigate("https://practicesoftwaretesting.com");
3422
page.locator("[placeholder=Search]").fill("Pliers");
3523
page.locator("button:has-text('Search')").click();
3624

3725
int matchingProductCount = page.locator(".card-title").count();
3826

3927
Assertions.assertTrue(matchingProductCount > 0);
40-
41-
browser.close();
42-
playwright.close();
4328
}
4429
}

0 commit comments

Comments
 (0)