Skip to content

Commit 1f07b32

Browse files
committed
install browsers as separate step
1 parent 02863c5 commit 1f07b32

File tree

8 files changed

+104
-13
lines changed

8 files changed

+104
-13
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
run: scripts/download_driver.sh
3131
- name: Build & Install
3232
run: mvn -B install -D skipTests --no-transfer-progress
33+
- name: Install browsers
34+
run: mvn compile exec:java -f playwright -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"
3335
- name: Run tests
3436
run: mvn test --no-transfer-progress --fail-at-end -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
3537
env:
@@ -78,6 +80,8 @@ jobs:
7880
run: scripts/download_driver.sh
7981
- name: Build & Install
8082
run: mvn -B install -D skipTests --no-transfer-progress
83+
- name: Install browsers
84+
run: mvn compile exec:java -f playwright/pom.xml -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"
8185
- name: Install MS Edge
8286
if: matrix.browser-channel == 'msedge' && matrix.os == 'macos-latest'
8387
shell: bash

.github/workflows/verify_api.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
run: scripts/download_driver.sh
2626
- name: Regenerate APIs
2727
run: scripts/generate_api.sh
28+
- name: Install browsers
29+
run: mvn compile exec:java -f playwright/pom.xml -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps"
2830
- name: Update browser versions in README
2931
run: scripts/update_readme.sh
3032
- name: Verify API is up to date

playwright/src/main/java/com/microsoft/playwright/Locator.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@
2929
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
3030
*/
3131
public interface Locator {
32+
class AriaSnapshotOptions {
33+
/**
34+
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
35+
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
36+
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
37+
* methods.
38+
*/
39+
public Double timeout;
40+
41+
/**
42+
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
43+
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
44+
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
45+
* methods.
46+
*/
47+
public AriaSnapshotOptions setTimeout(double timeout) {
48+
this.timeout = timeout;
49+
return this;
50+
}
51+
}
3252
class BlurOptions {
3353
/**
3454
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
@@ -2230,7 +2250,38 @@ public WaitForOptions setTimeout(double timeout) {
22302250
*
22312251
* @since v1.49
22322252
*/
2233-
String ariaSnapshot();
2253+
default String ariaSnapshot() {
2254+
return ariaSnapshot(null);
2255+
}
2256+
/**
2257+
* Captures the aria snapshot of the given element. Read more about <a
2258+
* href="https://playwright.dev/java/docs/aria-snapshots">aria snapshots</a> and {@link
2259+
* com.microsoft.playwright.assertions.LocatorAssertions#matchesAriaSnapshot LocatorAssertions.matchesAriaSnapshot()} for
2260+
* the corresponding assertion.
2261+
*
2262+
* <p> <strong>Usage</strong>
2263+
* <pre>{@code
2264+
* page.getByRole(AriaRole.LINK).ariaSnapshot();
2265+
* }</pre>
2266+
*
2267+
* <p> <strong>Details</strong>
2268+
*
2269+
* <p> This method captures the aria snapshot of the given element. The snapshot is a string that represents the state of the
2270+
* element and its children. The snapshot can be used to assert the state of the element in the test, or to compare it to
2271+
* state in the future.
2272+
*
2273+
* <p> The ARIA snapshot is represented using <a href="https://yaml.org/spec/1.2.2/">YAML</a> markup language:
2274+
* <ul>
2275+
* <li> The keys of the objects are the roles and optional accessible names of the elements.</li>
2276+
* <li> The values are either text content or an array of child elements.</li>
2277+
* <li> Generic static text can be represented with the {@code text} key.</li>
2278+
* </ul>
2279+
*
2280+
* <p> Below is the HTML markup and the respective ARIA snapshot:
2281+
*
2282+
* @since v1.49
2283+
*/
2284+
String ariaSnapshot(AriaSnapshotOptions options);
22342285
/**
22352286
* Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur">blur</a> on the element.
22362287
*

playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,20 @@ public HasValuesOptions setTimeout(double timeout) {
485485
return this;
486486
}
487487
}
488+
class MatchesAriaSnapshotOptions {
489+
/**
490+
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
491+
*/
492+
public Double timeout;
493+
494+
/**
495+
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
496+
*/
497+
public MatchesAriaSnapshotOptions setTimeout(double timeout) {
498+
this.timeout = timeout;
499+
return this;
500+
}
501+
}
488502
/**
489503
* Makes the assertion check for the opposite condition. For example, this code tests that the Locator doesn't contain text
490504
* {@code "error"}:
@@ -2172,6 +2186,24 @@ default void hasValues(Pattern[] values) {
21722186
*
21732187
* @since v1.49
21742188
*/
2175-
void matchesAriaSnapshot(String expected);
2189+
default void matchesAriaSnapshot(String expected) {
2190+
matchesAriaSnapshot(expected, null);
2191+
}
2192+
/**
2193+
* Asserts that the target element matches the given <a
2194+
* href="https://playwright.dev/java/docs/aria-snapshots">accessibility snapshot</a>.
2195+
*
2196+
* <p> <strong>Usage</strong>
2197+
* <pre>{@code
2198+
* page.navigate("https://demo.playwright.dev/todomvc/");
2199+
* assertThat(page.locator("body")).matchesAriaSnapshot("""
2200+
* - heading "todos"
2201+
* - textbox "What needs to be done?"
2202+
* """);
2203+
* }</pre>
2204+
*
2205+
* @since v1.49
2206+
*/
2207+
void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions options);
21762208
}
21772209

playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,8 @@ public void hasValues(Pattern[] patterns, HasValuesOptions options) {
327327
}
328328

329329
@Override
330-
public void matchesAriaSnapshot(String expected) {
331-
// expected = unshift(expected);
332-
// TODO: timeout
333-
FrameExpectOptions options = new FrameExpectOptions();
330+
public void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions snapshotOptions) {
331+
FrameExpectOptions options = convertType(snapshotOptions, FrameExpectOptions.class);
334332
options.expectedValue = serializeArgument(expected);
335333
expectImpl("to.match.aria", options, expected,"Locator expected to match Aria snapshot");
336334
}

playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ public Locator and(Locator locator) {
120120
}
121121

122122
@Override
123-
public String ariaSnapshot() {
124-
return frame.withLogging("Locator.ariaSnapshot", () -> ariaSnapshotImpl());
123+
public String ariaSnapshot(AriaSnapshotOptions options) {
124+
return frame.withLogging("Locator.ariaSnapshot", () -> ariaSnapshotImpl(options));
125125
}
126126

127-
private String ariaSnapshotImpl() {
128-
JsonObject params = new JsonObject();
127+
private String ariaSnapshotImpl(AriaSnapshotOptions options) {
128+
if (options == null) {
129+
options = new AriaSnapshotOptions();
130+
}
131+
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
129132
params.addProperty("selector", selector);
130133
JsonObject result = frame.sendMessage("ariaSnapshot", params).getAsJsonObject();
131134
return result.get("snapshot").getAsString();

playwright/src/test/java/com/microsoft/playwright/TestPageAriaSnapshot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ void shouldSnapshotComplex(Page page) {
7373
@Test
7474
void shouldAllowTextNodes(Page page) {
7575
page.setContent("<h1>Microsoft</h1><div>Open source projects and samples from Microsoft</div>");
76-
checkAndMatchSnapshot(page.locator("body"), "- heading \"Microsoft\" [level=1]\n" +
77-
"- text: Open source projects and samples from Microsoft");
76+
checkAndMatchSnapshot(page.locator("body"), "" +
77+
" - heading \"Microsoft\" [level=1]\n" +
78+
" - text: Open source projects and samples from Microsoft");
7879
}
7980

8081
@Test

scripts/DRIVER_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.49.0-beta-1731595428000
1+
1.49.0-beta-1731616844000

0 commit comments

Comments
 (0)