diff --git a/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java b/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java index 1fdae6de..f9742a69 100644 --- a/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java +++ b/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java @@ -26,17 +26,17 @@ import java.util.*; import java.util.List; import java.util.stream.Collectors; -abstract class Element

{ +abstract class Element { final String jsonName; final String jsonPath; final JsonElement jsonElement; - final P parent; + final Element parent; - Element(P parent, JsonElement jsonElement) { + Element(Element parent, JsonElement jsonElement) { this(parent, false, jsonElement); } - Element(P parent, boolean useParentJsonPath, JsonElement jsonElement) { + Element(Element parent, boolean useParentJsonPath, JsonElement jsonElement) { this.parent = parent; if (jsonElement != null && jsonElement.isJsonObject()) { this.jsonName = jsonElement.getAsJsonObject().get("name").getAsString();; @@ -55,11 +55,16 @@ abstract class Element

{ TypeDefinition typeScope() { return parent.typeScope(); } + + static String toTitle(String name) { + return Character.toUpperCase(name.charAt(0)) + name.substring(1); + } } // Represents return type of a method, type of a method param or type of a field. class TypeRef extends Element { String customType; + boolean isNestedClass; TypeRef(Element parent, JsonElement jsonElement) { super(parent, true, jsonElement); @@ -100,6 +105,7 @@ class TypeRef extends Element { typeScope().createEnum(customType, jsonName); } else if (isClass) { typeScope().createNestedClass(customType, this, jsonElement.getAsJsonObject()); + isNestedClass = true; } } @@ -146,14 +152,9 @@ class TypeRef extends Element { .replace("number", "int") .replace("null|", ""); } - - private static String toTitle(String name) { - return Character.toUpperCase(name.charAt(0)) + name.substring(1); - } } -abstract class TypeDefinition extends Element { - final List methods = new ArrayList<>(); +abstract class TypeDefinition extends Element { final List enums = new ArrayList<>(); final List classes = new ArrayList<>(); @@ -201,13 +202,10 @@ abstract class TypeDefinition extends Element { for (NestedClass c : classes) { c.writeTo(output, offset); } - for (Method m : methods) { - m.writeTo(output, offset); - } } } -class Method extends Element { +class Method extends Element { final TypeRef returnType; final List params = new ArrayList<>(); @@ -252,7 +250,7 @@ class Method extends Element { } } -class Param extends Element { +class Param extends Element { final TypeRef type; Param(Method method, JsonObject jsonElement) { @@ -265,7 +263,7 @@ class Param extends Element { } } -class Field extends Element { +class Field extends Element { final String name; final TypeRef type; @@ -275,12 +273,17 @@ class Field extends Element { this.type = new TypeRef(this, jsonElement.getAsJsonObject().get("type")); } + String toJava() { + return type.toJava() + " " + name; + } + void writeTo(List output, String offset) { - output.add(offset + type.toJava() + " " + name + ";"); + output.add(offset + toJava() + ";"); } } class Interface extends TypeDefinition { + private final List methods = new ArrayList<>(); private static String header = "/**\n" + " * Copyright (c) Microsoft Corporation.\n" + " *\n" + @@ -319,8 +322,11 @@ class Interface extends TypeDefinition { output.add("import java.util.*;"); output.add("import java.util.function.BiConsumer;"); output.add(""); - output.add("interface " + jsonName + " {"); + output.add("public interface " + jsonName + " {"); super.writeTo(output, offset + " "); + for (Method m : methods) { + m.writeTo(output, offset + " "); + } output.add("}"); output.add("\n"); } @@ -341,13 +347,41 @@ class NestedClass extends TypeDefinition { } void writeTo(List output, String offset) { - output.add(offset + "class " + name + " {"); - super.writeTo(output, offset + " "); + String access = parent.typeScope() instanceof NestedClass ? "public " : ""; + output.add(offset + access + "class " + name + " {"); + String bodyOffset = offset + " "; + super.writeTo(output, bodyOffset); for (Field f : fields) { - f.writeTo(output, offset + " "); + f.writeTo(output, bodyOffset); } + output.add(""); + writeBuilderMethods(output, bodyOffset); output.add(offset + "}"); } + + private void writeBuilderMethods(List output, String bodyOffset) { + if (parent.typeScope() instanceof NestedClass) { + NestedClass outer = (NestedClass) parent.typeScope(); + output.add(bodyOffset + name + "() {"); + output.add(bodyOffset + "}"); + output.add(bodyOffset + "public " + outer.name + " done() {"); + output.add(bodyOffset + " return " + outer.name + ".this;"); + output.add(bodyOffset + "}"); + output.add(""); + } + for (Field f : fields) { + if (f.type.isNestedClass) { + output.add(bodyOffset + "public " + f.type.toJava() + " set" + toTitle(f.name) + "() {"); + output.add(bodyOffset + " this." + f.name + " = new " + f.type.toJava() + "();"); + output.add(bodyOffset + " return this." + f.name + ";"); + } else { + output.add(bodyOffset + "public " + name + " with" + toTitle(f.name) + "(" + f.toJava() + ") {"); + output.add(bodyOffset + " this." + f.name + " = " + f.name + ";"); + output.add(bodyOffset + " return this;"); + } + output.add(bodyOffset + "}"); + } + } } class Enum extends TypeDefinition { diff --git a/lib/src/main/java/com/microsoft/playwright/Accessibility.java b/lib/src/main/java/com/microsoft/playwright/Accessibility.java index 87cd4910..ac6ed7c5 100644 --- a/lib/src/main/java/com/microsoft/playwright/Accessibility.java +++ b/lib/src/main/java/com/microsoft/playwright/Accessibility.java @@ -19,10 +19,19 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Accessibility { +public interface Accessibility { class SnapshotOptions { Boolean interestingOnly; ElementHandle root; + + public SnapshotOptions withInterestingOnly(Boolean interestingOnly) { + this.interestingOnly = interestingOnly; + return this; + } + public SnapshotOptions withRoot(ElementHandle root) { + this.root = root; + return this; + } } Object snapshot(SnapshotOptions options); } diff --git a/lib/src/main/java/com/microsoft/playwright/Browser.java b/lib/src/main/java/com/microsoft/playwright/Browser.java index 38de336b..c9e6c9ba 100644 --- a/lib/src/main/java/com/microsoft/playwright/Browser.java +++ b/lib/src/main/java/com/microsoft/playwright/Browser.java @@ -19,21 +19,70 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Browser { +public interface Browser { class NewContextOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -57,21 +106,159 @@ interface Browser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewContextOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewContextOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewContextOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewContextOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewContextOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewContextOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewContextOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewContextOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewContextOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewContextOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewContextOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewContextOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewContextOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewContextOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewContextOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewContextOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewContextOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewContextOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } class NewPageOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -95,6 +282,95 @@ interface Browser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewPageOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewPageOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewPageOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewPageOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewPageOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewPageOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewPageOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewPageOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewPageOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewPageOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewPageOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewPageOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewPageOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewPageOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewPageOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewPageOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewPageOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewPageOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } void close(); List contexts(); diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserContext.java b/lib/src/main/java/com/microsoft/playwright/BrowserContext.java index edf795c0..90560dc9 100644 --- a/lib/src/main/java/com/microsoft/playwright/BrowserContext.java +++ b/lib/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -19,9 +19,14 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface BrowserContext { +public interface BrowserContext { class GrantPermissionsOptions { String origin; + + public GrantPermissionsOptions withOrigin(String origin) { + this.origin = origin; + return this; + } } void close(); void addCookies(List cookies); diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserServer.java b/lib/src/main/java/com/microsoft/playwright/BrowserServer.java index f0b44953..94ee2bdd 100644 --- a/lib/src/main/java/com/microsoft/playwright/BrowserServer.java +++ b/lib/src/main/java/com/microsoft/playwright/BrowserServer.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface BrowserServer { +public interface BrowserServer { void close(); void kill(); Object process(); diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserType.java b/lib/src/main/java/com/microsoft/playwright/BrowserType.java index 6867ae9e..17f0a55c 100644 --- a/lib/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/lib/src/main/java/com/microsoft/playwright/BrowserType.java @@ -19,19 +19,59 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface BrowserType { +public interface BrowserType { class ConnectOptions { String wsEndpoint; Integer slowMo; Logger logger; Integer timeout; + + public ConnectOptions withWsEndpoint(String wsEndpoint) { + this.wsEndpoint = wsEndpoint; + return this; + } + public ConnectOptions withSlowMo(Integer slowMo) { + this.slowMo = slowMo; + return this; + } + public ConnectOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public ConnectOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class LaunchOptions { - class Proxy { + public class Proxy { String server; String bypass; String username; String password; + + Proxy() { + } + public LaunchOptions done() { + return LaunchOptions.this; + } + + public Proxy withServer(String server) { + this.server = server; + return this; + } + public Proxy withBypass(String bypass) { + this.bypass = bypass; + return this; + } + public Proxy withUsername(String username) { + this.username = username; + return this; + } + public Proxy withPassword(String password) { + this.password = password; + return this; + } } Boolean headless; String executablePath; @@ -50,27 +90,168 @@ interface BrowserType { String env; Boolean devtools; Integer slowMo; + + public LaunchOptions withHeadless(Boolean headless) { + this.headless = headless; + return this; + } + public LaunchOptions withExecutablePath(String executablePath) { + this.executablePath = executablePath; + return this; + } + public LaunchOptions withArgs(List args) { + this.args = args; + return this; + } + public LaunchOptions withIgnoreDefaultArgs(Boolean ignoreDefaultArgs) { + this.ignoreDefaultArgs = ignoreDefaultArgs; + return this; + } + public Proxy setProxy() { + this.proxy = new Proxy(); + return this.proxy; + } + public LaunchOptions withDownloadsPath(String downloadsPath) { + this.downloadsPath = downloadsPath; + return this; + } + public LaunchOptions withArtifactsPath(String artifactsPath) { + this.artifactsPath = artifactsPath; + return this; + } + public LaunchOptions withChromiumSandbox(Boolean chromiumSandbox) { + this.chromiumSandbox = chromiumSandbox; + return this; + } + public LaunchOptions withFirefoxUserPrefs(String firefoxUserPrefs) { + this.firefoxUserPrefs = firefoxUserPrefs; + return this; + } + public LaunchOptions withHandleSIGINT(Boolean handleSIGINT) { + this.handleSIGINT = handleSIGINT; + return this; + } + public LaunchOptions withHandleSIGTERM(Boolean handleSIGTERM) { + this.handleSIGTERM = handleSIGTERM; + return this; + } + public LaunchOptions withHandleSIGHUP(Boolean handleSIGHUP) { + this.handleSIGHUP = handleSIGHUP; + return this; + } + public LaunchOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public LaunchOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public LaunchOptions withEnv(String env) { + this.env = env; + return this; + } + public LaunchOptions withDevtools(Boolean devtools) { + this.devtools = devtools; + return this; + } + public LaunchOptions withSlowMo(Integer slowMo) { + this.slowMo = slowMo; + return this; + } } class LaunchPersistentContextOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Proxy { + public class Proxy { String server; String bypass; String username; String password; + + Proxy() { + } + public LaunchPersistentContextOptions done() { + return LaunchPersistentContextOptions.this; + } + + public Proxy withServer(String server) { + this.server = server; + return this; + } + public Proxy withBypass(String bypass) { + this.bypass = bypass; + return this; + } + public Proxy withUsername(String username) { + this.username = username; + return this; + } + public Proxy withPassword(String password) { + this.password = password; + return this; + } } - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public LaunchPersistentContextOptions done() { + return LaunchPersistentContextOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public LaunchPersistentContextOptions done() { + return LaunchPersistentContextOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public LaunchPersistentContextOptions done() { + return LaunchPersistentContextOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean headless; String executablePath; @@ -109,13 +290,185 @@ interface BrowserType { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public LaunchPersistentContextOptions withHeadless(Boolean headless) { + this.headless = headless; + return this; + } + public LaunchPersistentContextOptions withExecutablePath(String executablePath) { + this.executablePath = executablePath; + return this; + } + public LaunchPersistentContextOptions withArgs(List args) { + this.args = args; + return this; + } + public LaunchPersistentContextOptions withIgnoreDefaultArgs(String ignoreDefaultArgs) { + this.ignoreDefaultArgs = ignoreDefaultArgs; + return this; + } + public Proxy setProxy() { + this.proxy = new Proxy(); + return this.proxy; + } + public LaunchPersistentContextOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public LaunchPersistentContextOptions withDownloadsPath(String downloadsPath) { + this.downloadsPath = downloadsPath; + return this; + } + public LaunchPersistentContextOptions withArtifactsPath(String artifactsPath) { + this.artifactsPath = artifactsPath; + return this; + } + public LaunchPersistentContextOptions withChromiumSandbox(Boolean chromiumSandbox) { + this.chromiumSandbox = chromiumSandbox; + return this; + } + public LaunchPersistentContextOptions withHandleSIGINT(Boolean handleSIGINT) { + this.handleSIGINT = handleSIGINT; + return this; + } + public LaunchPersistentContextOptions withHandleSIGTERM(Boolean handleSIGTERM) { + this.handleSIGTERM = handleSIGTERM; + return this; + } + public LaunchPersistentContextOptions withHandleSIGHUP(Boolean handleSIGHUP) { + this.handleSIGHUP = handleSIGHUP; + return this; + } + public LaunchPersistentContextOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public LaunchPersistentContextOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public LaunchPersistentContextOptions withEnv(String env) { + this.env = env; + return this; + } + public LaunchPersistentContextOptions withDevtools(Boolean devtools) { + this.devtools = devtools; + return this; + } + public LaunchPersistentContextOptions withSlowMo(Integer slowMo) { + this.slowMo = slowMo; + return this; + } + public LaunchPersistentContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public LaunchPersistentContextOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public LaunchPersistentContextOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public LaunchPersistentContextOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public LaunchPersistentContextOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public LaunchPersistentContextOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public LaunchPersistentContextOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public LaunchPersistentContextOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public LaunchPersistentContextOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public LaunchPersistentContextOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public LaunchPersistentContextOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public LaunchPersistentContextOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public LaunchPersistentContextOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public LaunchPersistentContextOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public LaunchPersistentContextOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public LaunchPersistentContextOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public LaunchPersistentContextOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } class LaunchServerOptions { - class Proxy { + public class Proxy { String server; String bypass; String username; String password; + + Proxy() { + } + public LaunchServerOptions done() { + return LaunchServerOptions.this; + } + + public Proxy withServer(String server) { + this.server = server; + return this; + } + public Proxy withBypass(String bypass) { + this.bypass = bypass; + return this; + } + public Proxy withUsername(String username) { + this.username = username; + return this; + } + public Proxy withPassword(String password) { + this.password = password; + return this; + } } Boolean headless; Integer port; @@ -134,6 +487,75 @@ interface BrowserType { Integer timeout; String env; Boolean devtools; + + public LaunchServerOptions withHeadless(Boolean headless) { + this.headless = headless; + return this; + } + public LaunchServerOptions withPort(Integer port) { + this.port = port; + return this; + } + public LaunchServerOptions withExecutablePath(String executablePath) { + this.executablePath = executablePath; + return this; + } + public LaunchServerOptions withArgs(List args) { + this.args = args; + return this; + } + public LaunchServerOptions withIgnoreDefaultArgs(String ignoreDefaultArgs) { + this.ignoreDefaultArgs = ignoreDefaultArgs; + return this; + } + public Proxy setProxy() { + this.proxy = new Proxy(); + return this.proxy; + } + public LaunchServerOptions withDownloadsPath(String downloadsPath) { + this.downloadsPath = downloadsPath; + return this; + } + public LaunchServerOptions withArtifactsPath(String artifactsPath) { + this.artifactsPath = artifactsPath; + return this; + } + public LaunchServerOptions withChromiumSandbox(Boolean chromiumSandbox) { + this.chromiumSandbox = chromiumSandbox; + return this; + } + public LaunchServerOptions withFirefoxUserPrefs(String firefoxUserPrefs) { + this.firefoxUserPrefs = firefoxUserPrefs; + return this; + } + public LaunchServerOptions withHandleSIGINT(Boolean handleSIGINT) { + this.handleSIGINT = handleSIGINT; + return this; + } + public LaunchServerOptions withHandleSIGTERM(Boolean handleSIGTERM) { + this.handleSIGTERM = handleSIGTERM; + return this; + } + public LaunchServerOptions withHandleSIGHUP(Boolean handleSIGHUP) { + this.handleSIGHUP = handleSIGHUP; + return this; + } + public LaunchServerOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public LaunchServerOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public LaunchServerOptions withEnv(String env) { + this.env = env; + return this; + } + public LaunchServerOptions withDevtools(Boolean devtools) { + this.devtools = devtools; + return this; + } } Browser connect(ConnectOptions options); String executablePath(); diff --git a/lib/src/main/java/com/microsoft/playwright/CDPSession.java b/lib/src/main/java/com/microsoft/playwright/CDPSession.java index 2ec9e7b8..1d8a8867 100644 --- a/lib/src/main/java/com/microsoft/playwright/CDPSession.java +++ b/lib/src/main/java/com/microsoft/playwright/CDPSession.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface CDPSession { +public interface CDPSession { void detach(); Object send(String method, Object params); } diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java index 65c00e86..3a71d759 100644 --- a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java @@ -19,26 +19,88 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface ChromiumBrowser { +public interface ChromiumBrowser { class StartTracingOptions { String path; Boolean screenshots; List categories; + + public StartTracingOptions withPath(String path) { + this.path = path; + return this; + } + public StartTracingOptions withScreenshots(Boolean screenshots) { + this.screenshots = screenshots; + return this; + } + public StartTracingOptions withCategories(List categories) { + this.categories = categories; + return this; + } } class NewContextOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -62,21 +124,159 @@ interface ChromiumBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewContextOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewContextOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewContextOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewContextOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewContextOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewContextOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewContextOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewContextOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewContextOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewContextOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewContextOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewContextOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewContextOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewContextOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewContextOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewContextOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewContextOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewContextOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } class NewPageOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -100,6 +300,95 @@ interface ChromiumBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewPageOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewPageOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewPageOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewPageOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewPageOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewPageOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewPageOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewPageOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewPageOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewPageOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewPageOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewPageOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewPageOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewPageOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewPageOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewPageOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewPageOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewPageOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } CDPSession newBrowserCDPSession(); void startTracing(Page page, StartTracingOptions options); diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java index b5146659..5883c24b 100644 --- a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java @@ -19,9 +19,14 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface ChromiumBrowserContext { +public interface ChromiumBrowserContext { class GrantPermissionsOptions { String origin; + + public GrantPermissionsOptions withOrigin(String origin) { + this.origin = origin; + return this; + } } List backgroundPages(); CDPSession newCDPSession(Page page); diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java b/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java index 4b5d3c1b..553c6400 100644 --- a/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java @@ -19,13 +19,27 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface ChromiumCoverage { +public interface ChromiumCoverage { class StartCSSCoverageOptions { Boolean resetOnNavigation; + + public StartCSSCoverageOptions withResetOnNavigation(Boolean resetOnNavigation) { + this.resetOnNavigation = resetOnNavigation; + return this; + } } class StartJSCoverageOptions { Boolean resetOnNavigation; Boolean reportAnonymousScripts; + + public StartJSCoverageOptions withResetOnNavigation(Boolean resetOnNavigation) { + this.resetOnNavigation = resetOnNavigation; + return this; + } + public StartJSCoverageOptions withReportAnonymousScripts(Boolean reportAnonymousScripts) { + this.reportAnonymousScripts = reportAnonymousScripts; + return this; + } } void startCSSCoverage(StartCSSCoverageOptions options); void startJSCoverage(StartJSCoverageOptions options); diff --git a/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java b/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java index 271c1871..5f9b8c97 100644 --- a/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java +++ b/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java @@ -19,11 +19,24 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface ConsoleMessage { +public interface ConsoleMessage { class Location { String url; int lineNumber; int columnNumber; + + public Location withUrl(String url) { + this.url = url; + return this; + } + public Location withLineNumber(int lineNumber) { + this.lineNumber = lineNumber; + return this; + } + public Location withColumnNumber(int columnNumber) { + this.columnNumber = columnNumber; + return this; + } } List args(); Location location(); diff --git a/lib/src/main/java/com/microsoft/playwright/Dialog.java b/lib/src/main/java/com/microsoft/playwright/Dialog.java index 5fbf047d..01266242 100644 --- a/lib/src/main/java/com/microsoft/playwright/Dialog.java +++ b/lib/src/main/java/com/microsoft/playwright/Dialog.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Dialog { +public interface Dialog { void accept(String promptText); String defaultValue(); void dismiss(); diff --git a/lib/src/main/java/com/microsoft/playwright/Download.java b/lib/src/main/java/com/microsoft/playwright/Download.java index fb966261..ec2cab66 100644 --- a/lib/src/main/java/com/microsoft/playwright/Download.java +++ b/lib/src/main/java/com/microsoft/playwright/Download.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Download { +public interface Download { Readable createReadStream(); void delete(); String failure(); diff --git a/lib/src/main/java/com/microsoft/playwright/ElementHandle.java b/lib/src/main/java/com/microsoft/playwright/ElementHandle.java index d52f214e..8ccbc711 100644 --- a/lib/src/main/java/com/microsoft/playwright/ElementHandle.java +++ b/lib/src/main/java/com/microsoft/playwright/ElementHandle.java @@ -19,19 +19,47 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface ElementHandle { +public interface ElementHandle { enum ElementState { DISABLED, ENABLED, HIDDEN, STABLE, VISIBLE} class CheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public CheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public CheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public CheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ClickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public ClickOptions done() { + return ClickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer clickCount; @@ -41,13 +69,61 @@ interface ElementHandle { Boolean force; Boolean noWaitAfter; Integer timeout; + + public ClickOptions withButton(Button button) { + this.button = button; + return this; + } + public ClickOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } + public ClickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public ClickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public ClickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public ClickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public ClickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class DblclickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public DblclickOptions done() { + return DblclickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer delay; @@ -56,26 +132,109 @@ interface ElementHandle { Boolean force; Boolean noWaitAfter; Integer timeout; + + public DblclickOptions withButton(Button button) { + this.button = button; + return this; + } + public DblclickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public DblclickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public DblclickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public DblclickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public DblclickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class FillOptions { Boolean noWaitAfter; Integer timeout; + + public FillOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public FillOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class HoverOptions { enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public HoverOptions done() { + return HoverOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Position position; Set modifiers; Boolean force; Integer timeout; + + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public HoverOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public HoverOptions withForce(Boolean force) { + this.force = force; + return this; + } + public HoverOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class PressOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public PressOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public PressOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public PressOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ScreenshotOptions { enum Type { JPEG, PNG} @@ -84,38 +243,127 @@ interface ElementHandle { Integer quality; Boolean omitBackground; Integer timeout; + + public ScreenshotOptions withPath(String path) { + this.path = path; + return this; + } + public ScreenshotOptions withType(Type type) { + this.type = type; + return this; + } + public ScreenshotOptions withQuality(Integer quality) { + this.quality = quality; + return this; + } + public ScreenshotOptions withOmitBackground(Boolean omitBackground) { + this.omitBackground = omitBackground; + return this; + } + public ScreenshotOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ScrollIntoViewIfNeededOptions { Integer timeout; + + public ScrollIntoViewIfNeededOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SelectOptionOptions { Boolean noWaitAfter; Integer timeout; + + public SelectOptionOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SelectOptionOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SelectTextOptions { Integer timeout; + + public SelectTextOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SetInputFilesOptions { Boolean noWaitAfter; Integer timeout; + + public SetInputFilesOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SetInputFilesOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class TypeOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public TypeOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public TypeOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public TypeOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class UncheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public UncheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public UncheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public UncheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForElementStateOptions { Integer timeout; + + public WaitForElementStateOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForSelectorOptions { enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE} State state; Integer timeout; + + public WaitForSelectorOptions withState(State state) { + this.state = state; + return this; + } + public WaitForSelectorOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } ElementHandle querySelector(String selector); List querySelectorAll(String selector); diff --git a/lib/src/main/java/com/microsoft/playwright/FileChooser.java b/lib/src/main/java/com/microsoft/playwright/FileChooser.java index 324fd0aa..79358fcc 100644 --- a/lib/src/main/java/com/microsoft/playwright/FileChooser.java +++ b/lib/src/main/java/com/microsoft/playwright/FileChooser.java @@ -19,10 +19,19 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface FileChooser { +public interface FileChooser { class SetFilesOptions { Boolean noWaitAfter; Integer timeout; + + public SetFilesOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SetFilesOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } ElementHandle element(); boolean isMultiple(); diff --git a/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java b/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java index a16bd714..b78995f2 100644 --- a/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java +++ b/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java @@ -19,21 +19,70 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface FirefoxBrowser { +public interface FirefoxBrowser { class NewContextOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -57,21 +106,159 @@ interface FirefoxBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewContextOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewContextOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewContextOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewContextOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewContextOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewContextOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewContextOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewContextOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewContextOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewContextOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewContextOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewContextOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewContextOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewContextOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewContextOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewContextOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewContextOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewContextOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } class NewPageOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -95,6 +282,95 @@ interface FirefoxBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewPageOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewPageOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewPageOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewPageOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewPageOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewPageOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewPageOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewPageOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewPageOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewPageOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewPageOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewPageOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewPageOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewPageOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewPageOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewPageOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewPageOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewPageOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } void close(); List contexts(); diff --git a/lib/src/main/java/com/microsoft/playwright/Frame.java b/lib/src/main/java/com/microsoft/playwright/Frame.java index dc635832..3904be38 100644 --- a/lib/src/main/java/com/microsoft/playwright/Frame.java +++ b/lib/src/main/java/com/microsoft/playwright/Frame.java @@ -19,30 +19,88 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Frame { +public interface Frame { enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE} class AddScriptTagOptions { String url; String path; String content; String type; + + public AddScriptTagOptions withUrl(String url) { + this.url = url; + return this; + } + public AddScriptTagOptions withPath(String path) { + this.path = path; + return this; + } + public AddScriptTagOptions withContent(String content) { + this.content = content; + return this; + } + public AddScriptTagOptions withType(String type) { + this.type = type; + return this; + } } class AddStyleTagOptions { String url; String path; String content; + + public AddStyleTagOptions withUrl(String url) { + this.url = url; + return this; + } + public AddStyleTagOptions withPath(String path) { + this.path = path; + return this; + } + public AddStyleTagOptions withContent(String content) { + this.content = content; + return this; + } } class CheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public CheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public CheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public CheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ClickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public ClickOptions done() { + return ClickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer clickCount; @@ -52,13 +110,61 @@ interface Frame { Boolean force; Boolean noWaitAfter; Integer timeout; + + public ClickOptions withButton(Button button) { + this.button = button; + return this; + } + public ClickOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } + public ClickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public ClickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public ClickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public ClickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public ClickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class DblclickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public DblclickOptions done() { + return DblclickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer delay; @@ -67,91 +173,306 @@ interface Frame { Boolean force; Boolean noWaitAfter; Integer timeout; + + public DblclickOptions withButton(Button button) { + this.button = button; + return this; + } + public DblclickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public DblclickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public DblclickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public DblclickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public DblclickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class DispatchEventOptions { Integer timeout; + + public DispatchEventOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class FillOptions { Boolean noWaitAfter; Integer timeout; + + public FillOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public FillOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class FocusOptions { Integer timeout; + + public FocusOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class GetAttributeOptions { Integer timeout; + + public GetAttributeOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class GotoOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; String referer; + + public GotoOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public GotoOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } + public GotoOptions withReferer(String referer) { + this.referer = referer; + return this; + } } class HoverOptions { enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public HoverOptions done() { + return HoverOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Position position; Set modifiers; Boolean force; Integer timeout; + + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public HoverOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public HoverOptions withForce(Boolean force) { + this.force = force; + return this; + } + public HoverOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class InnerHTMLOptions { Integer timeout; + + public InnerHTMLOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class InnerTextOptions { Integer timeout; + + public InnerTextOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class PressOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public PressOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public PressOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public PressOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SelectOptionOptions { Boolean noWaitAfter; Integer timeout; + + public SelectOptionOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SelectOptionOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SetContentOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; + + public SetContentOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public SetContentOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class SetInputFilesOptions { Boolean noWaitAfter; Integer timeout; + + public SetInputFilesOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SetInputFilesOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class TextContentOptions { Integer timeout; + + public TextContentOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class TypeOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public TypeOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public TypeOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public TypeOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class UncheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public UncheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public UncheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public UncheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForFunctionOptions { double polling; Integer timeout; + + public WaitForFunctionOptions withPolling(double polling) { + this.polling = polling; + return this; + } + public WaitForFunctionOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForLoadStateOptions { Integer timeout; + + public WaitForLoadStateOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForNavigationOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; String url; WaitUntil waitUntil; + + public WaitForNavigationOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public WaitForNavigationOptions withUrl(String url) { + this.url = url; + return this; + } + public WaitForNavigationOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class WaitForSelectorOptions { enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE} State state; Integer timeout; + + public WaitForSelectorOptions withState(State state) { + this.state = state; + return this; + } + public WaitForSelectorOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } ElementHandle querySelector(String selector); List querySelectorAll(String selector); diff --git a/lib/src/main/java/com/microsoft/playwright/JSHandle.java b/lib/src/main/java/com/microsoft/playwright/JSHandle.java index bb699fcc..86619bdd 100644 --- a/lib/src/main/java/com/microsoft/playwright/JSHandle.java +++ b/lib/src/main/java/com/microsoft/playwright/JSHandle.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface JSHandle { +public interface JSHandle { ElementHandle asElement(); void dispose(); Object evaluate(String pageFunction, Object arg); diff --git a/lib/src/main/java/com/microsoft/playwright/Keyboard.java b/lib/src/main/java/com/microsoft/playwright/Keyboard.java index 24305a90..32081f30 100644 --- a/lib/src/main/java/com/microsoft/playwright/Keyboard.java +++ b/lib/src/main/java/com/microsoft/playwright/Keyboard.java @@ -19,12 +19,22 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Keyboard { +public interface Keyboard { class PressOptions { Integer delay; + + public PressOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } } class TypeOptions { Integer delay; + + public TypeOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } } void down(String key); void insertText(String text); diff --git a/lib/src/main/java/com/microsoft/playwright/Logger.java b/lib/src/main/java/com/microsoft/playwright/Logger.java index 449e7cc9..59c0a825 100644 --- a/lib/src/main/java/com/microsoft/playwright/Logger.java +++ b/lib/src/main/java/com/microsoft/playwright/Logger.java @@ -19,10 +19,15 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Logger { +public interface Logger { enum Severity { ERROR, INFO, VERBOSE, WARNING} class LogHints { String color; + + public LogHints withColor(String color) { + this.color = color; + return this; + } } boolean isEnabled(String name, Severity severity); void log(String name, Severity severity, String message, List args, LogHints hints); diff --git a/lib/src/main/java/com/microsoft/playwright/Mouse.java b/lib/src/main/java/com/microsoft/playwright/Mouse.java index 765bb89c..47b3cf98 100644 --- a/lib/src/main/java/com/microsoft/playwright/Mouse.java +++ b/lib/src/main/java/com/microsoft/playwright/Mouse.java @@ -19,30 +19,75 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Mouse { +public interface Mouse { class ClickOptions { enum Button { LEFT, MIDDLE, RIGHT} Button button; Integer clickCount; Integer delay; + + public ClickOptions withButton(Button button) { + this.button = button; + return this; + } + public ClickOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } + public ClickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } } class DblclickOptions { enum Button { LEFT, MIDDLE, RIGHT} Button button; Integer delay; + + public DblclickOptions withButton(Button button) { + this.button = button; + return this; + } + public DblclickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } } class DownOptions { enum Button { LEFT, MIDDLE, RIGHT} Button button; Integer clickCount; + + public DownOptions withButton(Button button) { + this.button = button; + return this; + } + public DownOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } } class MoveOptions { Integer steps; + + public MoveOptions withSteps(Integer steps) { + this.steps = steps; + return this; + } } class UpOptions { enum Button { LEFT, MIDDLE, RIGHT} Button button; Integer clickCount; + + public UpOptions withButton(Button button) { + this.button = button; + return this; + } + public UpOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } } void click(int x, int y, ClickOptions options); void dblclick(int x, int y, DblclickOptions options); diff --git a/lib/src/main/java/com/microsoft/playwright/Page.java b/lib/src/main/java/com/microsoft/playwright/Page.java index 30af1fab..c9b1b969 100644 --- a/lib/src/main/java/com/microsoft/playwright/Page.java +++ b/lib/src/main/java/com/microsoft/playwright/Page.java @@ -19,33 +19,96 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Page { +public interface Page { enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE} class CloseOptions { Boolean runBeforeUnload; + + public CloseOptions withRunBeforeUnload(Boolean runBeforeUnload) { + this.runBeforeUnload = runBeforeUnload; + return this; + } } class AddScriptTagOptions { String url; String path; String content; String type; + + public AddScriptTagOptions withUrl(String url) { + this.url = url; + return this; + } + public AddScriptTagOptions withPath(String path) { + this.path = path; + return this; + } + public AddScriptTagOptions withContent(String content) { + this.content = content; + return this; + } + public AddScriptTagOptions withType(String type) { + this.type = type; + return this; + } } class AddStyleTagOptions { String url; String path; String content; + + public AddStyleTagOptions withUrl(String url) { + this.url = url; + return this; + } + public AddStyleTagOptions withPath(String path) { + this.path = path; + return this; + } + public AddStyleTagOptions withContent(String content) { + this.content = content; + return this; + } } class CheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public CheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public CheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public CheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ClickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public ClickOptions done() { + return ClickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer clickCount; @@ -55,13 +118,61 @@ interface Page { Boolean force; Boolean noWaitAfter; Integer timeout; + + public ClickOptions withButton(Button button) { + this.button = button; + return this; + } + public ClickOptions withClickCount(Integer clickCount) { + this.clickCount = clickCount; + return this; + } + public ClickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public ClickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public ClickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public ClickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public ClickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class DblclickOptions { enum Button { LEFT, MIDDLE, RIGHT} enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public DblclickOptions done() { + return DblclickOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Button button; Integer delay; @@ -70,65 +181,223 @@ interface Page { Boolean force; Boolean noWaitAfter; Integer timeout; + + public DblclickOptions withButton(Button button) { + this.button = button; + return this; + } + public DblclickOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public DblclickOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public DblclickOptions withForce(Boolean force) { + this.force = force; + return this; + } + public DblclickOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public DblclickOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class DispatchEventOptions { Integer timeout; + + public DispatchEventOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class EmulateMediaOptions { enum Media { PRINT, SCREEN} enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} Media media; ColorScheme colorScheme; + + public EmulateMediaOptions withMedia(Media media) { + this.media = media; + return this; + } + public EmulateMediaOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } } class FillOptions { Boolean noWaitAfter; Integer timeout; + + public FillOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public FillOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class FocusOptions { Integer timeout; + + public FocusOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class GetAttributeOptions { Integer timeout; + + public GetAttributeOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class GoBackOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; + + public GoBackOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public GoBackOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class GoForwardOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; + + public GoForwardOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public GoForwardOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class GotoOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; String referer; + + public GotoOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public GotoOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } + public GotoOptions withReferer(String referer) { + this.referer = referer; + return this; + } } class HoverOptions { enum Modifier { ALT, CONTROL, META, SHIFT} - class Position { + public class Position { int x; int y; + + Position() { + } + public HoverOptions done() { + return HoverOptions.this; + } + + public Position withX(int x) { + this.x = x; + return this; + } + public Position withY(int y) { + this.y = y; + return this; + } } Position position; Set modifiers; Boolean force; Integer timeout; + + public Position setPosition() { + this.position = new Position(); + return this.position; + } + public HoverOptions withModifiers(Set modifiers) { + this.modifiers = modifiers; + return this; + } + public HoverOptions withForce(Boolean force) { + this.force = force; + return this; + } + public HoverOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class InnerHTMLOptions { Integer timeout; + + public InnerHTMLOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class InnerTextOptions { Integer timeout; + + public InnerTextOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class PdfOptions { - class Margin { + public class Margin { String top; String right; String bottom; String left; + + Margin() { + } + public PdfOptions done() { + return PdfOptions.this; + } + + public Margin withTop(String top) { + this.top = top; + return this; + } + public Margin withRight(String right) { + this.right = right; + return this; + } + public Margin withBottom(String bottom) { + this.bottom = bottom; + return this; + } + public Margin withLeft(String left) { + this.left = left; + return this; + } } String path; Integer scale; @@ -143,24 +412,122 @@ interface Page { String height; Margin margin; Boolean preferCSSPageSize; + + public PdfOptions withPath(String path) { + this.path = path; + return this; + } + public PdfOptions withScale(Integer scale) { + this.scale = scale; + return this; + } + public PdfOptions withDisplayHeaderFooter(Boolean displayHeaderFooter) { + this.displayHeaderFooter = displayHeaderFooter; + return this; + } + public PdfOptions withHeaderTemplate(String headerTemplate) { + this.headerTemplate = headerTemplate; + return this; + } + public PdfOptions withFooterTemplate(String footerTemplate) { + this.footerTemplate = footerTemplate; + return this; + } + public PdfOptions withPrintBackground(Boolean printBackground) { + this.printBackground = printBackground; + return this; + } + public PdfOptions withLandscape(Boolean landscape) { + this.landscape = landscape; + return this; + } + public PdfOptions withPageRanges(String pageRanges) { + this.pageRanges = pageRanges; + return this; + } + public PdfOptions withFormat(String format) { + this.format = format; + return this; + } + public PdfOptions withWidth(String width) { + this.width = width; + return this; + } + public PdfOptions withHeight(String height) { + this.height = height; + return this; + } + public Margin setMargin() { + this.margin = new Margin(); + return this.margin; + } + public PdfOptions withPreferCSSPageSize(Boolean preferCSSPageSize) { + this.preferCSSPageSize = preferCSSPageSize; + return this; + } } class PressOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public PressOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public PressOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public PressOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class ReloadOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; + + public ReloadOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public ReloadOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class ScreenshotOptions { enum Type { JPEG, PNG} - class Clip { + public class Clip { int x; int y; int width; int height; + + Clip() { + } + public ScreenshotOptions done() { + return ScreenshotOptions.this; + } + + public Clip withX(int x) { + this.x = x; + return this; + } + public Clip withY(int y) { + this.y = y; + return this; + } + public Clip withWidth(int width) { + this.width = width; + return this; + } + public Clip withHeight(int height) { + this.height = height; + return this; + } } String path; Type type; @@ -169,60 +536,202 @@ interface Page { Clip clip; Boolean omitBackground; Integer timeout; + + public ScreenshotOptions withPath(String path) { + this.path = path; + return this; + } + public ScreenshotOptions withType(Type type) { + this.type = type; + return this; + } + public ScreenshotOptions withQuality(Integer quality) { + this.quality = quality; + return this; + } + public ScreenshotOptions withFullPage(Boolean fullPage) { + this.fullPage = fullPage; + return this; + } + public Clip setClip() { + this.clip = new Clip(); + return this.clip; + } + public ScreenshotOptions withOmitBackground(Boolean omitBackground) { + this.omitBackground = omitBackground; + return this; + } + public ScreenshotOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SelectOptionOptions { Boolean noWaitAfter; Integer timeout; + + public SelectOptionOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SelectOptionOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SetContentOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; WaitUntil waitUntil; + + public SetContentOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public SetContentOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class SetInputFilesOptions { Boolean noWaitAfter; Integer timeout; + + public SetInputFilesOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public SetInputFilesOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class SetViewportSizeViewportSize { int width; int height; + + public SetViewportSizeViewportSize withWidth(int width) { + this.width = width; + return this; + } + public SetViewportSizeViewportSize withHeight(int height) { + this.height = height; + return this; + } } class TextContentOptions { Integer timeout; + + public TextContentOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class TypeOptions { Integer delay; Boolean noWaitAfter; Integer timeout; + + public TypeOptions withDelay(Integer delay) { + this.delay = delay; + return this; + } + public TypeOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public TypeOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class UncheckOptions { Boolean force; Boolean noWaitAfter; Integer timeout; + + public UncheckOptions withForce(Boolean force) { + this.force = force; + return this; + } + public UncheckOptions withNoWaitAfter(Boolean noWaitAfter) { + this.noWaitAfter = noWaitAfter; + return this; + } + public UncheckOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForFunctionOptions { double polling; Integer timeout; + + public WaitForFunctionOptions withPolling(double polling) { + this.polling = polling; + return this; + } + public WaitForFunctionOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForLoadStateOptions { Integer timeout; + + public WaitForLoadStateOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForNavigationOptions { enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE} Integer timeout; String url; WaitUntil waitUntil; + + public WaitForNavigationOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + public WaitForNavigationOptions withUrl(String url) { + this.url = url; + return this; + } + public WaitForNavigationOptions withWaitUntil(WaitUntil waitUntil) { + this.waitUntil = waitUntil; + return this; + } } class WaitForRequestOptions { Integer timeout; + + public WaitForRequestOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForResponseOptions { Integer timeout; + + public WaitForResponseOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } class WaitForSelectorOptions { enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE} State state; Integer timeout; + + public WaitForSelectorOptions withState(State state) { + this.state = state; + return this; + } + public WaitForSelectorOptions withTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } } void close(CloseOptions options); ElementHandle querySelector(String selector); diff --git a/lib/src/main/java/com/microsoft/playwright/Request.java b/lib/src/main/java/com/microsoft/playwright/Request.java index 33c387a8..12345d8b 100644 --- a/lib/src/main/java/com/microsoft/playwright/Request.java +++ b/lib/src/main/java/com/microsoft/playwright/Request.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Request { +public interface Request { Object failure(); Frame frame(); Map headers(); diff --git a/lib/src/main/java/com/microsoft/playwright/Response.java b/lib/src/main/java/com/microsoft/playwright/Response.java index f62e2cd9..dfa753c7 100644 --- a/lib/src/main/java/com/microsoft/playwright/Response.java +++ b/lib/src/main/java/com/microsoft/playwright/Response.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Response { +public interface Response { byte[] body(); Error finished(); Frame frame(); diff --git a/lib/src/main/java/com/microsoft/playwright/Route.java b/lib/src/main/java/com/microsoft/playwright/Route.java index 025e459e..fa259b0d 100644 --- a/lib/src/main/java/com/microsoft/playwright/Route.java +++ b/lib/src/main/java/com/microsoft/playwright/Route.java @@ -19,11 +19,24 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Route { +public interface Route { class ContinueOverrides { String method; String postData; Map headers; + + public ContinueOverrides withMethod(String method) { + this.method = method; + return this; + } + public ContinueOverrides withPostData(String postData) { + this.postData = postData; + return this; + } + public ContinueOverrides withHeaders(Map headers) { + this.headers = headers; + return this; + } } class FulfillResponse { Integer status; @@ -31,6 +44,27 @@ interface Route { String contentType; String body; String path; + + public FulfillResponse withStatus(Integer status) { + this.status = status; + return this; + } + public FulfillResponse withHeaders(Map headers) { + this.headers = headers; + return this; + } + public FulfillResponse withContentType(String contentType) { + this.contentType = contentType; + return this; + } + public FulfillResponse withBody(String body) { + this.body = body; + return this; + } + public FulfillResponse withPath(String path) { + this.path = path; + return this; + } } void abort(String errorCode); void continue_(ContinueOverrides overrides); diff --git a/lib/src/main/java/com/microsoft/playwright/Selectors.java b/lib/src/main/java/com/microsoft/playwright/Selectors.java index 62bf96e8..1c00ff0b 100644 --- a/lib/src/main/java/com/microsoft/playwright/Selectors.java +++ b/lib/src/main/java/com/microsoft/playwright/Selectors.java @@ -19,9 +19,14 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Selectors { +public interface Selectors { class RegisterOptions { Boolean contentScript; + + public RegisterOptions withContentScript(Boolean contentScript) { + this.contentScript = contentScript; + return this; + } } void register(String name, String script, RegisterOptions options); } diff --git a/lib/src/main/java/com/microsoft/playwright/TimeoutError.java b/lib/src/main/java/com/microsoft/playwright/TimeoutError.java index 3905400e..602b8c80 100644 --- a/lib/src/main/java/com/microsoft/playwright/TimeoutError.java +++ b/lib/src/main/java/com/microsoft/playwright/TimeoutError.java @@ -19,6 +19,6 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface TimeoutError { +public interface TimeoutError { } diff --git a/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java b/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java index 7a8d3155..20f26af6 100644 --- a/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java +++ b/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java @@ -19,21 +19,70 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface WebKitBrowser { +public interface WebKitBrowser { class NewContextOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewContextOptions done() { + return NewContextOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -57,21 +106,159 @@ interface WebKitBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewContextOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewContextOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewContextOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewContextOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewContextOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewContextOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewContextOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewContextOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewContextOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewContextOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewContextOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewContextOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewContextOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewContextOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewContextOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewContextOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewContextOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewContextOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } class NewPageOptions { enum ColorScheme { DARK, LIGHT, NO_PREFERENCE} - class Geolocation { + public class Geolocation { double latitude; double longitude; double accuracy; + + Geolocation() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public Geolocation withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + public Geolocation withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public Geolocation withAccuracy(double accuracy) { + this.accuracy = accuracy; + return this; + } } - class HttpCredentials { + public class HttpCredentials { String username; String password; + + HttpCredentials() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public HttpCredentials withUsername(String username) { + this.username = username; + return this; + } + public HttpCredentials withPassword(String password) { + this.password = password; + return this; + } } - class VideoSize { + public class VideoSize { int width; int height; + + VideoSize() { + } + public NewPageOptions done() { + return NewPageOptions.this; + } + + public VideoSize withWidth(int width) { + this.width = width; + return this; + } + public VideoSize withHeight(int height) { + this.height = height; + return this; + } } Boolean acceptDownloads; Boolean ignoreHTTPSErrors; @@ -95,6 +282,95 @@ interface WebKitBrowser { Boolean recordVideos; VideoSize videoSize; Boolean recordTrace; + + public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) { + this.acceptDownloads = acceptDownloads; + return this; + } + public NewPageOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) { + this.ignoreHTTPSErrors = ignoreHTTPSErrors; + return this; + } + public NewPageOptions withBypassCSP(Boolean bypassCSP) { + this.bypassCSP = bypassCSP; + return this; + } + public NewPageOptions withViewport(Object viewport) { + this.viewport = viewport; + return this; + } + public NewPageOptions withUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public NewPageOptions withDeviceScaleFactor(Integer deviceScaleFactor) { + this.deviceScaleFactor = deviceScaleFactor; + return this; + } + public NewPageOptions withIsMobile(Boolean isMobile) { + this.isMobile = isMobile; + return this; + } + public NewPageOptions withHasTouch(Boolean hasTouch) { + this.hasTouch = hasTouch; + return this; + } + public NewPageOptions withJavaScriptEnabled(Boolean javaScriptEnabled) { + this.javaScriptEnabled = javaScriptEnabled; + return this; + } + public NewPageOptions withTimezoneId(String timezoneId) { + this.timezoneId = timezoneId; + return this; + } + public Geolocation setGeolocation() { + this.geolocation = new Geolocation(); + return this.geolocation; + } + public NewPageOptions withLocale(String locale) { + this.locale = locale; + return this; + } + public NewPageOptions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + public NewPageOptions withExtraHTTPHeaders(Map extraHTTPHeaders) { + this.extraHTTPHeaders = extraHTTPHeaders; + return this; + } + public NewPageOptions withOffline(Boolean offline) { + this.offline = offline; + return this; + } + public HttpCredentials setHttpCredentials() { + this.httpCredentials = new HttpCredentials(); + return this.httpCredentials; + } + public NewPageOptions withColorScheme(ColorScheme colorScheme) { + this.colorScheme = colorScheme; + return this; + } + public NewPageOptions withLogger(Logger logger) { + this.logger = logger; + return this; + } + public NewPageOptions withRelativeArtifactsPath(String relativeArtifactsPath) { + this.relativeArtifactsPath = relativeArtifactsPath; + return this; + } + public NewPageOptions withRecordVideos(Boolean recordVideos) { + this.recordVideos = recordVideos; + return this; + } + public VideoSize setVideoSize() { + this.videoSize = new VideoSize(); + return this.videoSize; + } + public NewPageOptions withRecordTrace(Boolean recordTrace) { + this.recordTrace = recordTrace; + return this; + } } void close(); List contexts(); diff --git a/lib/src/main/java/com/microsoft/playwright/Worker.java b/lib/src/main/java/com/microsoft/playwright/Worker.java index a97b0dcd..d0d10897 100644 --- a/lib/src/main/java/com/microsoft/playwright/Worker.java +++ b/lib/src/main/java/com/microsoft/playwright/Worker.java @@ -19,7 +19,7 @@ package com.microsoft.playwright; import java.util.*; import java.util.function.BiConsumer; -interface Worker { +public interface Worker { Object evaluate(String pageFunction, Object arg); JSHandle evaluateHandle(String pageFunction, Object arg); String url();