Skip to content

Commit 6796423

Browse files
wakaleoclaude
andcommitted
docs: Update versions to 5.2.4 and modernize Screenplay Playwright examples
Update dependency versions across documentation pages (Serenity 5.2.4, JUnit 6.0.3, Cucumber 7.34.2, Playwright 1.58.0). Update the Screenplay Playwright reference to recommend @UsePlaywright + withPage(page) as the primary approach, with manual lifecycle management as an alternative. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2065762 commit 6796423

7 files changed

Lines changed: 86 additions & 32 deletions

File tree

docs/cucumber/cucumber-junit5.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Add the following dependencies to your `pom.xml`:
3232

3333
```xml
3434
<properties>
35-
<serenity.version>5.2.2</serenity.version>
36-
<cucumber.version>7.33.0</cucumber.version>
37-
<junit.version>6.0.1</junit.version>
35+
<serenity.version>5.2.4</serenity.version>
36+
<cucumber.version>7.34.2</cucumber.version>
37+
<junit.version>6.0.3</junit.version>
3838
</properties>
3939

4040
<dependencies>
@@ -70,9 +70,9 @@ For Gradle, add to your `build.gradle`:
7070

7171
```groovy
7272
dependencies {
73-
testImplementation "net.serenity-bdd:serenity-cucumber:5.2.2"
74-
testImplementation "io.cucumber:cucumber-junit-platform-engine:7.33.0"
75-
testImplementation "org.junit.platform:junit-platform-suite:6.0.1"
73+
testImplementation "net.serenity-bdd:serenity-cucumber:5.2.4"
74+
testImplementation "io.cucumber:cucumber-junit-platform-engine:7.34.2"
75+
testImplementation "org.junit.platform:junit-platform-suite:6.0.3"
7676
}
7777
```
7878

docs/junit5/junit5-tests.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Add the following to your `pom.xml`:
3636

3737
```xml
3838
<properties>
39-
<serenity.version>5.2.2</serenity.version>
40-
<junit.version>6.0.1</junit.version>
39+
<serenity.version>5.2.4</serenity.version>
40+
<junit.version>6.0.3</junit.version>
4141
</properties>
4242

4343
<dependencies>
@@ -95,12 +95,12 @@ For Gradle, add to your `build.gradle`:
9595

9696
```groovy
9797
dependencies {
98-
testImplementation "net.serenity-bdd:serenity-junit5:5.2.2"
99-
testImplementation "net.serenity-bdd:serenity-screenplay:5.2.2"
100-
testImplementation "net.serenity-bdd:serenity-screenplay-webdriver:5.2.2"
98+
testImplementation "net.serenity-bdd:serenity-junit5:5.2.4"
99+
testImplementation "net.serenity-bdd:serenity-screenplay:5.2.4"
100+
testImplementation "net.serenity-bdd:serenity-screenplay-webdriver:5.2.4"
101101
102-
testImplementation "org.junit.jupiter:junit-jupiter-api:6.0.1"
103-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:6.0.1"
102+
testImplementation "org.junit.jupiter:junit-jupiter-api:6.0.3"
103+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:6.0.3"
104104
105105
testImplementation "org.assertj:assertj-core:3.24.2"
106106
}

docs/playwright/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Add the following dependencies to your `pom.xml`:
2424

2525
```xml
2626
<properties>
27-
<serenity.version>5.1.0</serenity.version>
28-
<playwright.version>1.57.0</playwright.version>
29-
<junit.version>6.0.1</junit.version>
27+
<serenity.version>5.2.4</serenity.version>
28+
<playwright.version>1.58.0</playwright.version>
29+
<junit.version>6.0.3</junit.version>
3030
</properties>
3131

3232
<dependencies>

docs/playwright/screenplay-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Create a Maven project with these dependencies:
2222

2323
```xml
2424
<properties>
25-
<serenity.version>5.1.1</serenity.version>
25+
<serenity.version>5.2.4</serenity.version>
2626
<playwright.version>1.58.0</playwright.version>
2727
</properties>
2828

docs/playwright/screenplay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Add these dependencies to your `pom.xml`:
3838

3939
```xml
4040
<properties>
41-
<serenity.version>5.1.1</serenity.version>
41+
<serenity.version>5.2.4</serenity.version>
4242
<playwright.version>1.58.0</playwright.version>
4343
</properties>
4444

docs/playwright/tutorial-todomvc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ First, create a Maven project with these dependencies in `pom.xml`:
3434
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3535
<maven.compiler.source>17</maven.compiler.source>
3636
<maven.compiler.target>17</maven.compiler.target>
37-
<serenity.version>5.1.0</serenity.version>
38-
<playwright.version>1.57.0</playwright.version>
37+
<serenity.version>5.2.4</serenity.version>
38+
<playwright.version>1.58.0</playwright.version>
3939
</properties>
4040

4141
<dependencies>

docs/screenplay/screenplay-playwright.md

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,41 @@ Add the following dependency to your project:
3232

3333
### The BrowseTheWebWithPlaywright Ability
3434

