From 2c9c9bfa97f46a2e6192c411cdad9b731a6dfb57 Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Thu, 17 Oct 2024 16:05:04 -0400 Subject: [PATCH 01/13] Added PrintsPage section; added Java Examples --- .../selenium/interactions/PrintsPageTest.java | 31 ++++++++++ .../webdriver/interactions/print_page.en.md | 61 ++++++++++++++++--- .../webdriver/interactions/print_page.ja.md | 61 ++++++++++++++++--- .../interactions/print_page.pt-br.md | 61 ++++++++++++++++--- .../interactions/print_page.zh-cn.md | 61 ++++++++++++++++--- 5 files changed, 235 insertions(+), 40 deletions(-) create mode 100644 examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java diff --git a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java new file mode 100644 index 000000000000..2ff612e982d4 --- /dev/null +++ b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java @@ -0,0 +1,31 @@ +package dev.selenium.interactions; + +import org.openqa.selenium; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.print.PageMargin; +import org.openqa.selenium.print.PrintOptions; + +import dev.selenium.BaseChromeTest; + +public class PrintsPageTest extends BaseChromeTest { + + @Test + public void PrintWithPrintsPageTest() + { + driver.get("https://www.selenium.dev/"); + PrintsPage printer = (PrintsPage) driver; + PrintOptions printOptions = new PrintOptions(); + Pdf printedPage = printer.print(printOptions); + Assertions.assertNotNull(printedPage); + } + + @Test + public void PrintWithBrowsingContextTest() + { + BrowsingContext browsingContext = new BrowsingContext(driver, driver.getWindowHandle()); + driver.get("https://www.selenium.dev/selenium/web/formPage.html"); + PrintOptions printOptions = new PrintOptions(); + String printPage = browsingContext.print(printOptions); + Assertions.assertTrue(printPage.length() > 0); + } +} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md index dc9c5801b647..d9b64ba16004 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md @@ -7,11 +7,15 @@ aliases: [ ] --- -Printing a website is a common requirement, whether for sharing information or archiving records. -Selenium offers a straightforward way to automate this process through the `PrintOptions()` class. -This class provides an intuitive and multifaceted way of printing webpages. +Printing a webpage is a common task, whether for sharing information or maintaining archives. +Selenium simplifies this process through its PrintOptions, PrintsPage, and browsingContext +classes, which provide a flexible and intuitive interface for automating the printing of web pages. +These classes enable you to configure printing preferences, such as page layout, margins, and scaling, +ensuring that the output meets your specific requirements. -## Orientation +## Configuring + +### Orientation Using the `getOrientation()` and `setOrientation()` methods, you can get/set the page orientation --- either `PORTRAIT` or `LANDSCAPE`. {{< tabpane text=true >}} @@ -35,7 +39,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< /tab >}} {{< /tabpane >}} -## Range +### Range Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the range of pages to print --- e.g. "2-4". {{< tabpane text=true >}} @@ -59,7 +63,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< /tab >}} {{< /tabpane >}} -## Size +### Size Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the paper size to print --- e.g. "A0", "A6", "Legal", "Tabloid", etc. {{< tabpane text=true >}} @@ -83,7 +87,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< /tab >}} {{< /tabpane >}} -## Margins +### Margins Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margin sizes of the page you wish to print --- i.e. top, bottom, left, and right margins. {{< tabpane text=true >}} @@ -107,7 +111,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< /tab >}} {{< /tabpane >}} -## Scale +### Scale Using `getScale()` and `setScale()` methods, you can get/set the scale of the page you wish to print --- e.g. 1.0 is 100% or default, 0.25 is 25%, etc. {{< tabpane text=true >}} @@ -131,7 +135,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< /tab >}} {{< /tabpane >}} -## Background +### Background Using `getBackground()` and `setBackground()` methods, you can get/set whether background colors and images appear --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -155,7 +159,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< /tab >}} {{< /tabpane >}} -## ShrinkToFit +### ShrinkToFit Using `getBackground()` and `setBackground()` methods, you can get/set whether the page will shrink-to-fit content on the page --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -177,4 +181,41 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} +{{< /tabpane >}} + +## Printing + +Once you've configured your PrintOptions, you're ready to print the page. To do this, +you can invoke the print function, which generates a PDF representation of the web page. +The resulting PDF can be saved to your local storage for further use or distribution. +Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded +and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` +is part of Selenium's BiDi implementation. + +There may currently be multiple implementations depending on your language of choice. For example, with Java you have +have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a +parameter. + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +**PrintsPage()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +**BrowsingContext()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} {{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md index 160454f41238..aa60ceca46f6 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md @@ -7,11 +7,15 @@ aliases: [ ] --- -Printing a website is a common requirement, whether for sharing information or archiving records. -Selenium offers a straightforward way to automate this process through the `PrintOptions()` class. -This class provides an intuitive and multifaceted way of printing webpages. +Printing a webpage is a common task, whether for sharing information or maintaining archives. +Selenium simplifies this process through its PrintOptions, PrintsPage, and browsingContext +classes, which provide a flexible and intuitive interface for automating the printing of web pages. +These classes enable you to configure printing preferences, such as page layout, margins, and scaling, +ensuring that the output meets your specific requirements. -## Orientation +## Configuring + +### Orientation Using the `getOrientation()` and `setOrientation()` methods, you can get/set the page orientation --- either `PORTRAIT` or `LANDSCAPE`. {{< tabpane text=true >}} @@ -35,7 +39,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< /tab >}} {{< /tabpane >}} -## Range +### Range Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the range of pages to print --- e.g. "2-4". {{< tabpane text=true >}} @@ -59,7 +63,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< /tab >}} {{< /tabpane >}} -## Size +### Size Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the paper size to print --- e.g. "A0", "A6", "Legal", "Tabloid", etc. {{< tabpane text=true >}} @@ -83,7 +87,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< /tab >}} {{< /tabpane >}} -## Margins +### Margins Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margin sizes of the page you wish to print --- i.e. top, bottom, left, and right margins. {{< tabpane text=true >}} @@ -107,7 +111,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< /tab >}} {{< /tabpane >}} -## Scale +### Scale Using `getScale()` and `setScale()` methods, you can get/set the scale of the page you wish to print --- e.g. 1.0 is 100% or default, 0.25 is 25%, etc. {{< tabpane text=true >}} @@ -131,7 +135,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< /tab >}} {{< /tabpane >}} -## Background +### Background Using `getBackground()` and `setBackground()` methods, you can get/set whether background colors and images appear --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -155,7 +159,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< /tab >}} {{< /tabpane >}} -## ShrinkToFit +### ShrinkToFit Using `getBackground()` and `setBackground()` methods, you can get/set whether the page will shrink-to-fit content on the page --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -177,4 +181,41 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} +{{< /tabpane >}} + +## Printing + +Once you've configured your PrintOptions, you're ready to print the page. To do this, +you can invoke the print function, which generates a PDF representation of the web page. +The resulting PDF can be saved to your local storage for further use or distribution. +Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded +and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` +is part of Selenium's BiDi implementation. + +There may currently be multiple implementations depending on your language of choice. For example, with Java you have +have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a +parameter. + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +**PrintsPage()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +**BrowsingContext()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} {{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md index eef81cc999aa..3d33e1fed7ce 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md @@ -7,11 +7,15 @@ aliases: [ ] --- -Printing a website is a common requirement, whether for sharing information or archiving records. -Selenium offers a straightforward way to automate this process through the `PrintOptions()` class. -This class provides an intuitive and multifaceted way of printing webpages. +Printing a webpage is a common task, whether for sharing information or maintaining archives. +Selenium simplifies this process through its PrintOptions, PrintsPage, and browsingContext +classes, which provide a flexible and intuitive interface for automating the printing of web pages. +These classes enable you to configure printing preferences, such as page layout, margins, and scaling, +ensuring that the output meets your specific requirements. -## Orientation +## Configuring + +### Orientation Using the `getOrientation()` and `setOrientation()` methods, you can get/set the page orientation --- either `PORTRAIT` or `LANDSCAPE`. {{< tabpane text=true >}} @@ -35,7 +39,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< /tab >}} {{< /tabpane >}} -## Range +### Range Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the range of pages to print --- e.g. "2-4". {{< tabpane text=true >}} @@ -59,7 +63,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< /tab >}} {{< /tabpane >}} -## Size +### Size Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the paper size to print --- e.g. "A0", "A6", "Legal", "Tabloid", etc. {{< tabpane text=true >}} @@ -83,7 +87,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< /tab >}} {{< /tabpane >}} -## Margins +### Margins Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margin sizes of the page you wish to print --- i.e. top, bottom, left, and right margins. {{< tabpane text=true >}} @@ -107,7 +111,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< /tab >}} {{< /tabpane >}} -## Scale +### Scale Using `getScale()` and `setScale()` methods, you can get/set the scale of the page you wish to print --- e.g. 1.0 is 100% or default, 0.25 is 25%, etc. {{< tabpane text=true >}} @@ -131,7 +135,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< /tab >}} {{< /tabpane >}} -## Background +### Background Using `getBackground()` and `setBackground()` methods, you can get/set whether background colors and images appear --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -155,7 +159,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< /tab >}} {{< /tabpane >}} -## ShrinkToFit +### ShrinkToFit Using `getBackground()` and `setBackground()` methods, you can get/set whether the page will shrink-to-fit content on the page --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -177,4 +181,41 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} +{{< /tabpane >}} + +## Printing + +Once you've configured your PrintOptions, you're ready to print the page. To do this, +you can invoke the print function, which generates a PDF representation of the web page. +The resulting PDF can be saved to your local storage for further use or distribution. +Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded +and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` +is part of Selenium's BiDi implementation. + +There may currently be multiple implementations depending on your language of choice. For example, with Java you have +have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a +parameter. + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +**PrintsPage()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +**BrowsingContext()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} {{< /tabpane >}} \ No newline at end of file diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md index 8265d8292318..979fefa7a1e4 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md @@ -7,11 +7,15 @@ aliases: [ ] --- -Printing a website is a common requirement, whether for sharing information or archiving records. -Selenium offers a straightforward way to automate this process through the `PrintOptions()` class. -This class provides an intuitive and multifaceted way of printing webpages. +Printing a webpage is a common task, whether for sharing information or maintaining archives. +Selenium simplifies this process through its PrintOptions, PrintsPage, and browsingContext +classes, which provide a flexible and intuitive interface for automating the printing of web pages. +These classes enable you to configure printing preferences, such as page layout, margins, and scaling, +ensuring that the output meets your specific requirements. -## Orientation +## Configuring + +### Orientation Using the `getOrientation()` and `setOrientation()` methods, you can get/set the page orientation --- either `PORTRAIT` or `LANDSCAPE`. {{< tabpane text=true >}} @@ -35,7 +39,7 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the {{< /tab >}} {{< /tabpane >}} -## Range +### Range Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the range of pages to print --- e.g. "2-4". {{< tabpane text=true >}} @@ -59,7 +63,7 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r {{< /tab >}} {{< /tabpane >}} -## Size +### Size Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the paper size to print --- e.g. "A0", "A6", "Legal", "Tabloid", etc. {{< tabpane text=true >}} @@ -83,7 +87,7 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap {{< /tab >}} {{< /tabpane >}} -## Margins +### Margins Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margin sizes of the page you wish to print --- i.e. top, bottom, left, and right margins. {{< tabpane text=true >}} @@ -107,7 +111,7 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi {{< /tab >}} {{< /tabpane >}} -## Scale +### Scale Using `getScale()` and `setScale()` methods, you can get/set the scale of the page you wish to print --- e.g. 1.0 is 100% or default, 0.25 is 25%, etc. {{< tabpane text=true >}} @@ -131,7 +135,7 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa {{< /tab >}} {{< /tabpane >}} -## Background +### Background Using `getBackground()` and `setBackground()` methods, you can get/set whether background colors and images appear --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -155,7 +159,7 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b {{< /tab >}} {{< /tabpane >}} -## ShrinkToFit +### ShrinkToFit Using `getBackground()` and `setBackground()` methods, you can get/set whether the page will shrink-to-fit content on the page --- boolean `true` or `false`. {{< tabpane text=true >}} @@ -177,4 +181,41 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} +{{< /tabpane >}} + +## Printing + +Once you've configured your PrintOptions, you're ready to print the page. To do this, +you can invoke the print function, which generates a PDF representation of the web page. +The resulting PDF can be saved to your local storage for further use or distribution. +Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded +and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` +is part of Selenium's BiDi implementation. + +There may currently be multiple implementations depending on your language of choice. For example, with Java you have +have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a +parameter. + +{{< tabpane text=true >}} +{{% tab header="Java" %}} +**PrintsPage()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +**BrowsingContext()** +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< badge-implementation >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-implementation >}} +{{< /tab >}} {{< /tabpane >}} \ No newline at end of file From 2c7223748cc24a71223af0c416040d514b6df90b Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Fri, 18 Oct 2024 10:19:44 -0400 Subject: [PATCH 02/13] added reference to enabling bidi --- .../documentation/webdriver/interactions/print_page.en.md | 7 ++++--- .../documentation/webdriver/interactions/print_page.ja.md | 7 ++++--- .../webdriver/interactions/print_page.pt-br.md | 7 ++++--- .../webdriver/interactions/print_page.zh-cn.md | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md index d9b64ba16004..6ae4c864aa56 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md @@ -189,13 +189,14 @@ Once you've configured your PrintOptions, you're ready to print the page. To do you can invoke the print function, which generates a PDF representation of the web page. The resulting PDF can be saved to your local storage for further use or distribution. Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded -and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` -is part of Selenium's BiDi implementation. +and written to a file in your desired location, and using `BrowsingContext()` will return a String. -There may currently be multiple implementations depending on your language of choice. For example, with Java you have +There may currently be multiple implementations depending on your language of choice. For example, with Java you have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) + {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md index aa60ceca46f6..04ec5c42f056 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md @@ -189,13 +189,14 @@ Once you've configured your PrintOptions, you're ready to print the page. To do you can invoke the print function, which generates a PDF representation of the web page. The resulting PDF can be saved to your local storage for further use or distribution. Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded -and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` -is part of Selenium's BiDi implementation. +and written to a file in your desired location, and using `BrowsingContext()` will return a String. -There may currently be multiple implementations depending on your language of choice. For example, with Java you have +There may currently be multiple implementations depending on your language of choice. For example, with Java you have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) + {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md index 3d33e1fed7ce..55fd0846e504 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md @@ -189,13 +189,14 @@ Once you've configured your PrintOptions, you're ready to print the page. To do you can invoke the print function, which generates a PDF representation of the web page. The resulting PDF can be saved to your local storage for further use or distribution. Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded -and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` -is part of Selenium's BiDi implementation. +and written to a file in your desired location, and using `BrowsingContext()` will return a String. -There may currently be multiple implementations depending on your language of choice. For example, with Java you have +There may currently be multiple implementations depending on your language of choice. For example, with Java you have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) + {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md index 979fefa7a1e4..4971e4e90203 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md @@ -189,13 +189,14 @@ Once you've configured your PrintOptions, you're ready to print the page. To do you can invoke the print function, which generates a PDF representation of the web page. The resulting PDF can be saved to your local storage for further use or distribution. Using `PrintsPage()`, the print command will return the PDF data in base64-encoded format, which can be decoded -and written to a file in your desired location, and using `BrowsingContext()` will return a String. `BrowsingContext()` -is part of Selenium's BiDi implementation. +and written to a file in your desired location, and using `BrowsingContext()` will return a String. -There may currently be multiple implementations depending on your language of choice. For example, with Java you have +There may currently be multiple implementations depending on your language of choice. For example, with Java you have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) + {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** From d4db5e16f8ef94f65ac0967962e0dd6c937897fc Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:34:07 -0400 Subject: [PATCH 03/13] added missing imports --- .../java/dev/selenium/interactions/PrintsPageTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java index 2ff612e982d4..939b15de3cf5 100644 --- a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java +++ b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java @@ -1,10 +1,12 @@ package dev.selenium.interactions; -import org.openqa.selenium; +import org.openqa.selenium.Pdf; +import org.openqa.selenium.BrowsingContext; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; import org.openqa.selenium.print.PageMargin; import org.openqa.selenium.print.PrintOptions; - +import org.openqa.selenium.print.PrintsPage; import dev.selenium.BaseChromeTest; public class PrintsPageTest extends BaseChromeTest { @@ -28,4 +30,4 @@ public void PrintWithBrowsingContextTest() String printPage = browsingContext.print(printOptions); Assertions.assertTrue(printPage.length() > 0); } -} \ No newline at end of file +} From 2199047c15790a78dc3d5a74b544f856d72e9a96 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:05 -0400 Subject: [PATCH 04/13] Update print_page.en.md --- .../documentation/webdriver/interactions/print_page.en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md index 6ae4c864aa56..e932ad6575fa 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md @@ -195,7 +195,7 @@ There may currently be multiple implementations depending on your language of ch have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. -Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "bidi/" >}}) {{< tabpane text=true >}} {{% tab header="Java" %}} @@ -219,4 +219,4 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} -{{< /tabpane >}} \ No newline at end of file +{{< /tabpane >}} From 16ebb45dcc2a3f5be594159508e7394a71173760 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:18 -0400 Subject: [PATCH 05/13] Update print_page.ja.md --- .../documentation/webdriver/interactions/print_page.ja.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md index 04ec5c42f056..9c7559f8a1f8 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md @@ -195,7 +195,7 @@ There may currently be multiple implementations depending on your language of ch have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. -Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "bidi/" >}}) {{< tabpane text=true >}} {{% tab header="Java" %}} @@ -219,4 +219,4 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} -{{< /tabpane >}} \ No newline at end of file +{{< /tabpane >}} From 0ba6379a3dc59565a177d7a7a120a283c9ed3068 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:35 -0400 Subject: [PATCH 06/13] Update print_page.pt-br.md --- .../documentation/webdriver/interactions/print_page.pt-br.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md index 55fd0846e504..debb1c5040e0 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md @@ -195,7 +195,7 @@ There may currently be multiple implementations depending on your language of ch have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. -Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "bidi/" >}}) {{< tabpane text=true >}} {{% tab header="Java" %}} @@ -219,4 +219,4 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} -{{< /tabpane >}} \ No newline at end of file +{{< /tabpane >}} From 6819cabd8de7797b4f43b3f3852af62e24526914 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:44:48 -0400 Subject: [PATCH 07/13] Update print_page.zh-cn.md --- .../documentation/webdriver/interactions/print_page.zh-cn.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md index 4971e4e90203..c55cbf2c98e1 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md @@ -195,7 +195,7 @@ There may currently be multiple implementations depending on your language of ch have the ability to print using either `BrowingContext()` or `PrintsPage()`. Both take `PrintOptions()` objects as a parameter. -Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "../bidi/_index.md" >}}) +Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable BiDi see [Enabling Bidi]({{< ref "bidi/" >}}) {{< tabpane text=true >}} {{% tab header="Java" %}} @@ -219,4 +219,4 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tab header="Kotlin" >}} {{< badge-implementation >}} {{< /tab >}} -{{< /tabpane >}} \ No newline at end of file +{{< /tabpane >}} From 2a64f8ba7431eeb3d71f818f9cc9cb5ddbf753cc Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Sun, 20 Oct 2024 21:32:20 -0400 Subject: [PATCH 08/13] Update PrintsPageTest.java --- .../test/java/dev/selenium/interactions/PrintsPageTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java index 939b15de3cf5..1b77df8cf947 100644 --- a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java +++ b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java @@ -1,12 +1,12 @@ package dev.selenium.interactions; import org.openqa.selenium.Pdf; -import org.openqa.selenium.BrowsingContext; +import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; import org.openqa.selenium.print.PageMargin; import org.openqa.selenium.print.PrintOptions; -import org.openqa.selenium.print.PrintsPage; +import org.openqa.selenium.PrintsPage; import dev.selenium.BaseChromeTest; public class PrintsPageTest extends BaseChromeTest { From defa88aafde57f8e4b7e6fda2ea56f1a4ce98bd1 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:33:29 -0400 Subject: [PATCH 09/13] Added Sri's changes - thank you! --- .../dev/selenium/interactions/PrintsPageTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java index 1b77df8cf947..30b9c6f82d2e 100644 --- a/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java +++ b/examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java @@ -4,12 +4,22 @@ import org.openqa.selenium.bidi.browsingcontext.BrowsingContext; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.openqa.selenium.print.PageMargin; import org.openqa.selenium.print.PrintOptions; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.PrintsPage; -import dev.selenium.BaseChromeTest; +import dev.selenium.BaseTest; -public class PrintsPageTest extends BaseChromeTest { +public class PrintsPageTest extends BaseTest{ + + @BeforeEach + public void setup() { + ChromeOptions options = new ChromeOptions(); + options.setCapability("webSocketUrl", true); + driver = new ChromeDriver(options); + } @Test public void PrintWithPrintsPageTest() From 2bc1f29a0d103e7876e15a766c770d17e3f15c17 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:51:28 -0400 Subject: [PATCH 10/13] Update code example in en --- .../documentation/webdriver/interactions/print_page.en.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md index e932ad6575fa..37277550a7bc 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.en.md @@ -200,9 +200,9 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L25-L32" >}} **BrowsingContext()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-code >}} From 7818690f6655db3898caa7ca77807332c2cc117b Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:51:42 -0400 Subject: [PATCH 11/13] Update code example in ja --- .../documentation/webdriver/interactions/print_page.ja.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md index 9c7559f8a1f8..25fd68d99315 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md @@ -200,9 +200,9 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L25-L32" >}} **BrowsingContext()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-code >}} From 740557cf0a875cfda3aa2ab12b4800dd5c222667 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:51:59 -0400 Subject: [PATCH 12/13] update code examples in pt-br --- .../documentation/webdriver/interactions/print_page.pt-br.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md index debb1c5040e0..f172d2538658 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md @@ -200,9 +200,9 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L25-L32" >}} **BrowsingContext()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-code >}} From cd47268aec202bc63d1e97f08d944cb34151a0c6 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:52:28 -0400 Subject: [PATCH 13/13] Update code examples in zh-cn --- .../documentation/webdriver/interactions/print_page.zh-cn.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md index c55cbf2c98e1..a5383bd7dcce 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/print_page.zh-cn.md @@ -200,9 +200,9 @@ Note: `BrowsingContext()` is part of Selenium's BiDi implementation. To enable B {{< tabpane text=true >}} {{% tab header="Java" %}} **PrintsPage()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L13-L20" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L25-L32" >}} **BrowsingContext()** -{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L23-L30" >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42" >}} {{< /tab >}} {{< tab header="CSharp" >}} {{< badge-code >}}