diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java index c27afd77..1f92bcb6 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java @@ -946,9 +946,6 @@ public class PageImpl extends ChannelOwner implements Page { } private byte[] pdfImpl(PdfOptions options) { - if (!browserContext.browser().isChromium()) { - throw new PlaywrightException("Page.pdf only supported in headless Chromium"); - } if (options == null) { options = new PdfOptions(); } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPdf.java b/playwright/src/test/java/com/microsoft/playwright/TestPdf.java index 4ee3f84e..66d07717 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPdf.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPdf.java @@ -52,6 +52,18 @@ public class TestPdf extends TestBase { @DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip") void shouldThrowInNonChromium() { PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.pdf()); - assertTrue(e.getMessage().contains("Page.pdf only supported in headless Chromium")); + assertTrue(e.getMessage().contains("PDF generation is only supported for Headless Chromium"), e.getMessage()); + } + + + @Test + @DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip") + void correctExceptionWithPersistentContext(@TempDir Path tempDir) { + Path profile = tempDir.resolve("profile"); + try (BrowserContext context = browserType.launchPersistentContext(profile)) { + Page page = context.newPage(); + PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.pdf()); + assertTrue(e.getMessage().contains("PDF generation is only supported for Headless Chromium"), e.getMessage()); + } } }