chore: regenerate API from latest api.json (#88)

This commit is contained in:
Yury Semikhatsky 2020-12-04 10:14:51 -08:00 committed by GitHub
parent b5459c048b
commit f360de0a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 658 additions and 507 deletions

View File

@ -674,6 +674,10 @@ class Field extends Element {
output.add(offset + "public " + parentClass + " with" + toTitle(name) + "(int width, int height) {");
output.add(offset + " this." + name + " = new " + type.toJava() + "(width, height);");
output.add(offset + " return this;");
} else if ("Browser.VideoSize".equals(type.toJava()) || "VideoSize".equals(type.toJava())) {
output.add(offset + "public " + parentClass + " with" + toTitle(name) + "(int width, int height) {");
output.add(offset + " this." + name + " = new " + type.toJava() + "(width, height);");
output.add(offset + " return this;");
} else if ("Set<Keyboard.Modifier>".equals(type.toJava())) {
output.add(offset + "public " + parentClass + " with" + toTitle(name) + "(Keyboard.Modifier... modifiers) {");
output.add(offset + " this." + name + " = new HashSet<>(Arrays.asList(modifiers));");
@ -869,6 +873,27 @@ class Interface extends TypeDefinition {
output.add("");
break;
}
case "Browser": {
output.add(offset + "class VideoSize {");
output.add(offset + " private final int width;");
output.add(offset + " private final int height;");
output.add("");
output.add(offset + " public VideoSize(int width, int height) {");
output.add(offset + " this.width = width;");
output.add(offset + " this.height = height;");
output.add(offset + " }");
output.add("");
output.add(offset + " public int width() {");
output.add(offset + " return width;");
output.add(offset + " }");
output.add("");
output.add(offset + " public int height() {");
output.add(offset + " return height;");
output.add(offset + " }");
output.add(offset + "}");
output.add("");
break;
}
case "ElementHandle": {
output.add(offset + "class BoundingBox {");
output.add(offset + " public double x;");
@ -945,6 +970,16 @@ class NestedClass extends TypeDefinition {
final String name;
final List<Field> fields = new ArrayList<>();
private static Set<String> deprecatedOptions = new HashSet<>();
static {
deprecatedOptions.add("Browser.newPage.options.videosPath");
deprecatedOptions.add("Browser.newPage.options.videoSize");
deprecatedOptions.add("Browser.newContext.options.videosPath");
deprecatedOptions.add("Browser.newContext.options.videoSize");
deprecatedOptions.add("BrowserType.launchPersistentContext.options.videosPath");
deprecatedOptions.add("BrowserType.launchPersistentContext.options.videoSize");
}
NestedClass(Element parent, String name, JsonObject jsonElement) {
super(parent, true, jsonElement);
this.name = name;
@ -952,6 +987,9 @@ class NestedClass extends TypeDefinition {
if (jsonElement.has("properties")) {
JsonObject properties = jsonElement.get("properties").getAsJsonObject();
for (Map.Entry<String, JsonElement> m : properties.entrySet()) {
if (deprecatedOptions.contains(jsonPath + "." + m.getKey())) {
continue;
}
fields.add(new Field(this, m.getKey(), m.getValue().getAsJsonObject()));
}
}

View File

@ -108,8 +108,11 @@ class Types {
add("Route.fulfill.response.path", "string", "Path");
add("Route.fulfill.response.status", "number", "int");
add("Browser.newContext.options.recordHar.path", "string", "Path");
add("Browser.newContext.options.recordVideo.dir", "string", "Path");
add("Browser.newPage.options.recordHar.path", "string", "Path");
add("Browser.newPage.options.recordVideo.dir", "string", "Path");
add("BrowserType.launchPersistentContext.options.recordHar.path", "string", "Path");
add("BrowserType.launchPersistentContext.options.recordVideo.dir", "string", "Path");
add("BrowserType.launchPersistentContext.userDataDir", "string", "Path");
add("BrowserType.launchPersistentContext.options.executablePath", "string", "Path");
add("BrowserType.launchServer.options.executablePath", "string", "Path");
@ -131,6 +134,11 @@ class Types {
add("Page.viewportSize", "null|Object", "Viewport", new Empty());
add("BrowserType.launchPersistentContext.options.viewport", "null|Object", "Page.Viewport", new Empty());
// RecordVideo size.
add("Browser.newContext.options.recordVideo.size", "Object", "VideoSize", new Empty());
add("Browser.newPage.options.recordVideo.size", "Object", "VideoSize", new Empty());
add("BrowserType.launchPersistentContext.recordVideo.size", "Object", "Browser.VideoSize", new Empty());
// HTTP credentials.
add("Browser.newContext.options.httpCredentials", "Object", "BrowserContext.HTTPCredentials", new Empty());
add("Browser.newPage.options.httpCredentials", "Object", "BrowserContext.HTTPCredentials", new Empty());
@ -258,7 +266,7 @@ class Types {
add("Page.waitForEvent.optionsOrPredicate", "Function|Object", "WaitForEventOptions");
add("Page.waitForEvent", "Promise<Object>", "Deferred<Event<EventType>>", new Empty());
add("Page.waitForRequest.urlOrPredicate", "string|RegExp|Function", "String");
add("Page.waitForResponse.urlOrPredicate", "string|RegExp|Function", "String");
add("Page.waitForResponse.urlOrPredicate", "string|RegExp|function(Response):boolean", "String");
add("Frame.waitForNavigation.options.url", "string|RegExp|Function", "String");
add("Frame.selectOption.values", "null|string|ElementHandle|Array<string>|Object|Array<ElementHandle>|Array<Object>", "String");
add("Frame.setInputFiles.files", "string|Array<string>|Object|Array<Object>", "String");

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,24 @@ import java.util.*;
* <p>
*/
public interface Browser {
class VideoSize {
private final int width;
private final int height;
public VideoSize(int width, int height) {
this.width = width;
this.height = height;
}
public int width() {
return width;
}
public int height() {
return height;
}
}
enum EventType {
DISCONNECTED,
}
@ -31,6 +49,56 @@ public interface Browser {
void addListener(EventType type, Listener<EventType> listener);
void removeListener(EventType type, Listener<EventType> listener);
class NewContextOptions {
public class RecordHar {
/**
* Optional setting to control whether to omit request content from the HAR. Defaults to {@code false}.
*/
public Boolean omitContent;
/**
* Path on the filesystem to write the HAR file to.
*/
public Path path;
RecordHar() {
}
public NewContextOptions done() {
return NewContextOptions.this;
}
public RecordHar withOmitContent(Boolean omitContent) {
this.omitContent = omitContent;
return this;
}
public RecordHar withPath(Path path) {
this.path = path;
return this;
}
}
public class RecordVideo {
/**
* Path to the directory to put videos into.
*/
public Path dir;
/**
* Optional dimensions of the recorded videos. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
*/
public VideoSize size;
RecordVideo() {
}
public NewContextOptions done() {
return NewContextOptions.this;
}
public RecordVideo withDir(Path dir) {
this.dir = dir;
return this;
}
public RecordVideo withSize(int width, int height) {
this.size = new VideoSize(width, height);
return this;
}
}
public class Proxy {
/**
* Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example {@code http://myproxy.com:3128} or {@code socks5://myproxy.com:3128}. Short form {@code myproxy.com:3128} is considered an HTTP proxy.
@ -72,320 +140,28 @@ public interface Browser {
return this;
}
}
public class VideoSize {
public class StorageState {
/**
* Video frame width.
* Optional cookies to set for context
*/
public int width;
public List<Object> cookies;
/**
* Video frame height.
* Optional localStorage to set for context
*/
public int height;
public List<Object> origins;
VideoSize() {
StorageState() {
}
public NewContextOptions done() {
return NewContextOptions.this;
}
public VideoSize withWidth(int width) {
this.width = width;
public StorageState withCookies(List<Object> cookies) {
this.cookies = cookies;
return this;
}
public VideoSize withHeight(int height) {
this.height = height;
return this;
}
}
public class RecordHar {
/**
* Optional setting to control whether to omit request content from the HAR. Defaults to {@code false}.
*/
public Boolean omitContent;
/**
* Path on the filesystem to write the HAR file to.
*/
public Path path;
RecordHar() {
}
public NewContextOptions done() {
return NewContextOptions.this;
}
public RecordHar withOmitContent(Boolean omitContent) {
this.omitContent = omitContent;
return this;
}
public RecordHar withPath(Path path) {
this.path = path;
return this;
}
}
/**
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
*/
public Boolean acceptDownloads;
/**
* Whether to ignore HTTPS errors during navigation. Defaults to {@code false}.
*/
public Boolean ignoreHTTPSErrors;
/**
* Toggles bypassing page's Content-Security-Policy.
*/
public Boolean bypassCSP;
/**
* Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport.
*/
public Page.Viewport viewport;
/**
* Specific user agent to use in this context.
*/
public String userAgent;
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public Integer deviceScaleFactor;
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not supported in Firefox.
*/
public Boolean isMobile;
/**
* Specifies if viewport supports touch events. Defaults to false.
*/
public Boolean hasTouch;
/**
* Whether or not to enable JavaScript in the context. Defaults to true.
*/
public Boolean javaScriptEnabled;
/**
* Changes the timezone of the context. See ICUs {@code metaZones.txt} for a list of supported timezone IDs.
*/
public String timezoneId;
public Geolocation geolocation;
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value, {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public String locale;
/**
* A list of permissions to grant to all pages in this context. See browserContext.grantPermissions for more details.
*/
public List<String> permissions;
/**
* An object containing additional HTTP headers to be sent with every request. All header values must be strings.
*/
public Map<String, String> extraHTTPHeaders;
/**
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public Boolean offline;
/**
* Credentials for HTTP authentication.
*/
public BrowserContext.HTTPCredentials httpCredentials;
/**
* Emulates {@code 'prefers-colors-scheme'} media feature, supported values are {@code 'light'}, {@code 'dark'}, {@code 'no-preference'}. See page.emulateMedia(options) for more details. Defaults to '{@code light}'.
*/
public ColorScheme colorScheme;
/**
* Logger sink for Playwright logging.
*/
public Logger logger;
/**
* Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server: 'per-context' } })}.
*/
public Proxy proxy;
/**
* Enables video recording for all pages to {@code videosPath} folder. If not specified, videos are not recorded. Make sure to await {@code browserContext.close} for videos to be saved.
*/
public String videosPath;
/**
* Specifies dimensions of the automatically recorded video. Can only be used if {@code videosPath} is set. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
*/
public VideoSize videoSize;
/**
* Enables HAR recording for all pages into {@code har.path} file. If not specified, the HAR is not recorded. Make sure to await {@code browserContext.close} for the HAR to be saved.
*/
public RecordHar recordHar;
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(int width, int height) {
this.viewport = new Page.Viewport(width, height);
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 NewContextOptions withGeolocation(Geolocation geolocation) {
this.geolocation = geolocation;
return this;
}
public NewContextOptions withLocale(String locale) {
this.locale = locale;
return this;
}
public NewContextOptions withPermissions(List<String> permissions) {
this.permissions = permissions;
return this;
}
public NewContextOptions withExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
return this;
}
public NewContextOptions withOffline(Boolean offline) {
this.offline = offline;
return this;
}
public NewContextOptions withHttpCredentials(String username, String password) {
this.httpCredentials = new BrowserContext.HTTPCredentials(username, password);
return this;
}
public NewContextOptions withColorScheme(ColorScheme colorScheme) {
this.colorScheme = colorScheme;
return this;
}
public NewContextOptions withLogger(Logger logger) {
this.logger = logger;
return this;
}
public Proxy setProxy() {
this.proxy = new Proxy();
return this.proxy;
}
public NewContextOptions withVideosPath(String videosPath) {
this.videosPath = videosPath;
return this;
}
public VideoSize setVideoSize() {
this.videoSize = new VideoSize();
return this.videoSize;
}
public RecordHar setRecordHar() {
this.recordHar = new RecordHar();
return this.recordHar;
}
}
class NewPageOptions {
public class Proxy {
/**
* Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example {@code http://myproxy.com:3128} or {@code socks5://myproxy.com:3128}. Short form {@code myproxy.com:3128} is considered an HTTP proxy.
*/
public String server;
/**
* Optional coma-separated domains to bypass proxy, for example {@code ".com, chromium.org, .domain.com"}.
*/
public String bypass;
/**
* Optional username to use if HTTP proxy requires authentication.
*/
public String username;
/**
* Optional password to use if HTTP proxy requires authentication.
*/
public String password;
Proxy() {
}
public NewPageOptions done() {
return NewPageOptions.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;
}
}
public class VideoSize {
/**
* Video frame width.
*/
public int width;
/**
* Video frame height.
*/
public 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;
}
}
public class RecordHar {
/**
* Optional setting to control whether to omit request content from the HAR. Defaults to {@code false}.
*/
public Boolean omitContent;
/**
* Path on the filesystem to write the HAR file to.
*/
public Path path;
RecordHar() {
}
public NewPageOptions done() {
return NewPageOptions.this;
}
public RecordHar withOmitContent(Boolean omitContent) {
this.omitContent = omitContent;
return this;
}
public RecordHar withPath(Path path) {
this.path = path;
public StorageState withOrigins(List<Object> origins) {
this.origins = origins;
return this;
}
}
@ -458,22 +234,314 @@ public interface Browser {
* Logger sink for Playwright logging.
*/
public Logger logger;
/**
* Enables HAR recording for all pages into {@code recordHar.path} file. If not specified, the HAR is not recorded. Make sure to await {@code browserContext.close} for the HAR to be saved.
*/
public RecordHar recordHar;
/**
* Enables video recording for all pages into {@code recordVideo.dir} directory. If not specified videos are not recorded. Make sure to await {@code browserContext.close} for videos to be saved.
*/
public RecordVideo recordVideo;
/**
* Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server: 'per-context' } })}.
*/
public Proxy proxy;
/**
* Enables video recording for all pages to {@code videosPath} folder. If not specified, videos are not recorded. Make sure to await {@code page.close} for videos to be saved.
* Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
*/
public String videosPath;
public StorageState storageState;
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(int width, int height) {
this.viewport = new Page.Viewport(width, height);
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 NewContextOptions withGeolocation(Geolocation geolocation) {
this.geolocation = geolocation;
return this;
}
public NewContextOptions withLocale(String locale) {
this.locale = locale;
return this;
}
public NewContextOptions withPermissions(List<String> permissions) {
this.permissions = permissions;
return this;
}
public NewContextOptions withExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
return this;
}
public NewContextOptions withOffline(Boolean offline) {
this.offline = offline;
return this;
}
public NewContextOptions withHttpCredentials(String username, String password) {
this.httpCredentials = new BrowserContext.HTTPCredentials(username, password);
return this;
}
public NewContextOptions withColorScheme(ColorScheme colorScheme) {
this.colorScheme = colorScheme;
return this;
}
public NewContextOptions withLogger(Logger logger) {
this.logger = logger;
return this;
}
public RecordHar setRecordHar() {
this.recordHar = new RecordHar();
return this.recordHar;
}
public RecordVideo setRecordVideo() {
this.recordVideo = new RecordVideo();
return this.recordVideo;
}
public Proxy setProxy() {
this.proxy = new Proxy();
return this.proxy;
}
public StorageState setStorageState() {
this.storageState = new StorageState();
return this.storageState;
}
}
class NewPageOptions {
public class RecordHar {
/**
* Specifies dimensions of the automatically recorded video. Can only be used if {@code videosPath} is set. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
* Optional setting to control whether to omit request content from the HAR. Defaults to {@code false}.
*/
public VideoSize videoSize;
public Boolean omitContent;
/**
* Enables HAR recording for all pages into {@code har.path} file. If not specified, the HAR is not recorded. Make sure to await {@code page.close} for the HAR to be saved.
* Path on the filesystem to write the HAR file to.
*/
public Path path;
RecordHar() {
}
public NewPageOptions done() {
return NewPageOptions.this;
}
public RecordHar withOmitContent(Boolean omitContent) {
this.omitContent = omitContent;
return this;
}
public RecordHar withPath(Path path) {
this.path = path;
return this;
}
}
public class RecordVideo {
/**
* Path to the directory to put videos into.
*/
public Path dir;
/**
* Optional dimensions of the recorded videos. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
*/
public VideoSize size;
RecordVideo() {
}
public NewPageOptions done() {
return NewPageOptions.this;
}
public RecordVideo withDir(Path dir) {
this.dir = dir;
return this;
}
public RecordVideo withSize(int width, int height) {
this.size = new VideoSize(width, height);
return this;
}
}
public class Proxy {
/**
* Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example {@code http://myproxy.com:3128} or {@code socks5://myproxy.com:3128}. Short form {@code myproxy.com:3128} is considered an HTTP proxy.
*/
public String server;
/**
* Optional coma-separated domains to bypass proxy, for example {@code ".com, chromium.org, .domain.com"}.
*/
public String bypass;
/**
* Optional username to use if HTTP proxy requires authentication.
*/
public String username;
/**
* Optional password to use if HTTP proxy requires authentication.
*/
public String password;
Proxy() {
}
public NewPageOptions done() {
return NewPageOptions.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;
}
}
public class StorageState {
/**
* Optional cookies to set for context
*/
public List<Object> cookies;
/**
* Optional localStorage to set for context
*/
public List<Object> origins;
StorageState() {
}
public NewPageOptions done() {
return NewPageOptions.this;
}
public StorageState withCookies(List<Object> cookies) {
this.cookies = cookies;
return this;
}
public StorageState withOrigins(List<Object> origins) {
this.origins = origins;
return this;
}
}
/**
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
*/
public Boolean acceptDownloads;
/**
* Whether to ignore HTTPS errors during navigation. Defaults to {@code false}.
*/
public Boolean ignoreHTTPSErrors;
/**
* Toggles bypassing page's Content-Security-Policy.
*/
public Boolean bypassCSP;
/**
* Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. {@code null} disables the default viewport.
*/
public Page.Viewport viewport;
/**
* Specific user agent to use in this context.
*/
public String userAgent;
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public Integer deviceScaleFactor;
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not supported in Firefox.
*/
public Boolean isMobile;
/**
* Specifies if viewport supports touch events. Defaults to false.
*/
public Boolean hasTouch;
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public Boolean javaScriptEnabled;
/**
* Changes the timezone of the context. See ICUs {@code metaZones.txt} for a list of supported timezone IDs.
*/
public String timezoneId;
public Geolocation geolocation;
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value, {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public String locale;
/**
* A list of permissions to grant to all pages in this context. See browserContext.grantPermissions for more details.
*/
public List<String> permissions;
/**
* An object containing additional HTTP headers to be sent with every request. All header values must be strings.
*/
public Map<String, String> extraHTTPHeaders;
/**
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public Boolean offline;
/**
* Credentials for HTTP authentication.
*/
public BrowserContext.HTTPCredentials httpCredentials;
/**
* Emulates {@code 'prefers-colors-scheme'} media feature, supported values are {@code 'light'}, {@code 'dark'}, {@code 'no-preference'}. See page.emulateMedia(options) for more details. Defaults to '{@code light}'.
*/
public ColorScheme colorScheme;
/**
* Logger sink for Playwright logging.
*/
public Logger logger;
/**
* Enables HAR recording for all pages into {@code recordHar.path} file. If not specified, the HAR is not recorded. Make sure to await {@code browserContext.close} for the HAR to be saved.
*/
public RecordHar recordHar;
/**
* Enables video recording for all pages into {@code recordVideo.dir} directory. If not specified videos are not recorded. Make sure to await {@code browserContext.close} for videos to be saved.
*/
public RecordVideo recordVideo;
/**
* Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server: 'per-context' } })}.
*/
public Proxy proxy;
/**
* Populates context with given storage state. This method can be used to initialize context with logged-in information obtained via browserContext.storageState().
*/
public StorageState storageState;
public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) {
this.acceptDownloads = acceptDownloads;
@ -547,21 +615,21 @@ public interface Browser {
this.logger = logger;
return this;
}
public RecordHar setRecordHar() {
this.recordHar = new RecordHar();
return this.recordHar;
}
public RecordVideo setRecordVideo() {
this.recordVideo = new RecordVideo();
return this.recordVideo;
}
public Proxy setProxy() {
this.proxy = new Proxy();
return this.proxy;
}
public NewPageOptions withVideosPath(String videosPath) {
this.videosPath = videosPath;
return this;
}
public VideoSize setVideoSize() {
this.videoSize = new VideoSize();
return this.videoSize;
}
public RecordHar setRecordHar() {
this.recordHar = new RecordHar();
return this.recordHar;
public StorageState setStorageState() {
this.storageState = new StorageState();
return this.storageState;
}
}
/**

View File

@ -378,6 +378,10 @@ public interface BrowserContext {
* @param offline Whether to emulate network being offline for the browser context.
*/
void setOffline(boolean offline);
/**
* Returns storage state for this browser context, contains current cookies and local storage snapshot.
*/
Object storageState();
default void unroute(String url) { unroute(url, null); }
default void unroute(Pattern url) { unroute(url, null); }
default void unroute(Predicate<String> url) { unroute(url, null); }

View File

@ -89,7 +89,7 @@ public interface BrowserType {
*/
public Proxy proxy;
/**
* If specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed.
*/
public Path downloadsPath;
/**
@ -240,34 +240,9 @@ public interface BrowserType {
return this;
}
}
public class VideoSize {
/**
* Video frame width.
*/
public int width;
/**
* Video frame height.
*/
public 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;
}
}
public class RecordHar {
/**
* Optional setting to control whether to omit request content from the HAR. Defaults to false.
* Optional setting to control whether to omit request content from the HAR. Defaults to {@code false}.
*/
public Boolean omitContent;
/**
@ -290,6 +265,56 @@ public interface BrowserType {
return this;
}
}
public class RecordVideo {
public class Size {
/**
* Video frame width.
*/
public int width;
/**
* Video frame height.
*/
public int height;
Size() {
}
public RecordVideo done() {
return RecordVideo.this;
}
public Size withWidth(int width) {
this.width = width;
return this;
}
public Size withHeight(int height) {
this.height = height;
return this;
}
}
/**
* Path to the directory to put videos into.
*/
public Path dir;
/**
* Optional dimensions of the recorded videos. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of each page will be scaled down if necessary to fit the specified size.
*/
public Size size;
RecordVideo() {
}
public LaunchPersistentContextOptions done() {
return LaunchPersistentContextOptions.this;
}
public RecordVideo withDir(Path dir) {
this.dir = dir;
return this;
}
public Size setSize() {
this.size = new Size();
return this.size;
}
}
/**
* Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to {@code true} unless the {@code devtools} option is {@code true}.
*/
@ -311,11 +336,7 @@ public interface BrowserType {
*/
public Proxy proxy;
/**
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
*/
public Boolean acceptDownloads;
/**
* If specified, accepted downloads are downloaded into this folder. Otherwise, temporary folder is created and is deleted when browser is closed.
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed.
*/
public Path downloadsPath;
/**
@ -334,10 +355,6 @@ public interface BrowserType {
* Close the browser process on SIGHUP. Defaults to {@code true}.
*/
public Boolean handleSIGHUP;
/**
* Logger sink for Playwright logging.
*/
public Logger logger;
/**
* Maximum time in milliseconds to wait for the browser instance to start. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
*/
@ -354,6 +371,10 @@ public interface BrowserType {
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0.
*/
public Integer slowMo;
/**
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
*/
public Boolean acceptDownloads;
/**
* Whether to ignore HTTPS errors during navigation. Defaults to {@code false}.
*/
@ -383,7 +404,7 @@ public interface BrowserType {
*/
public Boolean hasTouch;
/**
* Whether or not to enable JavaScript in the context. Defaults to true.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public Boolean javaScriptEnabled;
/**
@ -416,17 +437,17 @@ public interface BrowserType {
*/
public ColorScheme colorScheme;
/**
* Enables video recording for all pages to {@code videosPath} folder. If not specified, videos are not recorded. Make sure to await {@code browserContext.close} for videos to be saved.
* Logger sink for Playwright logging.
*/
public String videosPath;
public Logger logger;
/**
* Specifies dimensions of the automatically recorded video. Can only be used if {@code videosPath} is set. If not specified the size will be equal to {@code viewport}. If {@code viewport} is not configured explicitly the video size defaults to 1280x720. Actual picture of the page will be scaled down if necessary to fit specified size.
*/
public VideoSize videoSize;
/**
* Enables HAR recording for all the pages into {@code har.path} file. If not specified, HAR is not recorded. Make sure to await {@code page.close} for HAR to be saved.
* Enables HAR recording for all pages into {@code recordHar.path} file. If not specified, the HAR is not recorded. Make sure to await {@code browserContext.close} for the HAR to be saved.
*/
public RecordHar recordHar;
/**
* Enables video recording for all pages into {@code recordVideo.dir} directory. If not specified videos are not recorded. Make sure to await {@code browserContext.close} for videos to be saved.
*/
public RecordVideo recordVideo;
public LaunchPersistentContextOptions withHeadless(Boolean headless) {
this.headless = headless;
@ -448,10 +469,6 @@ public interface BrowserType {
this.proxy = new Proxy();
return this.proxy;
}
public LaunchPersistentContextOptions withAcceptDownloads(Boolean acceptDownloads) {
this.acceptDownloads = acceptDownloads;
return this;
}
public LaunchPersistentContextOptions withDownloadsPath(Path downloadsPath) {
this.downloadsPath = downloadsPath;
return this;
@ -472,10 +489,6 @@ public interface BrowserType {
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;
@ -492,6 +505,10 @@ public interface BrowserType {
this.slowMo = slowMo;
return this;
}
public LaunchPersistentContextOptions withAcceptDownloads(Boolean acceptDownloads) {
this.acceptDownloads = acceptDownloads;
return this;
}
public LaunchPersistentContextOptions withIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) {
this.ignoreHTTPSErrors = ignoreHTTPSErrors;
return this;
@ -556,18 +573,18 @@ public interface BrowserType {
this.colorScheme = colorScheme;
return this;
}
public LaunchPersistentContextOptions withVideosPath(String videosPath) {
this.videosPath = videosPath;
public LaunchPersistentContextOptions withLogger(Logger logger) {
this.logger = logger;
return this;
}
public VideoSize setVideoSize() {
this.videoSize = new VideoSize();
return this.videoSize;
}
public RecordHar setRecordHar() {
this.recordHar = new RecordHar();
return this.recordHar;
}
public RecordVideo setRecordVideo() {
this.recordVideo = new RecordVideo();
return this.recordVideo;
}
}
/**
*

View File

@ -95,11 +95,11 @@ public interface ElementHandle extends JSHandle {
*/
public Integer delay;
/**
* A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -161,11 +161,11 @@ public interface ElementHandle extends JSHandle {
*/
public Integer delay;
/**
* A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -234,11 +234,11 @@ public interface ElementHandle extends JSHandle {
}
class HoverOptions {
/**
* A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -422,11 +422,11 @@ public interface ElementHandle extends JSHandle {
}
}
/**
* A point to tap relative to the top-left corner of element padding box. If not specified, taps some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -554,12 +554,12 @@ public interface ElementHandle extends JSHandle {
}
/**
* The method finds an element matching the specified selector in the {@code ElementHandle}'s subtree. See Working with selectors for more details. If no elements match the selector, the return value resolves to {@code null}.
* @param selector A selector to query element for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
*/
ElementHandle querySelector(String selector);
/**
* The method finds all elements matching the specified selector in the {@code ElementHandle}s subtree. See Working with selectors for more details. If no elements match the selector, the return value resolves to {@code []}.
* @param selector A selector to query element for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
*/
List<ElementHandle> querySelectorAll(String selector);
default Object evalOnSelector(String selector, String pageFunction) {
@ -573,7 +573,7 @@ public interface ElementHandle extends JSHandle {
* Examples:
* <p>
*
* @param selector A selector to query element for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
@ -590,14 +590,21 @@ public interface ElementHandle extends JSHandle {
* Examples:
* <p>
*
* @param selector A selector to query element for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
*/
Object evalOnSelectorAll(String selector, String pageFunction, Object arg);
/**
* This method returns the bounding box of the element (relative to the main frame), or {@code null} if the element is not visible.
* This method returns the bounding box of the element, or {@code null} if the element is not visible. The bounding box is calculated relative to the main frame viewport - which is usually the same as the browser window.
* <p>
* Scrolling affects the returned bonding box, similarly to Element.getBoundingClientRect. That means {@code x} and/or {@code y} may be negative.
* <p>
* Elements from child frames return the bounding box relative to the main frame, unlike the Element.getBoundingClientRect.
* <p>
* Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following snippet should click the center of the element.
* <p>
*/
BoundingBox boundingBox();
default void check() {
@ -958,7 +965,7 @@ public interface ElementHandle extends JSHandle {
*
* <p>
* <strong>NOTE</strong> This method does not work across navigations, use page.waitForSelector(selector[, options]) instead.
* @param selector A selector of an element to wait for, relative to the element handle. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @return Promise that resolves when element specified by selector satisfies {@code state} option. Resolves to {@code null} if waiting for {@code hidden} or {@code detached}.
*/
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);

View File

@ -138,11 +138,11 @@ public interface Frame {
*/
public Integer delay;
/**
* A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -204,11 +204,11 @@ public interface Frame {
*/
public Integer delay;
/**
* A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -310,14 +310,14 @@ public interface Frame {
}
class NavigateOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public LoadState waitUntil;
/**
@ -340,11 +340,11 @@ public interface Frame {
}
class HoverOptions {
/**
* A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -446,14 +446,14 @@ public interface Frame {
}
class SetContentOptions {
/**
* Maximum time in milliseconds for resources to load, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider setting content to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider setting content to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider setting content to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public LoadState waitUntil;
@ -506,11 +506,11 @@ public interface Frame {
}
}
/**
* A point to tap relative to the top-left corner of element padding box. If not specified, taps some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -618,7 +618,7 @@ public interface Frame {
*/
public Integer pollingInterval;
/**
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout(timeout).
*/
public Integer timeout;
@ -637,7 +637,7 @@ public interface Frame {
}
class WaitForLoadStateOptions {
/**
* Maximum waiting time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
@ -648,7 +648,7 @@ public interface Frame {
}
class WaitForNavigationOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
@ -658,10 +658,10 @@ public interface Frame {
public Pattern pattern;
public Predicate<String> predicate;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public LoadState waitUntil;
@ -712,13 +712,13 @@ public interface Frame {
}
/**
* The method finds an element matching the specified selector within the frame. See Working with selectors for more details. If no elements match the selector, the return value resolves to {@code null}.
* @param selector A selector to query frame for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @return Promise which resolves to ElementHandle pointing to the frame element.
*/
ElementHandle querySelector(String selector);
/**
* The method finds all elements matching the specified selector within the frame. See Working with selectors for more details. If no elements match the selector, the return value resolves to {@code []}.
* @param selector A selector to query frame for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @return Promise which resolves to ElementHandles pointing to the frame elements.
*/
List<ElementHandle> querySelectorAll(String selector);
@ -733,7 +733,7 @@ public interface Frame {
* Examples:
* <p>
*
* @param selector A selector to query frame for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
@ -750,7 +750,7 @@ public interface Frame {
* Examples:
* <p>
*
* @param selector A selector to query frame for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
@ -787,7 +787,7 @@ public interface Frame {
* Ensure that the element is now checked. If not, this method rejects.
* <p>
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* @param selector A selector to search for checkbox to check. If there are multiple elements satisfying the selector, the first will be checked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully checked.
*/
void check(String selector, CheckOptions options);
@ -809,7 +809,7 @@ public interface Frame {
* Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.
* <p>
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* @param selector A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully clicked.
*/
void click(String selector, ClickOptions options);
@ -836,7 +836,7 @@ public interface Frame {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* <strong>NOTE</strong> {@code frame.dblclick()} dispatches two {@code click} events and a single {@code dblclick} event.
* @param selector A selector to search for element to double click. If there are multiple elements satisfying the selector, the first will be double clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully double clicked.
*/
void dblclick(String selector, DblclickOptions options);
@ -870,7 +870,7 @@ public interface Frame {
* You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event:
* <p>
*
* @param selector A selector to search for element to use. If there are multiple elements satisfying the selector, the first will be double clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param type DOM event type: {@code "click"}, {@code "dragstart"}, etc.
* @param eventInit event-specific initialization properties.
*/
@ -922,7 +922,7 @@ public interface Frame {
* Note that you can pass an empty string to clear the input field.
* <p>
* To send fine-grained keyboard events, use {@code frame.type}.
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param value Value to fill for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
*/
void fill(String selector, String value, FillOptions options);
@ -933,7 +933,7 @@ public interface Frame {
* This method fetches an element with {@code selector} and focuses it.
* <p>
* If there's no element matching {@code selector}, the method waits until a matching element appears in the DOM.
* @param selector A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise which resolves when the element matching {@code selector} is successfully focused. The promise will be rejected if there is no element matching {@code selector}.
*/
void focus(String selector, FocusOptions options);
@ -951,7 +951,7 @@ public interface Frame {
}
/**
* Returns element attribute value.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param name Attribute name to get the value for.
*/
String getAttribute(String selector, String name, GetAttributeOptions options);
@ -1000,7 +1000,7 @@ public interface Frame {
* Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.
* <p>
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* @param selector A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully hovered.
*/
void hover(String selector, HoverOptions options);
@ -1009,7 +1009,7 @@ public interface Frame {
}
/**
* Resolves to the {@code element.innerHTML}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String innerHTML(String selector, InnerHTMLOptions options);
default String innerText(String selector) {
@ -1017,7 +1017,7 @@ public interface Frame {
}
/**
* Resolves to the {@code element.innerText}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String innerText(String selector, InnerTextOptions options);
/**
@ -1056,7 +1056,7 @@ public interface Frame {
* If {@code key} is a single character, it is case-sensitive, so the values {@code a} and {@code A} will generate different respective texts.
* <p>
* Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
* @param selector A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
*/
void press(String selector, String key, PressOptions options);
@ -1104,7 +1104,7 @@ public interface Frame {
* If there's no {@code <select>} element matching {@code selector}, the method throws an error.
* <p>
*
* @param selector A selector to query frame for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param values Options to select. If the {@code <select>} has the {@code multiple} attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to {@code {value:'string'}}. Option is considered matching if all specified properties match.
* @return An array of option values that have been successfully selected.
*/
@ -1129,7 +1129,7 @@ public interface Frame {
* This method expects {@code selector} to point to an input element.
* <p>
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.
* @param selector A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
void setInputFiles(String selector, FileChooser.FilePayload[] files, SetInputFilesOptions options);
default void tap(String selector) {
@ -1151,7 +1151,7 @@ public interface Frame {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* <strong>NOTE</strong> {@code frame.tap()} requires that the {@code hasTouch} option of the browser context be set to true.
* @param selector A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully tapped.
*/
void tap(String selector, TapOptions options);
@ -1160,7 +1160,7 @@ public interface Frame {
}
/**
* Resolves to the {@code element.textContent}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String textContent(String selector, TextContentOptions options);
/**
@ -1177,7 +1177,7 @@ public interface Frame {
* To press a special key, like {@code Control} or {@code ArrowDown}, use {@code keyboard.press}.
* <p>
*
* @param selector A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param text A text to type into a focused element.
*/
void type(String selector, String text, TypeOptions options);
@ -1202,7 +1202,7 @@ public interface Frame {
* Ensure that the element is now unchecked. If not, this method rejects.
* <p>
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* @param selector A selector to search for uncheckbox to check. If there are multiple elements satisfying the selector, the first will be checked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully unchecked.
*/
void uncheck(String selector, UncheckOptions options);
@ -1267,7 +1267,7 @@ public interface Frame {
* This method works across navigations:
* <p>
*
* @param selector A selector of an element to wait for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @return Promise which resolves when element specified by selector satisfies {@code state} option. Resolves to {@code null} if waiting for {@code hidden} or {@code detached}.
*/
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);

View File

@ -210,11 +210,11 @@ public interface Page {
*/
public Integer delay;
/**
* A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -289,11 +289,11 @@ public interface Page {
*/
public Integer delay;
/**
* A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -426,14 +426,14 @@ public interface Page {
}
class GoBackOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
@ -448,14 +448,14 @@ public interface Page {
}
class GoForwardOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
@ -470,14 +470,14 @@ public interface Page {
}
class NavigateOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
/**
@ -500,11 +500,11 @@ public interface Page {
}
class HoverOptions {
/**
* A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -740,14 +740,14 @@ public interface Page {
}
class ReloadOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
@ -882,14 +882,14 @@ public interface Page {
}
class SetContentOptions {
/**
* Maximum time in milliseconds for resources to load, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
* When to consider setting markup succeeded, defaults to {@code load}. Given an array of event strings, setting content is considered to be successful after all events have been fired. Events can be either:
* - {@code 'load'} - consider setting content to be finished when the {@code load} event is fired.
* - {@code 'domcontentloaded'} - consider setting content to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'networkidle'} - consider setting content to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
@ -942,11 +942,11 @@ public interface Page {
}
}
/**
* A point to tap relative to the top-left corner of element padding box. If not specified, taps some visible point of the element.
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
*/
public Position position;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
*/
public Set<Keyboard.Modifier> modifiers;
/**
@ -1054,7 +1054,7 @@ public interface Page {
*/
public Integer pollingInterval;
/**
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default value can be changed by using the page.setDefaultTimeout(timeout) method.
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultTimeout(timeout).
*/
public Integer timeout;
@ -1073,7 +1073,7 @@ public interface Page {
}
class WaitForLoadStateOptions {
/**
* Maximum waiting time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
@ -1084,7 +1084,7 @@ public interface Page {
}
class WaitForNavigationOptions {
/**
* Maximum navigation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout), browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
*/
public Integer timeout;
/**
@ -1094,10 +1094,10 @@ public interface Page {
public Pattern pattern;
public Predicate<String> predicate;
/**
* When to consider navigation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider navigation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider navigation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider navigation to be finished when there are no network connections for at least {@code 500} ms.
* When to consider operation succeeded, defaults to {@code load}. Events can be either:
* - {@code 'domcontentloaded'} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.
* - {@code 'load'} - consider operation to be finished when the {@code load} event is fired.
* - {@code 'networkidle'} - consider operation to be finished when there are no network connections for at least {@code 500} ms.
*/
public Frame.LoadState waitUntil;
@ -1172,14 +1172,14 @@ public interface Page {
* The method finds an element matching the specified selector within the page. If no elements match the selector, the return value resolves to {@code null}.
* <p>
* Shortcut for page.mainFrame().$(selector).
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
*/
ElementHandle querySelector(String selector);
/**
* The method finds all elements matching the specified selector within the page. If no elements match the selector, the return value resolves to {@code []}.
* <p>
* Shortcut for page.mainFrame().$$(selector).
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
*/
List<ElementHandle> querySelectorAll(String selector);
default Object evalOnSelector(String selector, String pageFunction) {
@ -1193,7 +1193,7 @@ public interface Page {
* Examples:
* <p>
* Shortcut for page.mainFrame().$eval(selector, pageFunction).
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
@ -1210,7 +1210,7 @@ public interface Page {
* Examples:
* <p>
*
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @param pageFunction Function to be evaluated in browser context
* @param arg Optional argument to pass to {@code pageFunction}
* @return Promise which resolves to the return value of {@code pageFunction}
@ -1274,7 +1274,7 @@ public interface Page {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* Shortcut for page.mainFrame().check(selector[, options]).
* @param selector A selector to search for checkbox or radio button to check. If there are multiple elements satisfying the selector, the first will be checked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully checked.
*/
void check(String selector, CheckOptions options);
@ -1297,7 +1297,7 @@ public interface Page {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* Shortcut for page.mainFrame().click(selector[, options]).
* @param selector A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully clicked.
*/
void click(String selector, ClickOptions options);
@ -1345,7 +1345,7 @@ public interface Page {
* <strong>NOTE</strong> {@code page.dblclick()} dispatches two {@code click} events and a single {@code dblclick} event.
* <p>
* Shortcut for page.mainFrame().dblclick(selector[, options]).
* @param selector A selector to search for element to double click. If there are multiple elements satisfying the selector, the first will be double clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully double clicked.
*/
void dblclick(String selector, DblclickOptions options);
@ -1379,7 +1379,7 @@ public interface Page {
* You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event:
* <p>
*
* @param selector A selector to search for element to use. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param type DOM event type: {@code "click"}, {@code "dragstart"}, etc.
* @param eventInit event-specific initialization properties.
*/
@ -1479,7 +1479,7 @@ public interface Page {
* To send fine-grained keyboard events, use {@code page.type}.
* <p>
* Shortcut for page.mainFrame().fill()
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param value Value to fill for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
*/
void fill(String selector, String value, FillOptions options);
@ -1492,7 +1492,7 @@ public interface Page {
* If there's no element matching {@code selector}, the method waits until a matching element appears in the DOM.
* <p>
* Shortcut for page.mainFrame().focus(selector).
* @param selector A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise which resolves when the element matching {@code selector} is successfully focused. The promise will be rejected if there is no element matching {@code selector}.
*/
void focus(String selector, FocusOptions options);
@ -1516,7 +1516,7 @@ public interface Page {
}
/**
* Returns element attribute value.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param name Attribute name to get the value for.
*/
String getAttribute(String selector, String name, GetAttributeOptions options);
@ -1589,7 +1589,7 @@ public interface Page {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* Shortcut for page.mainFrame().hover(selector[, options]).
* @param selector A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully hovered.
*/
void hover(String selector, HoverOptions options);
@ -1598,7 +1598,7 @@ public interface Page {
}
/**
* Resolves to the {@code element.innerHTML}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String innerHTML(String selector, InnerHTMLOptions options);
default String innerText(String selector) {
@ -1606,7 +1606,7 @@ public interface Page {
}
/**
* Resolves to the {@code element.innerText}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String innerText(String selector, InnerTextOptions options);
/**
@ -1709,7 +1709,7 @@ public interface Page {
* Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
* <p>
*
* @param selector A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
*/
void press(String selector, String key, PressOptions options);
@ -1794,7 +1794,7 @@ public interface Page {
* If there's no {@code <select>} element matching {@code selector}, the method throws an error.
* <p>
* Shortcut for page.mainFrame().selectOption()
* @param selector A selector to query page for. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param values Options to select. If the {@code <select>} has the {@code multiple} attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to {@code {value:'string'}}. Option is considered matching if all specified properties match.
* @return An array of option values that have been successfully selected.
*/
@ -1854,7 +1854,7 @@ public interface Page {
* This method expects {@code selector} to point to an input element.
* <p>
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.
* @param selector A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
void setInputFiles(String selector, FileChooser.FilePayload[] files, SetInputFilesOptions options);
/**
@ -1885,7 +1885,7 @@ public interface Page {
* <strong>NOTE</strong> {@code page.tap()} requires that the {@code hasTouch} option of the browser context be set to true.
* <p>
* Shortcut for page.mainFrame().tap().
* @param selector A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully tapped.
*/
void tap(String selector, TapOptions options);
@ -1894,7 +1894,7 @@ public interface Page {
}
/**
* Resolves to the {@code element.textContent}.
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be picked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
*/
String textContent(String selector, TextContentOptions options);
/**
@ -1911,7 +1911,7 @@ public interface Page {
* To press a special key, like {@code Control} or {@code ArrowDown}, use {@code keyboard.press}.
* <p>
* Shortcut for page.mainFrame().type(selector, text[, options]).
* @param selector A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @param text A text to type into a focused element.
*/
void type(String selector, String text, TypeOptions options);
@ -1938,7 +1938,7 @@ public interface Page {
* When all steps combined have not finished during the specified {@code timeout}, this method rejects with a TimeoutError. Passing zero timeout disables this.
* <p>
* Shortcut for page.mainFrame().uncheck(selector[, options]).
* @param selector A selector to search for uncheckbox to check. If there are multiple elements satisfying the selector, the first will be checked. See working with selectors for more details.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See working with selectors for more details.
* @return Promise that resolves when the element matching {@code selector} is successfully unchecked.
*/
void uncheck(String selector, UncheckOptions options);
@ -2061,7 +2061,7 @@ public interface Page {
* This method works across navigations:
* <p>
* Shortcut for page.mainFrame().waitForSelector(selector[, options]).
* @param selector A selector of an element to wait for. See working with selectors for more details.
* @param selector A selector to query for. See working with selectors for more details.
* @return Promise which resolves when element specified by selector satisfies {@code state} option. Resolves to {@code null} if waiting for {@code hidden} or {@code detached}.
*/
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);

View File

@ -82,7 +82,6 @@ public interface Request {
private int responseStart;
/**
* Time immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first. The value is given in milliseconds relative to {@code startTime}, -1 if not available.
* };
*/
private int responseEnd;

View File

@ -25,6 +25,10 @@ import java.util.*;
*/
public interface Route {
class ContinueOverrides {
/**
* If set changes the request URL. New URL must have same protocol as original one.
*/
public String url;
/**
* If set changes the request method (e.g. GET or POST)
*/
@ -38,6 +42,10 @@ public interface Route {
*/
public Map<String, String> headers;
public ContinueOverrides withUrl(String url) {
this.url = url;
return this;
}
public ContinueOverrides withMethod(String method) {
this.method = method;
return this;

View File

@ -16,14 +16,11 @@
package com.microsoft.playwright.impl;
import com.google.gson.*;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.microsoft.playwright.*;
import java.io.IOException;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@ -243,6 +240,11 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
sendMessage("setOffline", params);
}
@Override
public Object storageState() {
return null;
}
@Override
public void unroute(String url, Consumer<Route> handler) {
unroute(new UrlMatcher(url), handler);