Skip to content

Commit 91a53cf

Browse files
committed
1.54.0-alpha-2025-06-20
1 parent 9df2165 commit 91a53cf

12 files changed

Lines changed: 69 additions & 24 deletions

File tree

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<name>Playwright Client Examples</name>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<playwright.version>1.53.0</playwright.version>
13+
<playwright.version>1.54.0</playwright.version>
1414
</properties>
1515
<dependencies>
1616
<dependency>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ public WaitForPageOptions setTimeout(double timeout) {
596596
*/
597597
List<Page> backgroundPages();
598598
/**
599-
* Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
599+
* Gets the browser instance that owns the context. Returns {@code null} if the context is created outside of normal
600+
* browser, e.g. Android or Electron.
600601
*
601602
* @since v1.8
602603
*/
@@ -871,6 +872,7 @@ default void exposeBinding(String name, BindingCallback callback) {
871872
* <li> {@code "notifications"}</li>
872873
* <li> {@code "payment-handler"}</li>
873874
* <li> {@code "storage-access"}</li>
875+
* <li> {@code "local-fonts"}</li>
874876
* </ul>
875877
* @since v1.8
876878
*/
@@ -903,6 +905,7 @@ default void grantPermissions(List<String> permissions) {
903905
* <li> {@code "notifications"}</li>
904906
* <li> {@code "payment-handler"}</li>
905907
* <li> {@code "storage-access"}</li>
908+
* <li> {@code "local-fonts"}</li>
906909
* </ul>
907910
* @since v1.8
908911
*/

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
/**
2222
* The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
2323
*
24+
* <p> <strong>NOTE:</strong> If you want to debug where the mouse moved, you can use the <a
25+
* href="https://playwright.dev/java/docs/trace-viewer-intro">Trace viewer</a> or <a
26+
* href="https://playwright.dev/java/docs/running-tests">Playwright Inspector</a>. A red dot showing the location of the
27+
* mouse will be shown for every mouse action.
28+
*
2429
* <p> Every {@code page} object has its own Mouse, accessible with {@link com.microsoft.playwright.Page#mouse Page.mouse()}.
2530
* <pre>{@code
2631
* // Using ‘page.mouse’ to trace a 100x100 square.

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.microsoft.playwright.impl;
1818

19-
import com.microsoft.playwright.PlaywrightException;
2019
import org.opentest4j.AssertionFailedError;
2120
import org.opentest4j.ValueWrapper;
2221

@@ -29,12 +28,10 @@
2928
import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
3029
import static java.util.Arrays.asList;
3130

32-
class AssertionsBase {
33-
final LocatorImpl actualLocator;
31+
abstract class AssertionsBase {
3432
final boolean isNot;
3533

36-
AssertionsBase(LocatorImpl actual, boolean isNot) {
37-
this.actualLocator = actual;
34+
AssertionsBase(boolean isNot) {
3835
this.isNot = isNot;
3936
}
4037

@@ -58,7 +55,7 @@ void expectImpl(String expression, FrameExpectOptions expectOptions, Object expe
5855
if (isNot) {
5956
message = message.replace("expected to", "expected not to");
6057
}
61-
FrameExpectResult result = actualLocator.expect(expression, expectOptions, title);
58+
FrameExpectResult result = doExpect(expression, expectOptions, title);
6259
if (result.matches == isNot) {
6360
Object actual = result.received == null ? null : Serialization.deserialize(result.received);
6461
String log = (result.log == null) ? "" : String.join("\n", result.log);
@@ -75,7 +72,9 @@ void expectImpl(String expression, FrameExpectOptions expectOptions, Object expe
7572
}
7673
}
7774

78-
private static ValueWrapper formatValue(Object value) {
75+
abstract FrameExpectResult doExpect(String expression, FrameExpectOptions expectOptions, String title);
76+
77+
protected static ValueWrapper formatValue(Object value) {
7978
if (value == null || !value.getClass().isArray()) {
8079
return ValueWrapper.create(value);
8180
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,4 +1085,16 @@ protected double navigationTimeout(Double timeout) {
10851085
}
10861086
return new TimeoutSettings().navigationTimeout(timeout);
10871087
}
1088+
1089+
FrameExpectResult expect(String expression, FrameExpectOptions options, String title) {
1090+
return withTitle(title, () -> expect(expression, options));
1091+
}
1092+
1093+
FrameExpectResult expect(String expression, FrameExpectOptions options) {
1094+
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
1095+
params.addProperty("expression", expression);
1096+
JsonElement json = sendMessage("expect", params, options.timeout);
1097+
FrameExpectResult result = gson().fromJson(json, FrameExpectResult.class);
1098+
return result;
1099+
}
10881100
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@
3030
import static com.microsoft.playwright.impl.Utils.convertType;
3131

3232
public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAssertions {
33+
LocatorImpl actualLocator;
34+
3335
public LocatorAssertionsImpl(Locator locator) {
3436
this(locator, false);
3537
}
3638

3739
private LocatorAssertionsImpl(Locator locator, boolean isNot) {
38-
super((LocatorImpl) locator, isNot);
40+
super(isNot);
41+
this.actualLocator = (LocatorImpl) locator;
42+
}
43+
44+
@Override
45+
FrameExpectResult doExpect(String expression, FrameExpectOptions expectOptions, String title) {
46+
return actualLocator.expect(expression, expectOptions, title);
3947
}
4048

4149

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,8 @@ public int hashCode() {
645645
}
646646

647647
FrameExpectResult expect(String expression, FrameExpectOptions options, String title) {
648-
return frame.withTitle(title, () -> expectImpl(expression, options));
648+
options.selector = selector;
649+
return frame.expect(expression, options, title);
649650
}
650651

651652
JsonObject toProtocol() {
@@ -654,13 +655,4 @@ JsonObject toProtocol() {
654655
result.addProperty("selector", selector);
655656
return result;
656657
}
657-
658-
private FrameExpectResult expectImpl(String expression, FrameExpectOptions options) {
659-
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
660-
params.addProperty("selector", selector);
661-
params.addProperty("expression", expression);
662-
JsonElement json = frame.sendMessage("expect", params, options.timeout);
663-
FrameExpectResult result = gson().fromJson(json, FrameExpectResult.class);
664-
return result;
665-
}
666658
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ public PageAssertionsImpl(Page page) {
3232
}
3333

3434
private PageAssertionsImpl(Page page, boolean isNot) {
35-
super((LocatorImpl) page.locator(":root"), isNot);
35+
super(isNot);
3636
this.actualPage = (PageImpl) page;
3737
}
3838

39+
@Override
40+
FrameExpectResult doExpect(String expression, FrameExpectOptions expectOptions, String title) {
41+
FrameImpl frame = (FrameImpl) actualPage.mainFrame();
42+
return frame.expect(expression, expectOptions, title);
43+
}
44+
3945
@Override
4046
public void hasTitle(String title, HasTitleOptions options) {
4147
ExpectedTextValue expected = new ExpectedTextValue();

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
// This file is generated by generate_java_rpc.js, do not edit manually.
18-
1917
package com.microsoft.playwright.impl;
2018

2119
import java.util.List;
@@ -105,6 +103,7 @@ class ExpectedTextValue {
105103
class FrameExpectOptions {
106104
Object expressionArg;
107105
List<ExpectedTextValue> expectedText;
106+
String selector;
108107
Double expectedNumber;
109108
SerializedArgument expectedValue;
110109
Boolean useInnerText;

playwright/src/main/java/com/microsoft/playwright/options/Cookie.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public class Cookie {
4848
* Optional.
4949
*/
5050
public SameSiteAttribute sameSite;
51+
/**
52+
* For partitioned third-party cookies (aka <a
53+
* href="https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies">CHIPS</a>), the
54+
* partition key. Optional.
55+
*/
56+
public String partitionKey;
5157

5258
public Cookie(String name, String value) {
5359
this.name = name;
@@ -103,4 +109,13 @@ public Cookie setSameSite(SameSiteAttribute sameSite) {
103109
this.sameSite = sameSite;
104110
return this;
105111
}
112+
/**
113+
* For partitioned third-party cookies (aka <a
114+
* href="https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies">CHIPS</a>), the
115+
* partition key. Optional.
116+
*/
117+
public Cookie setPartitionKey(String partitionKey) {
118+
this.partitionKey = partitionKey;
119+
return this;
120+
}
106121
}

0 commit comments

Comments
 (0)