diff --git a/playwright/src/main/java/com/microsoft/playwright/Browser.java b/playwright/src/main/java/com/microsoft/playwright/Browser.java index 82d8f739..c4f1f7d0 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Browser.java +++ b/playwright/src/main/java/com/microsoft/playwright/Browser.java @@ -140,6 +140,11 @@ public interface Browser extends AutoCloseable { * be scaled down if necessary to fit the specified size. */ public RecordVideoSize recordVideoSize; + /** + * Emulates consistent window screen size available inside web page via {@code window.screen}. Is only used when the {@code viewport} + * is set. + */ + public ScreenSize screenSize; /** * Populates context with given storage state. This option can be used to initialize context with logged-in information * obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. @@ -162,7 +167,7 @@ public interface Browser extends AutoCloseable { */ public String userAgent; /** - * Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. */ public Optional viewportSize; @@ -254,6 +259,13 @@ public interface Browser extends AutoCloseable { this.recordVideoSize = recordVideoSize; return this; } + public NewContextOptions setScreenSize(int width, int height) { + return setScreenSize(new ScreenSize(width, height)); + } + public NewContextOptions setScreenSize(ScreenSize screenSize) { + this.screenSize = screenSize; + return this; + } public NewContextOptions setStorageState(String storageState) { this.storageState = storageState; return this; @@ -363,6 +375,11 @@ public interface Browser extends AutoCloseable { * be scaled down if necessary to fit the specified size. */ public RecordVideoSize recordVideoSize; + /** + * Emulates consistent window screen size available inside web page via {@code window.screen}. Is only used when the {@code viewport} + * is set. + */ + public ScreenSize screenSize; /** * Populates context with given storage state. This option can be used to initialize context with logged-in information * obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. @@ -385,7 +402,7 @@ public interface Browser extends AutoCloseable { */ public String userAgent; /** - * Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. */ public Optional viewportSize; @@ -477,6 +494,13 @@ public interface Browser extends AutoCloseable { this.recordVideoSize = recordVideoSize; return this; } + public NewPageOptions setScreenSize(int width, int height) { + return setScreenSize(new ScreenSize(width, height)); + } + public NewPageOptions setScreenSize(ScreenSize screenSize) { + this.screenSize = screenSize; + return this; + } public NewPageOptions setStorageState(String storageState) { this.storageState = storageState; return this; diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index 567d87ac..5e76f52c 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -362,6 +362,11 @@ public interface BrowserType { * be scaled down if necessary to fit the specified size. */ public RecordVideoSize recordVideoSize; + /** + * Emulates consistent window screen size available inside web page via {@code window.screen}. Is only used when the {@code viewport} + * is set. + */ + public ScreenSize screenSize; /** * Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. * Defaults to 0. @@ -383,7 +388,7 @@ public interface BrowserType { */ public String userAgent; /** - * Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport. */ public Optional viewportSize; @@ -527,6 +532,13 @@ public interface BrowserType { this.recordVideoSize = recordVideoSize; return this; } + public LaunchPersistentContextOptions setScreenSize(int width, int height) { + return setScreenSize(new ScreenSize(width, height)); + } + public LaunchPersistentContextOptions setScreenSize(ScreenSize screenSize) { + this.screenSize = screenSize; + return this; + } public LaunchPersistentContextOptions setSlowMo(double slowMo) { this.slowMo = slowMo; return this; diff --git a/playwright/src/main/java/com/microsoft/playwright/options/ScreenSize.java b/playwright/src/main/java/com/microsoft/playwright/options/ScreenSize.java new file mode 100644 index 00000000..ba90ab2e --- /dev/null +++ b/playwright/src/main/java/com/microsoft/playwright/options/ScreenSize.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.playwright.options; + +public class ScreenSize { + /** + * page width in pixels. + */ + public int width; + /** + * page height in pixels. + */ + public int height; + + public ScreenSize(int width, int height) { + this.width = width; + this.height = height; + } +} \ No newline at end of file diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index 93248a9a..e3872e0a 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.11.0-next-1617006126000 +1.11.0-next-1617087307000