Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions playwright/src/main/java/com/microsoft/playwright/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public Margin withLeft(String left) {
/**
* Scale of the webpage rendering. Defaults to {@code 1}. Scale amount must be between 0.1 and 2.
*/
public Integer scale;
public Double scale;
/**
* Display header and footer. Defaults to {@code false}.
*/
Expand Down Expand Up @@ -660,7 +660,7 @@ public PdfOptions withPath(Path path) {
this.path = path;
return this;
}
public PdfOptions withScale(Integer scale) {
public PdfOptions withScale(Double scale) {
this.scale = scale;
return this;
}
Expand Down
15 changes: 13 additions & 2 deletions playwright/src/test/java/com/microsoft/playwright/TestPdf.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.api.io.TempDir;

import java.io.File;
import java.io.IOException;
Expand All @@ -31,13 +32,23 @@ public class TestPdf extends TestBase {
@Test
@EnabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
@DisabledIf(value="com.microsoft.playwright.TestBase#isHeadful", disabledReason="skip")
void shouldBeAbleToSaveFile() throws IOException {
Path path = File.createTempFile("output", ".pdf").toPath();
void shouldBeAbleToSaveFile(@TempDir Path tempDir) throws IOException {
Path path = tempDir.resolve("output.pdf");
page.pdf(new Page.PdfOptions().withPath(path));
long size = Files.size(path);
assertTrue(size > 0);
}

@Test
@EnabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
@DisabledIf(value="com.microsoft.playwright.TestBase#isHeadful", disabledReason="skip")
void shouldSupportFractionalScaleValue(@TempDir Path tempDir) throws IOException {
Path path = tempDir.resolve("output.pdf");
page.pdf(new Page.PdfOptions().withPath(path).withScale(0.5));
long size = Files.size(path);
assertTrue(size > 0);
}

@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
void shouldOnlyHavePdfInChromium() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class Mapping {
add("Page.pdf.options.margin.left", "string|number", "String");
add("Page.pdf.options.width", "string|number", "String");
add("Page.pdf.options.height", "string|number", "String");
add("Page.pdf.options.scale", "number", "Double");

add("Page.goto.options", "Object", "NavigateOptions");
add("Frame.goto.options", "Object", "NavigateOptions");
Expand Down