mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-09-08 21:01:00 +00:00
fix: switch to new api.json format (#68)
This commit is contained in:
parent
463435c992
commit
298a5f8bb8
@ -16,7 +16,7 @@ cd playwright-java
|
|||||||
```bash
|
```bash
|
||||||
mkdir driver
|
mkdir driver
|
||||||
cd driver
|
cd driver
|
||||||
FILENAME=playwright-cli-0.160.0-next.1604357190081-linux.zip
|
FILENAME=playwright-cli-0.160.0-next.1604373941495-linux.zip
|
||||||
curl -O https://playwright.azureedge.net/builds/cli/next/${FILENAME}
|
curl -O https://playwright.azureedge.net/builds/cli/next/${FILENAME}
|
||||||
unzip ${FILENAME} -d .
|
unzip ${FILENAME} -d .
|
||||||
./playwright-cli install
|
./playwright-cli install
|
||||||
|
@ -638,20 +638,15 @@ class Interface extends TypeDefinition {
|
|||||||
Interface(JsonObject jsonElement) {
|
Interface(JsonObject jsonElement) {
|
||||||
super(null, jsonElement);
|
super(null, jsonElement);
|
||||||
|
|
||||||
JsonObject members = jsonElement.get("members").getAsJsonObject();
|
for (Map.Entry<String, JsonElement> m : jsonElement.get("methods").getAsJsonObject().entrySet()) {
|
||||||
for (Map.Entry<String, JsonElement> m : members.entrySet()) {
|
methods.add(new Method(this, m.getValue().getAsJsonObject()));
|
||||||
JsonObject json = m.getValue().getAsJsonObject();
|
}
|
||||||
String kind = json.get("kind").getAsString();
|
for (Map.Entry<String, JsonElement> m : jsonElement.get("properties").getAsJsonObject().entrySet()) {
|
||||||
if ("method".equals(kind)) {
|
|
||||||
methods.add(new Method(this, json));
|
|
||||||
}
|
|
||||||
// All properties are converted to methods in Java.
|
// All properties are converted to methods in Java.
|
||||||
if ("property".equals(kind)) {
|
methods.add(new Method(this, m.getValue().getAsJsonObject()));
|
||||||
methods.add(new Method(this, json));
|
}
|
||||||
}
|
for (Map.Entry<String, JsonElement> m : jsonElement.get("events").getAsJsonObject().entrySet()) {
|
||||||
if ("event".equals(kind)) {
|
events.add(new Event(this, m.getValue().getAsJsonObject()));
|
||||||
events.add(new Event(this, json));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,10 +699,6 @@ class Interface extends TypeDefinition {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
output.add(offset + "enum EventType {");
|
output.add(offset + "enum EventType {");
|
||||||
// TODO: fix api.json to not miss this event.
|
|
||||||
if ("Page".equals(jsonName)) {
|
|
||||||
output.add(offset + " CLOSE,");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
String comma = i == events.size() ? "" : ",";
|
String comma = i == events.size() ? "" : ",";
|
||||||
output.add(offset + " " + events.get(i).jsonName.toUpperCase() + comma);
|
output.add(offset + " " + events.get(i).jsonName.toUpperCase() + comma);
|
||||||
|
File diff suppressed because one or more lines are too long
@ -56,6 +56,7 @@ public interface BrowserContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
|
CLOSE,
|
||||||
PAGE,
|
PAGE,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +161,6 @@ public interface BrowserContext {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void close();
|
|
||||||
void addCookies(List<AddCookie> cookies);
|
void addCookies(List<AddCookie> cookies);
|
||||||
default void addInitScript(String script) {
|
default void addInitScript(String script) {
|
||||||
addInitScript(script, null);
|
addInitScript(script, null);
|
||||||
@ -169,6 +169,7 @@ public interface BrowserContext {
|
|||||||
Browser browser();
|
Browser browser();
|
||||||
void clearCookies();
|
void clearCookies();
|
||||||
void clearPermissions();
|
void clearPermissions();
|
||||||
|
void close();
|
||||||
default List<Cookie> cookies() { return cookies((List<String>) null); }
|
default List<Cookie> cookies() { return cookies((List<String>) null); }
|
||||||
default List<Cookie> cookies(String url) { return cookies(Arrays.asList(url)); }
|
default List<Cookie> cookies(String url) { return cookies(Arrays.asList(url)); }
|
||||||
List<Cookie> cookies(List<String> urls);
|
List<Cookie> cookies(List<String> urls);
|
||||||
|
@ -99,14 +99,6 @@ public interface Page {
|
|||||||
void addListener(EventType type, Listener<EventType> listener);
|
void addListener(EventType type, Listener<EventType> listener);
|
||||||
void removeListener(EventType type, Listener<EventType> listener);
|
void removeListener(EventType type, Listener<EventType> listener);
|
||||||
enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE }
|
enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE }
|
||||||
class CloseOptions {
|
|
||||||
public Boolean runBeforeUnload;
|
|
||||||
|
|
||||||
public CloseOptions withRunBeforeUnload(Boolean runBeforeUnload) {
|
|
||||||
this.runBeforeUnload = runBeforeUnload;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class AddScriptTagOptions {
|
class AddScriptTagOptions {
|
||||||
public String url;
|
public String url;
|
||||||
public Path path;
|
public Path path;
|
||||||
@ -212,6 +204,14 @@ public interface Page {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class CloseOptions {
|
||||||
|
public Boolean runBeforeUnload;
|
||||||
|
|
||||||
|
public CloseOptions withRunBeforeUnload(Boolean runBeforeUnload) {
|
||||||
|
this.runBeforeUnload = runBeforeUnload;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
class DblclickOptions {
|
class DblclickOptions {
|
||||||
public Mouse.Button button;
|
public Mouse.Button button;
|
||||||
public Integer delay;
|
public Integer delay;
|
||||||
@ -807,10 +807,6 @@ public interface Page {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default void close() {
|
|
||||||
close(null);
|
|
||||||
}
|
|
||||||
void close(CloseOptions options);
|
|
||||||
ElementHandle querySelector(String selector);
|
ElementHandle querySelector(String selector);
|
||||||
List<ElementHandle> querySelectorAll(String selector);
|
List<ElementHandle> querySelectorAll(String selector);
|
||||||
default Object evalOnSelector(String selector, String pageFunction) {
|
default Object evalOnSelector(String selector, String pageFunction) {
|
||||||
@ -821,7 +817,6 @@ public interface Page {
|
|||||||
return evalOnSelectorAll(selector, pageFunction, null);
|
return evalOnSelectorAll(selector, pageFunction, null);
|
||||||
}
|
}
|
||||||
Object evalOnSelectorAll(String selector, String pageFunction, Object arg);
|
Object evalOnSelectorAll(String selector, String pageFunction, Object arg);
|
||||||
Accessibility accessibility();
|
|
||||||
default void addInitScript(String script) {
|
default void addInitScript(String script) {
|
||||||
addInitScript(script, null);
|
addInitScript(script, null);
|
||||||
}
|
}
|
||||||
@ -837,9 +832,12 @@ public interface Page {
|
|||||||
click(selector, null);
|
click(selector, null);
|
||||||
}
|
}
|
||||||
void click(String selector, ClickOptions options);
|
void click(String selector, ClickOptions options);
|
||||||
|
default void close() {
|
||||||
|
close(null);
|
||||||
|
}
|
||||||
|
void close(CloseOptions options);
|
||||||
String content();
|
String content();
|
||||||
BrowserContext context();
|
BrowserContext context();
|
||||||
ChromiumCoverage coverage();
|
|
||||||
default void dblclick(String selector) {
|
default void dblclick(String selector) {
|
||||||
dblclick(selector, null);
|
dblclick(selector, null);
|
||||||
}
|
}
|
||||||
@ -907,9 +905,7 @@ public interface Page {
|
|||||||
}
|
}
|
||||||
String innerText(String selector, InnerTextOptions options);
|
String innerText(String selector, InnerTextOptions options);
|
||||||
boolean isClosed();
|
boolean isClosed();
|
||||||
Keyboard keyboard();
|
|
||||||
Frame mainFrame();
|
Frame mainFrame();
|
||||||
Mouse mouse();
|
|
||||||
Page opener();
|
Page opener();
|
||||||
default byte[] pdf() {
|
default byte[] pdf() {
|
||||||
return pdf(null);
|
return pdf(null);
|
||||||
@ -994,7 +990,6 @@ public interface Page {
|
|||||||
}
|
}
|
||||||
String textContent(String selector, TextContentOptions options);
|
String textContent(String selector, TextContentOptions options);
|
||||||
String title();
|
String title();
|
||||||
Touchscreen touchscreen();
|
|
||||||
default void type(String selector, String text) {
|
default void type(String selector, String text) {
|
||||||
type(selector, text, null);
|
type(selector, text, null);
|
||||||
}
|
}
|
||||||
@ -1053,5 +1048,10 @@ public interface Page {
|
|||||||
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);
|
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);
|
||||||
Deferred<Void> waitForTimeout(int timeout);
|
Deferred<Void> waitForTimeout(int timeout);
|
||||||
List<Worker> workers();
|
List<Worker> workers();
|
||||||
|
Accessibility accessibility();
|
||||||
|
ChromiumCoverage coverage();
|
||||||
|
Keyboard keyboard();
|
||||||
|
Mouse mouse();
|
||||||
|
Touchscreen touchscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user