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
|
||||
mkdir 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}
|
||||
unzip ${FILENAME} -d .
|
||||
./playwright-cli install
|
||||
|
@ -638,20 +638,15 @@ class Interface extends TypeDefinition {
|
||||
Interface(JsonObject jsonElement) {
|
||||
super(null, jsonElement);
|
||||
|
||||
JsonObject members = jsonElement.get("members").getAsJsonObject();
|
||||
for (Map.Entry<String, JsonElement> m : members.entrySet()) {
|
||||
JsonObject json = m.getValue().getAsJsonObject();
|
||||
String kind = json.get("kind").getAsString();
|
||||
if ("method".equals(kind)) {
|
||||
methods.add(new Method(this, json));
|
||||
for (Map.Entry<String, JsonElement> m : jsonElement.get("methods").getAsJsonObject().entrySet()) {
|
||||
methods.add(new Method(this, m.getValue().getAsJsonObject()));
|
||||
}
|
||||
for (Map.Entry<String, JsonElement> m : jsonElement.get("properties").getAsJsonObject().entrySet()) {
|
||||
// All properties are converted to methods in Java.
|
||||
if ("property".equals(kind)) {
|
||||
methods.add(new Method(this, json));
|
||||
}
|
||||
if ("event".equals(kind)) {
|
||||
events.add(new Event(this, json));
|
||||
methods.add(new Method(this, m.getValue().getAsJsonObject()));
|
||||
}
|
||||
for (Map.Entry<String, JsonElement> m : jsonElement.get("events").getAsJsonObject().entrySet()) {
|
||||
events.add(new Event(this, m.getValue().getAsJsonObject()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -704,10 +699,6 @@ class Interface extends TypeDefinition {
|
||||
return;
|
||||
}
|
||||
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++) {
|
||||
String comma = i == events.size() ? "" : ",";
|
||||
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 {
|
||||
CLOSE,
|
||||
PAGE,
|
||||
}
|
||||
|
||||
@ -160,7 +161,6 @@ public interface BrowserContext {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
void close();
|
||||
void addCookies(List<AddCookie> cookies);
|
||||
default void addInitScript(String script) {
|
||||
addInitScript(script, null);
|
||||
@ -169,6 +169,7 @@ public interface BrowserContext {
|
||||
Browser browser();
|
||||
void clearCookies();
|
||||
void clearPermissions();
|
||||
void close();
|
||||
default List<Cookie> cookies() { return cookies((List<String>) null); }
|
||||
default List<Cookie> cookies(String url) { return cookies(Arrays.asList(url)); }
|
||||
List<Cookie> cookies(List<String> urls);
|
||||
|
@ -99,14 +99,6 @@ public interface Page {
|
||||
void addListener(EventType type, Listener<EventType> listener);
|
||||
void removeListener(EventType type, Listener<EventType> listener);
|
||||
enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE }
|
||||
class CloseOptions {
|
||||
public Boolean runBeforeUnload;
|
||||
|
||||
public CloseOptions withRunBeforeUnload(Boolean runBeforeUnload) {
|
||||
this.runBeforeUnload = runBeforeUnload;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class AddScriptTagOptions {
|
||||
public String url;
|
||||
public Path path;
|
||||
@ -212,6 +204,14 @@ public interface Page {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class CloseOptions {
|
||||
public Boolean runBeforeUnload;
|
||||
|
||||
public CloseOptions withRunBeforeUnload(Boolean runBeforeUnload) {
|
||||
this.runBeforeUnload = runBeforeUnload;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class DblclickOptions {
|
||||
public Mouse.Button button;
|
||||
public Integer delay;
|
||||
@ -807,10 +807,6 @@ public interface Page {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
default void close() {
|
||||
close(null);
|
||||
}
|
||||
void close(CloseOptions options);
|
||||
ElementHandle querySelector(String selector);
|
||||
List<ElementHandle> querySelectorAll(String selector);
|
||||
default Object evalOnSelector(String selector, String pageFunction) {
|
||||
@ -821,7 +817,6 @@ public interface Page {
|
||||
return evalOnSelectorAll(selector, pageFunction, null);
|
||||
}
|
||||
Object evalOnSelectorAll(String selector, String pageFunction, Object arg);
|
||||
Accessibility accessibility();
|
||||
default void addInitScript(String script) {
|
||||
addInitScript(script, null);
|
||||
}
|
||||
@ -837,9 +832,12 @@ public interface Page {
|
||||
click(selector, null);
|
||||
}
|
||||
void click(String selector, ClickOptions options);
|
||||
default void close() {
|
||||
close(null);
|
||||
}
|
||||
void close(CloseOptions options);
|
||||
String content();
|
||||
BrowserContext context();
|
||||
ChromiumCoverage coverage();
|
||||
default void dblclick(String selector) {
|
||||
dblclick(selector, null);
|
||||
}
|
||||
@ -907,9 +905,7 @@ public interface Page {
|
||||
}
|
||||
String innerText(String selector, InnerTextOptions options);
|
||||
boolean isClosed();
|
||||
Keyboard keyboard();
|
||||
Frame mainFrame();
|
||||
Mouse mouse();
|
||||
Page opener();
|
||||
default byte[] pdf() {
|
||||
return pdf(null);
|
||||
@ -994,7 +990,6 @@ public interface Page {
|
||||
}
|
||||
String textContent(String selector, TextContentOptions options);
|
||||
String title();
|
||||
Touchscreen touchscreen();
|
||||
default void type(String selector, String text) {
|
||||
type(selector, text, null);
|
||||
}
|
||||
@ -1053,5 +1048,10 @@ public interface Page {
|
||||
Deferred<ElementHandle> waitForSelector(String selector, WaitForSelectorOptions options);
|
||||
Deferred<Void> waitForTimeout(int timeout);
|
||||
List<Worker> workers();
|
||||
Accessibility accessibility();
|
||||
ChromiumCoverage coverage();
|
||||
Keyboard keyboard();
|
||||
Mouse mouse();
|
||||
Touchscreen touchscreen();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user