35-
To use Playwright with Screenplay, actors need the `BrowseTheWebWithPlaywright` ability:
35+
To use Playwright with Screenplay, actors need the `BrowseTheWebWithPlaywright` ability. The recommended approach is to use Playwright's `@UsePlaywright` annotation, which manages the browser lifecycle automatically:
3636

3737
```java
38+
import net.serenitybdd.junit5.SerenityJUnit5Extension;
39+
import net.serenitybdd.playwright.junit5.SerenityPlaywrightExtension;
40+
import net.serenitybdd.screenplay.Actor;
3841
import net.serenitybdd.screenplay.playwright.abilities.BrowseTheWebWithPlaywright;
3942
import com.microsoft.playwright.*;
4043

44+
@ExtendWith(SerenityJUnit5Extension.class)
45+
@ExtendWith(SerenityPlaywrightExtension.class)
46+
@UsePlaywright(ChromeHeadlessOptions.class)
47+
class MyScreenplayTest {
48+
49+
Actor alice;
50+
51+
@BeforeEach
52+
void setUp(Page page) {
53+
alice = Actor.named("Alice");
54+
alice.can(BrowseTheWebWithPlaywright.withPage(page));
55+
}
56+
}
57+
```
58+
59+
The `withPage(Page)` factory method wraps a `@UsePlaywright`-managed page. Screenplay reuses the existing browser — no duplicate browser instance is created. On teardown, Screenplay only unregisters the page; it does **not** close the Page, BrowserContext, Browser, or Playwright instance.
60+
61+
:::tip `@SerenityPlaywright` shorthand
62+
You can use the `@SerenityPlaywright` meta-annotation as a shorthand for both `@ExtendWith(SerenityJUnit5Extension.class)` and `@ExtendWith(SerenityPlaywrightExtension.class)`.
63+
:::
64+
65+
#### Alternative: Manual Lifecycle Management
66+
67+
If you need full control over the browser lifecycle, you can manage it manually:
68+
69+
```java
4170
Playwright playwright = Playwright.create();
4271
Browser browser = playwright.chromium().launch();
4372

@@ -47,10 +76,28 @@ alice.can(BrowseTheWebWithPlaywright.using(browser));
4776

4877
### Configuration
4978

50-
You can configure Playwright behavior using environment variables or programmatically:
79+
When using `@UsePlaywright`, configure browser options with an `OptionsFactory`:
80+
81+
```java
82+
public class ChromeHeadlessOptions implements OptionsFactory {
83+
@Override
84+
public Options getOptions() {
85+
return new Options()
86+
.setHeadless(true)
87+
.setLaunchOptions(
88+
new BrowserType.LaunchOptions()
89+
.setArgs(Arrays.asList(
90+
"--no-sandbox",
91+
"--disable-extensions",
92+
"--disable-gpu"))
93+
);
94+
}
95+
}
96+
```
97+
98+
For manual lifecycle management, configure programmatically:
5199

52100
```java
53-
// Launch with options
54101
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions()
55102
.setHeadless(false)
56103
.setSlowMo(100);
@@ -1089,9 +1136,9 @@ Simply enable console and/or network capture at the start of your tests:
10891136

10901137
```java
10911138
@BeforeEach
1092-
void setup() {
1093-
alice = Actor.named("Alice")
1094-
.whoCan(BrowseTheWebWithPlaywright.usingTheDefaultConfiguration());
1139+
void setup(Page page) {
1140+
alice = Actor.named("Alice");
1141+
alice.can(BrowseTheWebWithPlaywright.withPage(page));
10951142

10961143
// Enable capture for failure evidence
10971144
alice.attemptsTo(
@@ -1965,22 +2012,29 @@ When migrating from `serenity-screenplay-webdriver`:
19652012
## Complete Example
19662013

19672014
```java
2015+
import com.microsoft.playwright.Page;
2016+
import net.serenitybdd.annotations.SerenityPlaywright;
19682017
import net.serenitybdd.screenplay.Actor;
19692018
import net.serenitybdd.screenplay.playwright.abilities.BrowseTheWebWithPlaywright;
19702019
import net.serenitybdd.screenplay.playwright.interactions.*;
19712020
import net.serenitybdd.screenplay.playwright.questions.*;
19722021
import net.serenitybdd.screenplay.playwright.ui.*;
2022+
import com.microsoft.playwright.junit.UsePlaywright;
2023+
import org.junit.jupiter.api.BeforeEach;
2024+
import org.junit.jupiter.api.Test;
2025+
19732026
import static org.assertj.core.api.Assertions.assertThat;
19742027

1975-
public class ShoppingCartTest {
2028+
@SerenityPlaywright
2029+
@UsePlaywright
2030+
class ShoppingCartTest {
19762031

1977-
Actor alice = Actor.named("Alice");
2032+
Actor alice;
19782033

19792034
@BeforeEach
1980-
void setup() {
1981-
Playwright playwright = Playwright.create();
1982-
Browser browser = playwright.chromium().launch();
1983-
alice.can(BrowseTheWebWithPlaywright.using(browser));
2035+
void setup(Page page) {
2036+
alice = Actor.named("Alice");
2037+
alice.can(BrowseTheWebWithPlaywright.withPage(page));
19842038
}
19852039

19862040
@Test

0 commit comments

Comments
 (0)