diff --git a/README.md b/README.md index 5a4a7f0b1..b9c8f99ad 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 159.0.8154.13 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 159.0.8154.33 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 27.2 | ✅ | ✅ | ✅ | -| Firefox 159.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 160.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | ## Documentation diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java index 4e2fe4103..9ccab67cb 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserTypeImpl.java @@ -186,7 +186,9 @@ private BrowserImpl browserFromConnectResult(BrowserTypeConnectOverCDPResult res BrowserImpl browser = result.browser; browser.connectToBrowserType(this, new LaunchOptions(), null); if (result.defaultContext != null) { - instrumentation.runAfterCreateBrowserContext(result.defaultContext); + BrowserContextImpl context = result.defaultContext; + playwright.selectors.registerOnContext(context); + instrumentation.runAfterCreateBrowserContext(context); } return browser; } diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/SelectorsImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/SelectorsImpl.java index 140c589bd..55c465326 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/SelectorsImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/SelectorsImpl.java @@ -69,6 +69,19 @@ private void registerImpl(String name, Object script, RegisterOptions options) { selectorEngines.add(engine); } + void registerOnContext(BrowserContextImpl context) { + for (SelectorEngine selectorEngine : selectorEngines) { + BrowserContextRegisterSelectorEngineParams params = new BrowserContextRegisterSelectorEngineParams(); + params.selectorEngine = selectorEngine; + context.channel.registerSelectorEngine(params, NO_TIMEOUT); + } + if (testIdAttributeName != null) { + BrowserContextSetTestIdAttributeNameParams params = new BrowserContextSetTestIdAttributeNameParams(); + params.testIdAttributeName = testIdAttributeName; + context.channel.setTestIdAttributeName(params, NO_TIMEOUT); + } + } + @Override public void setTestIdAttribute(String attributeName) { if (attributeName == null) { diff --git a/playwright/src/test/java/com/microsoft/playwright/tests/library/TestCapabilities.java b/playwright/src/test/java/com/microsoft/playwright/tests/library/TestCapabilities.java index 545927426..078a12e4d 100644 --- a/playwright/src/test/java/com/microsoft/playwright/tests/library/TestCapabilities.java +++ b/playwright/src/test/java/com/microsoft/playwright/tests/library/TestCapabilities.java @@ -18,6 +18,7 @@ import com.microsoft.playwright.Browser; import com.microsoft.playwright.BrowserContext; +import com.microsoft.playwright.BrowserType; import com.microsoft.playwright.FileChooser; import com.microsoft.playwright.Frame; import com.microsoft.playwright.Locator; @@ -30,14 +31,18 @@ import com.microsoft.playwright.fixtures.DisabledOnBrowser; import com.microsoft.playwright.fixtures.EnabledOnBrowser; import com.microsoft.playwright.fixtures.Env; +import com.microsoft.playwright.fixtures.Fixture; import com.microsoft.playwright.fixtures.HttpsTestServer; import com.microsoft.playwright.fixtures.PlaywrightTest; +import com.microsoft.playwright.fixtures.Scope; import com.microsoft.playwright.fixtures.TestServer; import com.microsoft.playwright.options.BoundingBox; import org.junit.jupiter.api.DisplayName; import java.nio.file.Path; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.regex.Pattern; @@ -51,6 +56,20 @@ /** Port of tests/library/capabilities.spec.ts. */ public class TestCapabilities { + @Fixture(scope = Scope.WORKER) + static BrowserType.LaunchOptions launchOptions(BrowserType.LaunchOptions launchOptions, BrowserName browserName) { + if (browserName == BrowserName.FIREFOX) { + Map firefoxUserPrefs = new HashMap<>(); + if (launchOptions.firefoxUserPrefs != null) { + firefoxUserPrefs.putAll(launchOptions.firefoxUserPrefs); + } + // Test DOM fullscreen without requiring a window manager under Xvfb. + firefoxUserPrefs.put("full-screen-api.ignore-widgets", true); + return com.microsoft.playwright.impl.Utils.clone(launchOptions).setFirefoxUserPrefs(firefoxUserPrefs); + } + return launchOptions; + } + @PlaywrightTest @DisplayName("CA-001 SharedArrayBuffer should work @smoke") void sharedArrayBufferShouldWork(ContextFactory contextFactory, HttpsTestServer httpsServer) { @@ -316,8 +335,7 @@ void windowGestureEventInWebKit(Page page, TestServer server, BrowserName browse @PlaywrightTest @DisplayName("CA-020 requestFullscreen") - @DisabledOnBrowser(value = BrowserName.FIREFOX, headed = true, reason = "fixme: Error: Request for fullscreen was denied because requesting element is not in the currently focused tab") - void requestFullscreen(Page page, TestServer server) { + void requestFullscreen(Page page, TestServer server, BrowserName browserName) { page.navigate(server.EMPTY_PAGE); page.evaluate("() => {\n" + " const result = new Promise(resolve => document.addEventListener('fullscreenchange', resolve));\n" + @@ -332,6 +350,8 @@ void requestFullscreen(Page page, TestServer server) { "}"); assertEquals(false, page.evaluate("() => !!document.fullscreenElement")); + assumeFalse(browserName == BrowserName.WEBKIT && !Env.isLinux, + "fixme: requestFullscreen() in a popup rejects with InvalidStateError on Windows and hangs the context teardown on macOS"); Page popup = page.waitForPopup(() -> page.evaluate("url => window.open(url, 'popup', 'popup')", server.EMPTY_PAGE)); popup.waitForLoadState(); popup.evaluate("() => {\n" + diff --git a/playwright/src/test/java/com/microsoft/playwright/tests/library/chromium/TestConnectOverCdp.java b/playwright/src/test/java/com/microsoft/playwright/tests/library/chromium/TestConnectOverCdp.java index cf92522cf..51e11a57b 100644 --- a/playwright/src/test/java/com/microsoft/playwright/tests/library/chromium/TestConnectOverCdp.java +++ b/playwright/src/test/java/com/microsoft/playwright/tests/library/chromium/TestConnectOverCdp.java @@ -472,6 +472,46 @@ void shouldReturnValidBrowserFromContextBrowser(BrowserType browserType) { } } + @PlaywrightTest + @DisplayName("CD-055 should work with registered selector engines") + void shouldWorkWithRegisteredSelectorEngines(Playwright playwright, BrowserType browserType) { + int port = findFreePort(); + Browser browserServer = browserType.launch(remoteDebuggingPort(port)); + try { + // Java: invoke the factory, since register accepts script source rather than a JavaScript function. + playwright.selectors().register("cdpTag", "(() => ({\n" + + " query: (root, selector) => root.querySelector(selector),\n" + + " queryAll: (root, selector) => Array.from(root.querySelectorAll(selector)),\n" + + "}))()"); + Browser cdpBrowser = browserType.connectOverCDP("http://127.0.0.1:" + port + "/"); + Page page = cdpBrowser.contexts().get(0).newPage(); + page.setContent("
hello
"); + assertEquals("hello", page.locator("cdpTag=div").textContent()); + cdpBrowser.close(); + } finally { + browserServer.close(); + } + } + + @PlaywrightTest + @DisplayName("CD-056 should respect the test id attribute in strict mode errors") + void shouldRespectTheTestIdAttributeInStrictModeErrors(Playwright playwright, BrowserType browserType) { + int port = findFreePort(); + Browser browserServer = browserType.launch(remoteDebuggingPort(port)); + try { + playwright.selectors().setTestIdAttribute("data-foo"); + Browser cdpBrowser = browserType.connectOverCDP("http://127.0.0.1:" + port + "/"); + Page page = cdpBrowser.contexts().get(0).newPage(); + page.setContent(""); + PlaywrightException error = assertThrows(PlaywrightException.class, () -> page.locator("button").click()); + assertTrue(error.getMessage().contains("aka getByTestId(\"a\")")); + cdpBrowser.close(); + } finally { + playwright.selectors().setTestIdAttribute("data-testid"); + browserServer.close(); + } + } + @PlaywrightTest @DisplayName("CD-020 should report an expected error when the endpointURL returns a non-expected status code") void shouldReportAnExpectedErrorWhenTheEndpointURLReturnsANonExpectedStatusCode(BrowserType browserType, TestServer server) { diff --git a/playwright/src/test/java/com/microsoft/playwright/tests/page/TestPageScreenshot.java b/playwright/src/test/java/com/microsoft/playwright/tests/page/TestPageScreenshot.java index 8d39ae065..3a6799746 100644 --- a/playwright/src/test/java/com/microsoft/playwright/tests/page/TestPageScreenshot.java +++ b/playwright/src/test/java/com/microsoft/playwright/tests/page/TestPageScreenshot.java @@ -721,6 +721,7 @@ void shouldRemoveElementsBasedOnAttr(Page page, TestServer server, TestInfo test } @Nested + @DisabledOnBrowser(value = BrowserName.FIREFOX, headed = true, reason = "Firefox headed produces a different image: https://github.com/microsoft/playwright-browsers/issues/2714") class PageScreenshotAnimations { @PlaywrightTest @DisplayName("SS-098 should preserve scroll animation progress during screenshots") diff --git a/playwright/src/test/upstream_base.txt b/playwright/src/test/upstream_base.txt index 39baf9cca..cca056c8a 100644 --- a/playwright/src/test/upstream_base.txt +++ b/playwright/src/test/upstream_base.txt @@ -5,4 +5,4 @@ # git log ..main --oneline -- tests/page tests/library tests/registry.md # git diff ..main -- tests/page tests/library tests/registry.md # and move this line forward together with the registry copy and the ports. -b0e0b7b555e637cc8c0ce94dd98c3be153861333 2026-11-24 fix(test): watch external dependencies of test directories (#44317) +a804c193562095b0da20e5d4679fa87e4c8e5563 2026-11-27 docs(python): fix async/sync mistakes in Python code snippets (#44410) diff --git a/playwright/src/test/upstream_registry.md b/playwright/src/test/upstream_registry.md index 0affc5bcb..2e8c53808 100644 --- a/playwright/src/test/upstream_registry.md +++ b/playwright/src/test/upstream_registry.md @@ -766,6 +766,8 @@ subsystem, add a row to the Subsystems table. Then update this file: | `CD-052` | `library/chromium/session.spec.ts` | should work with newBrowserCDPSession | | `CD-053` | `library/chromium/connect-over-cdp.spec.ts` | should connect when another client inspects a terminated shared worker | | `CD-054` | `library/chromium/connect-over-cdp.spec.ts` | should not wait for a busy page longer than maxPageAttachTime | +| `CD-055` | `library/chromium/connect-over-cdp.spec.ts` | should work with registered selector engines | +| `CD-056` | `library/chromium/connect-over-cdp.spec.ts` | should respect the test id attribute in strict mode errors | ### CF — Code frame diff --git a/scripts/DRIVER_VERSION b/scripts/DRIVER_VERSION index 49036cda3..5f86dfacc 100644 --- a/scripts/DRIVER_VERSION +++ b/scripts/DRIVER_VERSION @@ -1 +1 @@ -b0e0b7b555e637cc8c0ce94dd98c3be153861333 +a804c193562095b0da20e5d4679fa87e4c8e5563