mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-09-08 21:01:00 +00:00
chore: generate api using the newest api.json (#67)
This commit is contained in:
parent
f05f044c2f
commit
463435c992
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -29,16 +29,16 @@ jobs:
|
||||
run: |
|
||||
FILE_NAME="unkwnown"
|
||||
if [[ $OS == *"ubuntu"* ]]; then
|
||||
FILE_NAME=playwright-cli-0.151.0-linux.zip
|
||||
FILE_NAME=playwright-cli-0.160.0-next.1604357190081-linux.zip
|
||||
fi
|
||||
if [[ $OS == *"macos"* ]]; then
|
||||
FILE_NAME=playwright-cli-0.151.0-mac.zip
|
||||
FILE_NAME=playwright-cli-0.160.0-next.1604357190081-mac.zip
|
||||
fi
|
||||
if [[ $OS == *"windows"* ]]; then
|
||||
FILE_NAME=playwright-cli-0.151.0-win32_x64.zip
|
||||
FILE_NAME=playwright-cli-0.160.0-next.1604357190081-win32_x64.zip
|
||||
fi
|
||||
echo "Downloading from $FILE_NAME"
|
||||
curl -O https://playwright.azureedge.net/builds/cli/$FILE_NAME
|
||||
curl -O https://playwright.azureedge.net/builds/cli/next/$FILE_NAME
|
||||
unzip $FILE_NAME -d .
|
||||
./playwright-cli install
|
||||
- name: Build with Maven
|
||||
|
@ -16,7 +16,7 @@ cd playwright-java
|
||||
```bash
|
||||
mkdir driver
|
||||
cd driver
|
||||
FILENAME=playwright-cli-0.160.0-next.1604089209904-linux.zip
|
||||
FILENAME=playwright-cli-0.160.0-next.1604357190081-linux.zip
|
||||
curl -O https://playwright.azureedge.net/builds/cli/next/${FILENAME}
|
||||
unzip ${FILENAME} -d .
|
||||
./playwright-cli install
|
||||
|
@ -59,6 +59,7 @@ class Types {
|
||||
add("Page.click.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Page.dblclick.options.button", "\"left\"|\"middle\"|\"right\"", "Mouse.Button", new Empty());
|
||||
add("Page.dblclick.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Page.tap.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Page.emulateMedia.options.media", "null|\"print\"|\"screen\"", "Media");
|
||||
add("Page.emulateMedia.options.colorScheme", "null|\"dark\"|\"light\"|\"no-preference\"", "ColorScheme", new Empty());
|
||||
add("Page.goBack.options.waitUntil", "\"domcontentloaded\"|\"load\"|\"networkidle\"", "Frame.LoadState", new Empty());
|
||||
@ -75,6 +76,7 @@ class Types {
|
||||
add("Frame.click.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Frame.dblclick.options.button", "\"left\"|\"middle\"|\"right\"", "Mouse.Button", new Empty());
|
||||
add("Frame.dblclick.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Frame.tap.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Frame.goto.options.waitUntil", "\"domcontentloaded\"|\"load\"|\"networkidle\"", "LoadState", new Empty());
|
||||
add("Frame.hover.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("Frame.setContent.options.waitUntil", "\"domcontentloaded\"|\"load\"|\"networkidle\"", "LoadState", new Empty());
|
||||
@ -85,6 +87,7 @@ class Types {
|
||||
add("ElementHandle.click.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("ElementHandle.dblclick.options.button", "\"left\"|\"middle\"|\"right\"", "Mouse.Button", new Empty());
|
||||
add("ElementHandle.dblclick.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("ElementHandle.tap.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("ElementHandle.hover.options.modifiers", "Array<\"Alt\"|\"Control\"|\"Meta\"|\"Shift\">", "Set<Keyboard.Modifier>", new Empty());
|
||||
add("ElementHandle.screenshot.options.type", "\"jpeg\"|\"png\"", "Type");
|
||||
add("ElementHandle.waitForSelector.options.state", "\"attached\"|\"detached\"|\"hidden\"|\"visible\"", "State");
|
||||
@ -177,6 +180,7 @@ class Types {
|
||||
add("Selectors.register.script", "function|string|Object", "String");
|
||||
add("Worker.evaluate.pageFunction", "function|string", "String");
|
||||
add("Worker.evaluateHandle.pageFunction", "function|string", "String");
|
||||
add("WebSocket.waitForEvent.optionsOrPredicate", "Function|Object", "String");
|
||||
|
||||
// Return structures
|
||||
add("Dialog.type", "string", "Type", new Empty());
|
||||
@ -294,6 +298,9 @@ class Types {
|
||||
add("Response.body", "Promise<Buffer>", "byte[]");
|
||||
add("Response.finished", "Promise<null|Error>", "String");
|
||||
add("ChromiumBrowser.stopTracing", "Promise<Buffer>", "byte[]");
|
||||
add("WebSocket.framereceived.payload", "string|Buffer", "byte[]");
|
||||
add("WebSocket.framesent.payload", "string|Buffer", "byte[]");
|
||||
|
||||
|
||||
// JSON type
|
||||
add("BrowserContext.addInitScript.arg", "Serializable", "Object");
|
||||
|
File diff suppressed because one or more lines are too long
@ -26,6 +26,35 @@ public interface Browser {
|
||||
void addListener(EventType type, Listener<EventType> listener);
|
||||
void removeListener(EventType type, Listener<EventType> listener);
|
||||
class NewContextOptions {
|
||||
public class Proxy {
|
||||
public String server;
|
||||
public String bypass;
|
||||
public String username;
|
||||
public String password;
|
||||
|
||||
Proxy() {
|
||||
}
|
||||
public NewContextOptions done() {
|
||||
return NewContextOptions.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 {
|
||||
public int width;
|
||||
public int height;
|
||||
@ -45,6 +74,25 @@ public interface Browser {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public class RecordHar {
|
||||
public Boolean omitContent;
|
||||
public String path;
|
||||
|
||||
RecordHar() {
|
||||
}
|
||||
public NewContextOptions done() {
|
||||
return NewContextOptions.this;
|
||||
}
|
||||
|
||||
public RecordHar withOmitContent(Boolean omitContent) {
|
||||
this.omitContent = omitContent;
|
||||
return this;
|
||||
}
|
||||
public RecordHar withPath(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Boolean acceptDownloads;
|
||||
public Boolean ignoreHTTPSErrors;
|
||||
public Boolean bypassCSP;
|
||||
@ -63,8 +111,10 @@ public interface Browser {
|
||||
public BrowserContext.HTTPCredentials httpCredentials;
|
||||
public ColorScheme colorScheme;
|
||||
public Logger logger;
|
||||
public Proxy proxy;
|
||||
public String videosPath;
|
||||
public VideoSize videoSize;
|
||||
public RecordHar recordHar;
|
||||
|
||||
public NewContextOptions withAcceptDownloads(Boolean acceptDownloads) {
|
||||
this.acceptDownloads = acceptDownloads;
|
||||
@ -138,6 +188,10 @@ public interface Browser {
|
||||
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;
|
||||
@ -146,8 +200,41 @@ public interface Browser {
|
||||
this.videoSize = new VideoSize();
|
||||
return this.videoSize;
|
||||
}
|
||||
public RecordHar setRecordHar() {
|
||||
this.recordHar = new RecordHar();
|
||||
return this.recordHar;
|
||||
}
|
||||
}
|
||||
class NewPageOptions {
|
||||
public class Proxy {
|
||||
public String server;
|
||||
public String bypass;
|
||||
public String username;
|
||||
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 {
|
||||
public int width;
|
||||
public int height;
|
||||
@ -167,6 +254,25 @@ public interface Browser {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public class RecordHar {
|
||||
public Boolean omitContent;
|
||||
public String path;
|
||||
|
||||
RecordHar() {
|
||||
}
|
||||
public NewPageOptions done() {
|
||||
return NewPageOptions.this;
|
||||
}
|
||||
|
||||
public RecordHar withOmitContent(Boolean omitContent) {
|
||||
this.omitContent = omitContent;
|
||||
return this;
|
||||
}
|
||||
public RecordHar withPath(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Boolean acceptDownloads;
|
||||
public Boolean ignoreHTTPSErrors;
|
||||
public Boolean bypassCSP;
|
||||
@ -185,8 +291,10 @@ public interface Browser {
|
||||
public BrowserContext.HTTPCredentials httpCredentials;
|
||||
public ColorScheme colorScheme;
|
||||
public Logger logger;
|
||||
public Proxy proxy;
|
||||
public String videosPath;
|
||||
public VideoSize videoSize;
|
||||
public RecordHar recordHar;
|
||||
|
||||
public NewPageOptions withAcceptDownloads(Boolean acceptDownloads) {
|
||||
this.acceptDownloads = acceptDownloads;
|
||||
@ -260,6 +368,10 @@ public interface Browser {
|
||||
this.logger = logger;
|
||||
return this;
|
||||
}
|
||||
public Proxy setProxy() {
|
||||
this.proxy = new Proxy();
|
||||
return this.proxy;
|
||||
}
|
||||
public NewPageOptions withVideosPath(String videosPath) {
|
||||
this.videosPath = videosPath;
|
||||
return this;
|
||||
@ -268,6 +380,10 @@ public interface Browser {
|
||||
this.videoSize = new VideoSize();
|
||||
return this.videoSize;
|
||||
}
|
||||
public RecordHar setRecordHar() {
|
||||
this.recordHar = new RecordHar();
|
||||
return this.recordHar;
|
||||
}
|
||||
}
|
||||
void close();
|
||||
List<BrowserContext> contexts();
|
||||
|
@ -203,6 +203,25 @@ public interface BrowserType {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public class RecordHar {
|
||||
public Boolean omitContent;
|
||||
public String path;
|
||||
|
||||
RecordHar() {
|
||||
}
|
||||
public LaunchPersistentContextOptions done() {
|
||||
return LaunchPersistentContextOptions.this;
|
||||
}
|
||||
|
||||
public RecordHar withOmitContent(Boolean omitContent) {
|
||||
this.omitContent = omitContent;
|
||||
return this;
|
||||
}
|
||||
public RecordHar withPath(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Boolean headless;
|
||||
public String executablePath;
|
||||
public List<String> args;
|
||||
@ -237,6 +256,7 @@ public interface BrowserType {
|
||||
public ColorScheme colorScheme;
|
||||
public String videosPath;
|
||||
public VideoSize videoSize;
|
||||
public RecordHar recordHar;
|
||||
|
||||
public LaunchPersistentContextOptions withHeadless(Boolean headless) {
|
||||
this.headless = headless;
|
||||
@ -374,6 +394,10 @@ public interface BrowserType {
|
||||
this.videoSize = new VideoSize();
|
||||
return this.videoSize;
|
||||
}
|
||||
public RecordHar setRecordHar() {
|
||||
this.recordHar = new RecordHar();
|
||||
return this.recordHar;
|
||||
}
|
||||
}
|
||||
class LaunchServerOptions {
|
||||
public class Proxy {
|
||||
|
@ -280,6 +280,53 @@ public interface ElementHandle extends JSHandle {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TapOptions {
|
||||
public class Position {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
Position() {
|
||||
}
|
||||
public TapOptions done() {
|
||||
return TapOptions.this;
|
||||
}
|
||||
|
||||
public Position withX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
public Position withY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Position position;
|
||||
public Set<Keyboard.Modifier> modifiers;
|
||||
public Boolean force;
|
||||
public Boolean noWaitAfter;
|
||||
public Integer timeout;
|
||||
|
||||
public Position setPosition() {
|
||||
this.position = new Position();
|
||||
return this.position;
|
||||
}
|
||||
public TapOptions withModifiers(Keyboard.Modifier... modifiers) {
|
||||
this.modifiers = new HashSet<>(Arrays.asList(modifiers));
|
||||
return this;
|
||||
}
|
||||
public TapOptions withForce(Boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withNoWaitAfter(Boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TypeOptions {
|
||||
public Integer delay;
|
||||
public Boolean noWaitAfter;
|
||||
@ -442,6 +489,10 @@ public interface ElementHandle extends JSHandle {
|
||||
default void setInputFiles(FileChooser.FilePayload file, SetInputFilesOptions options) { setInputFiles(new FileChooser.FilePayload[]{ file }, options); }
|
||||
default void setInputFiles(FileChooser.FilePayload[] files) { setInputFiles(files, null); }
|
||||
void setInputFiles(FileChooser.FilePayload[] files, SetInputFilesOptions options);
|
||||
default void tap() {
|
||||
tap(null);
|
||||
}
|
||||
void tap(TapOptions options);
|
||||
String textContent();
|
||||
String toString();
|
||||
default void type(String text) {
|
||||
|
@ -323,6 +323,53 @@ public interface Frame {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TapOptions {
|
||||
public class Position {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
Position() {
|
||||
}
|
||||
public TapOptions done() {
|
||||
return TapOptions.this;
|
||||
}
|
||||
|
||||
public Position withX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
public Position withY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Position position;
|
||||
public Set<Keyboard.Modifier> modifiers;
|
||||
public Boolean noWaitAfter;
|
||||
public Boolean force;
|
||||
public Integer timeout;
|
||||
|
||||
public Position setPosition() {
|
||||
this.position = new Position();
|
||||
return this.position;
|
||||
}
|
||||
public TapOptions withModifiers(Keyboard.Modifier... modifiers) {
|
||||
this.modifiers = new HashSet<>(Arrays.asList(modifiers));
|
||||
return this;
|
||||
}
|
||||
public TapOptions withNoWaitAfter(Boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withForce(Boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TextContentOptions {
|
||||
public Integer timeout;
|
||||
|
||||
@ -563,6 +610,10 @@ public interface Frame {
|
||||
default void setInputFiles(String selector, FileChooser.FilePayload file, SetInputFilesOptions options) { setInputFiles(selector, new FileChooser.FilePayload[]{ file }, options); }
|
||||
default void setInputFiles(String selector, FileChooser.FilePayload[] files) { setInputFiles(selector, files, null); }
|
||||
void setInputFiles(String selector, FileChooser.FilePayload[] files, SetInputFilesOptions options);
|
||||
default void tap(String selector) {
|
||||
tap(selector, null);
|
||||
}
|
||||
void tap(String selector, TapOptions options);
|
||||
default String textContent(String selector) {
|
||||
return textContent(selector, null);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public interface Page {
|
||||
REQUESTFAILED,
|
||||
REQUESTFINISHED,
|
||||
RESPONSE,
|
||||
WEBSOCKET,
|
||||
WORKER,
|
||||
}
|
||||
|
||||
@ -632,6 +633,53 @@ public interface Page {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TapOptions {
|
||||
public class Position {
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
Position() {
|
||||
}
|
||||
public TapOptions done() {
|
||||
return TapOptions.this;
|
||||
}
|
||||
|
||||
public Position withX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
public Position withY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public Position position;
|
||||
public Set<Keyboard.Modifier> modifiers;
|
||||
public Boolean noWaitAfter;
|
||||
public Boolean force;
|
||||
public Integer timeout;
|
||||
|
||||
public Position setPosition() {
|
||||
this.position = new Position();
|
||||
return this.position;
|
||||
}
|
||||
public TapOptions withModifiers(Keyboard.Modifier... modifiers) {
|
||||
this.modifiers = new HashSet<>(Arrays.asList(modifiers));
|
||||
return this;
|
||||
}
|
||||
public TapOptions withNoWaitAfter(Boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withForce(Boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public TapOptions withTimeout(Integer timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class TextContentOptions {
|
||||
public Integer timeout;
|
||||
|
||||
@ -937,11 +985,16 @@ public interface Page {
|
||||
default void setInputFiles(String selector, FileChooser.FilePayload[] files) { setInputFiles(selector, files, null); }
|
||||
void setInputFiles(String selector, FileChooser.FilePayload[] files, SetInputFilesOptions options);
|
||||
void setViewportSize(int width, int height);
|
||||
default void tap(String selector) {
|
||||
tap(selector, null);
|
||||
}
|
||||
void tap(String selector, TapOptions options);
|
||||
default String textContent(String selector) {
|
||||
return textContent(selector, null);
|
||||
}
|
||||
String textContent(String selector, TextContentOptions options);
|
||||
String title();
|
||||
Touchscreen touchscreen();
|
||||
default void type(String selector, String text) {
|
||||
type(selector, text, null);
|
||||
}
|
||||
|
@ -31,6 +31,45 @@ public interface Request {
|
||||
}
|
||||
class RequestPostDataJSON {
|
||||
|
||||
}
|
||||
class RequestTiming {
|
||||
private int startTime;
|
||||
private int domainLookupStart;
|
||||
private int domainLookupEnd;
|
||||
private int connectStart;
|
||||
private int secureConnectionStart;
|
||||
private int connectEnd;
|
||||
private int requestStart;
|
||||
private int responseStart;
|
||||
private int responseEnd;
|
||||
|
||||
public int startTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
public int domainLookupStart() {
|
||||
return this.domainLookupStart;
|
||||
}
|
||||
public int domainLookupEnd() {
|
||||
return this.domainLookupEnd;
|
||||
}
|
||||
public int connectStart() {
|
||||
return this.connectStart;
|
||||
}
|
||||
public int secureConnectionStart() {
|
||||
return this.secureConnectionStart;
|
||||
}
|
||||
public int connectEnd() {
|
||||
return this.connectEnd;
|
||||
}
|
||||
public int requestStart() {
|
||||
return this.requestStart;
|
||||
}
|
||||
public int responseStart() {
|
||||
return this.responseStart;
|
||||
}
|
||||
public int responseEnd() {
|
||||
return this.responseEnd;
|
||||
}
|
||||
}
|
||||
RequestFailure failure();
|
||||
Frame frame();
|
||||
@ -43,6 +82,7 @@ public interface Request {
|
||||
Request redirectedTo();
|
||||
String resourceType();
|
||||
Response response();
|
||||
RequestTiming timing();
|
||||
String url();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface Touchscreen {
|
||||
void tap(int x, int y);
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface WebSocket {
|
||||
enum EventType {
|
||||
CLOSE,
|
||||
FRAMERECEIVED,
|
||||
FRAMESENT,
|
||||
SOCKETERROR,
|
||||
}
|
||||
|
||||
void addListener(EventType type, Listener<EventType> listener);
|
||||
void removeListener(EventType type, Listener<EventType> listener);
|
||||
class WebSocketFramereceived {
|
||||
public byte[] payload;
|
||||
|
||||
public WebSocketFramereceived withPayload(byte[] payload) {
|
||||
this.payload = payload;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class WebSocketFramesent {
|
||||
public byte[] payload;
|
||||
|
||||
public WebSocketFramesent withPayload(byte[] payload) {
|
||||
this.payload = payload;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
boolean isClosed();
|
||||
String url();
|
||||
default Object waitForEvent(String event) {
|
||||
return waitForEvent(event, null);
|
||||
}
|
||||
Object waitForEvent(String event, String optionsOrPredicate);
|
||||
}
|
||||
|
@ -137,7 +137,11 @@ public class Connection {
|
||||
if (message.error == null) {
|
||||
callback.complete(message.result);
|
||||
} else {
|
||||
callback.completeExceptionally(new PlaywrightException(message.error.toString()));
|
||||
if (message.error.error != null) {
|
||||
callback.completeExceptionally(new ServerException(message.error.error));
|
||||
} else {
|
||||
callback.completeExceptionally(new PlaywrightException(message.error.toString()));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -330,6 +330,11 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
||||
sendMessage("setInputFiles", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tap(TapOptions options) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String textContent() {
|
||||
JsonObject json = sendMessage("textContent").getAsJsonObject();
|
||||
|
@ -455,6 +455,11 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
sendMessage("setInputFiles", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tap(String selector, TapOptions options) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String textContent(String selector, TextContentOptions options) {
|
||||
if (options == null) {
|
||||
|
@ -30,6 +30,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
import static com.microsoft.playwright.impl.Utils.convertViaJson;
|
||||
import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
|
||||
|
||||
|
||||
public class PageImpl extends ChannelOwner implements Page {
|
||||
@ -206,7 +207,13 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
@Override
|
||||
public void close(CloseOptions options) {
|
||||
JsonObject params = options == null ? new JsonObject() : gson().toJsonTree(options).getAsJsonObject();
|
||||
sendMessage("close", params);
|
||||
try {
|
||||
sendMessage("close", params);
|
||||
} catch (PlaywrightException exception) {
|
||||
if (!isSafeCloseError(exception)) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
if (ownedContext != null) {
|
||||
ownedContext.close();
|
||||
}
|
||||
@ -630,6 +637,11 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
sendMessage("setViewportSize", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tap(String selector, TapOptions options) {
|
||||
mainFrame.tap(selector, convertViaJson(options, Frame.TapOptions.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String textContent(String selector, TextContentOptions options) {
|
||||
return mainFrame.textContent(selector, convertViaJson(options, Frame.TextContentOptions.class));
|
||||
@ -640,6 +652,11 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
return mainFrame.title();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Touchscreen touchscreen() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void type(String selector, String text, TypeOptions options) {
|
||||
mainFrame.type(selector, text, convertViaJson(options, Frame.TypeOptions.class));
|
||||
|
@ -114,6 +114,11 @@ public class RequestImpl extends ChannelOwner implements Request {
|
||||
return connection.getExistingObject(result.getAsJsonObject("response").get("guid").getAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestTiming timing() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String url() {
|
||||
return initializer.get("url").getAsString();
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.impl;
|
||||
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
class ServerException extends PlaywrightException {
|
||||
private final SerializedError.Error error;
|
||||
|
||||
ServerException(SerializedError.Error error) {
|
||||
super(error.name + ": " + error.message);
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
s.println("Caused by Playwright server error:");
|
||||
s.println(getMessage());
|
||||
s.println(error.stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
s.println("Caused by Playwright server error:");
|
||||
s.println(getMessage());
|
||||
s.println(error.stack);
|
||||
}
|
||||
}
|
@ -151,7 +151,7 @@ class Utils {
|
||||
}
|
||||
|
||||
static boolean isSafeCloseError(String error) {
|
||||
return error.endsWith("Browser has been closed") || error.endsWith("Target browser or context has been closed");
|
||||
return error.endsWith("Browser has been closed") || error.endsWith("Target page, context or browser has been closed");
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user