mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-09-08 21:01:00 +00:00
chore: remove browser-specific APIs (#73)
This commit is contained in:
parent
c33e5fab03
commit
eeb8bd16c9
@ -273,6 +273,8 @@ class Method extends Element {
|
|||||||
// No connect for now.
|
// No connect for now.
|
||||||
customSignature.put("BrowserType.connect", new String[0]);
|
customSignature.put("BrowserType.connect", new String[0]);
|
||||||
customSignature.put("BrowserType.launchServer", new String[0]);
|
customSignature.put("BrowserType.launchServer", new String[0]);
|
||||||
|
// We don't expose Chromium-specific APIs at the moment.
|
||||||
|
customSignature.put("Page.coverage", new String[0]);
|
||||||
customSignature.put("BrowserContext.route", new String[]{
|
customSignature.put("BrowserContext.route", new String[]{
|
||||||
"void route(String url, Consumer<Route> handler);",
|
"void route(String url, Consumer<Route> handler);",
|
||||||
"void route(Pattern url, Consumer<Route> handler);",
|
"void route(Pattern url, Consumer<Route> handler);",
|
||||||
@ -419,6 +421,11 @@ class Method extends Element {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Set<String> skipJavadoc = new HashSet<>(asList(
|
||||||
|
"Page.waitForEvent.optionsOrPredicate",
|
||||||
|
"Page.frame.options"
|
||||||
|
));
|
||||||
|
|
||||||
Method(TypeDefinition parent, JsonObject jsonElement) {
|
Method(TypeDefinition parent, JsonObject jsonElement) {
|
||||||
super(parent, jsonElement);
|
super(parent, jsonElement);
|
||||||
returnType = new TypeRef(this, jsonElement.get("type"));
|
returnType = new TypeRef(this, jsonElement.get("type"));
|
||||||
@ -494,6 +501,9 @@ class Method extends Element {
|
|||||||
if (comment.isEmpty()) {
|
if (comment.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (skipJavadoc.contains(p.jsonPath)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sections.add("@param " + p.name() + " " + comment);
|
sections.add("@param " + p.name() + " " + comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,6 +1016,16 @@ class Enum extends TypeDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ApiGenerator {
|
public class ApiGenerator {
|
||||||
|
private static Set<String> skipList = new HashSet<>(Arrays.asList(
|
||||||
|
"BrowserServer",
|
||||||
|
"ChromiumBrowser",
|
||||||
|
"ChromiumBrowserContext",
|
||||||
|
"ChromiumCoverage",
|
||||||
|
"CDPSession",
|
||||||
|
"FirefoxBrowser",
|
||||||
|
"WebKitBrowser"
|
||||||
|
));
|
||||||
|
|
||||||
ApiGenerator(Reader reader) throws IOException {
|
ApiGenerator(Reader reader) throws IOException {
|
||||||
JsonObject api = new Gson().fromJson(reader, JsonObject.class);
|
JsonObject api = new Gson().fromJson(reader, JsonObject.class);
|
||||||
File cwd = FileSystems.getDefault().getPath(".").toFile();
|
File cwd = FileSystems.getDefault().getPath(".").toFile();
|
||||||
@ -1013,7 +1033,7 @@ public class ApiGenerator {
|
|||||||
System.out.println("Writing files to: " + dir.getCanonicalPath());
|
System.out.println("Writing files to: " + dir.getCanonicalPath());
|
||||||
for (Map.Entry<String, JsonElement> entry: api.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry: api.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
if ("BrowserServer".equals(name)) {
|
if (skipList.contains(name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@code CDPSession} instances are used to talk raw Chrome Devtools Protocol:
|
|
||||||
* <p>
|
|
||||||
* protocol methods can be called with {@code session.send} method.
|
|
||||||
* <p>
|
|
||||||
* protocol events can be subscribed to with {@code session.on} method.
|
|
||||||
* <p>
|
|
||||||
* Useful links:
|
|
||||||
* <p>
|
|
||||||
* Documentation on DevTools Protocol can be found here: DevTools Protocol Viewer.
|
|
||||||
* <p>
|
|
||||||
* Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
public interface CDPSession {
|
|
||||||
/**
|
|
||||||
* Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used
|
|
||||||
* <p>
|
|
||||||
* to send messages.
|
|
||||||
*/
|
|
||||||
void detach();
|
|
||||||
default Object send(String method) {
|
|
||||||
return send(method, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param method protocol method name
|
|
||||||
* @param params Optional method parameters
|
|
||||||
*/
|
|
||||||
Object send(String method, Object params);
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chromium-specific features including Tracing, service worker support, etc.
|
|
||||||
* <p>
|
|
||||||
* You can use {@code chromiumBrowser.startTracing} and {@code chromiumBrowser.stopTracing} to create a trace file which can be opened in Chrome DevTools or timeline viewer.
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
public interface ChromiumBrowser extends Browser {
|
|
||||||
class StartTracingOptions {
|
|
||||||
/**
|
|
||||||
* A path to write the trace file to.
|
|
||||||
*/
|
|
||||||
public Path path;
|
|
||||||
/**
|
|
||||||
* captures screenshots in the trace.
|
|
||||||
*/
|
|
||||||
public Boolean screenshots;
|
|
||||||
/**
|
|
||||||
* specify custom categories to use instead of default.
|
|
||||||
*/
|
|
||||||
public List<String> categories;
|
|
||||||
|
|
||||||
public StartTracingOptions withPath(Path path) {
|
|
||||||
this.path = path;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public StartTracingOptions withScreenshots(Boolean screenshots) {
|
|
||||||
this.screenshots = screenshots;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public StartTracingOptions withCategories(List<String> categories) {
|
|
||||||
this.categories = categories;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Promise that resolves to the newly created browser
|
|
||||||
* session.
|
|
||||||
*/
|
|
||||||
CDPSession newBrowserCDPSession();
|
|
||||||
default void startTracing(Page page) {
|
|
||||||
startTracing(page, null);
|
|
||||||
}
|
|
||||||
default void startTracing() {
|
|
||||||
startTracing(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Only one trace can be active at a time per browser.
|
|
||||||
* @param page Optional, if specified, tracing includes screenshots of the given page.
|
|
||||||
*/
|
|
||||||
void startTracing(Page page, StartTracingOptions options);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Promise which resolves to buffer with trace data.
|
|
||||||
*/
|
|
||||||
byte[] stopTracing();
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chromium-specific features including background pages, service worker support, etc.
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
public interface ChromiumBrowserContext extends BrowserContext {
|
|
||||||
enum EventType {
|
|
||||||
BACKGROUNDPAGE,
|
|
||||||
SERVICEWORKER,
|
|
||||||
}
|
|
||||||
|
|
||||||
void addListener(EventType type, Listener<EventType> listener);
|
|
||||||
void removeListener(EventType type, Listener<EventType> listener);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return All existing background pages in the context.
|
|
||||||
*/
|
|
||||||
List<Page> backgroundPages();
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param page Page to create new session for.
|
|
||||||
* @return Promise that resolves to the newly created session.
|
|
||||||
*/
|
|
||||||
CDPSession newCDPSession(Page page);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return All existing service workers in the context.
|
|
||||||
*/
|
|
||||||
List<Worker> serviceWorkers();
|
|
||||||
}
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Coverage gathers information about parts of JavaScript and CSS that were used by the page.
|
|
||||||
*/
|
|
||||||
public interface ChromiumCoverage {
|
|
||||||
class StartCSSCoverageOptions {
|
|
||||||
/**
|
|
||||||
* Whether to reset coverage on every navigation. Defaults to {@code true}.
|
|
||||||
*/
|
|
||||||
public Boolean resetOnNavigation;
|
|
||||||
|
|
||||||
public StartCSSCoverageOptions withResetOnNavigation(Boolean resetOnNavigation) {
|
|
||||||
this.resetOnNavigation = resetOnNavigation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class StartJSCoverageOptions {
|
|
||||||
/**
|
|
||||||
* Whether to reset coverage on every navigation. Defaults to {@code true}.
|
|
||||||
*/
|
|
||||||
public Boolean resetOnNavigation;
|
|
||||||
/**
|
|
||||||
* Whether anonymous scripts generated by the page should be reported. Defaults to {@code false}.
|
|
||||||
*/
|
|
||||||
public Boolean reportAnonymousScripts;
|
|
||||||
|
|
||||||
public StartJSCoverageOptions withResetOnNavigation(Boolean resetOnNavigation) {
|
|
||||||
this.resetOnNavigation = resetOnNavigation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public StartJSCoverageOptions withReportAnonymousScripts(Boolean reportAnonymousScripts) {
|
|
||||||
this.reportAnonymousScripts = reportAnonymousScripts;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ChromiumCoverageStopCSSCoverage {
|
|
||||||
/**
|
|
||||||
* StyleSheet URL
|
|
||||||
*/
|
|
||||||
private String url;
|
|
||||||
/**
|
|
||||||
* StyleSheet content, if available.
|
|
||||||
*/
|
|
||||||
private String text;
|
|
||||||
/**
|
|
||||||
* StyleSheet ranges that were used. Ranges are sorted and non-overlapping.
|
|
||||||
*/
|
|
||||||
private List<Object> ranges;
|
|
||||||
|
|
||||||
public String url() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
public String text() {
|
|
||||||
return this.text;
|
|
||||||
}
|
|
||||||
public List<Object> ranges() {
|
|
||||||
return this.ranges;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ChromiumCoverageStopJSCoverage {
|
|
||||||
/**
|
|
||||||
* Script URL
|
|
||||||
*/
|
|
||||||
private String url;
|
|
||||||
/**
|
|
||||||
* Script ID
|
|
||||||
*/
|
|
||||||
private String scriptId;
|
|
||||||
/**
|
|
||||||
* Script content, if applicable.
|
|
||||||
*/
|
|
||||||
private String source;
|
|
||||||
/**
|
|
||||||
* V8-specific coverage format.
|
|
||||||
*/
|
|
||||||
private List<Object> functions;
|
|
||||||
|
|
||||||
public String url() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
public String scriptId() {
|
|
||||||
return this.scriptId;
|
|
||||||
}
|
|
||||||
public String source() {
|
|
||||||
return this.source;
|
|
||||||
}
|
|
||||||
public List<Object> functions() {
|
|
||||||
return this.functions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default void startCSSCoverage() {
|
|
||||||
startCSSCoverage(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param options Set of configurable options for coverage
|
|
||||||
* @return Promise that resolves when coverage is started
|
|
||||||
*/
|
|
||||||
void startCSSCoverage(StartCSSCoverageOptions options);
|
|
||||||
default void startJSCoverage() {
|
|
||||||
startJSCoverage(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <strong>NOTE</strong> Anonymous scripts are ones that don't have an associated url. These are scripts that are dynamically created on the page using {@code eval} or {@code new Function}. If {@code reportAnonymousScripts} is set to {@code true}, anonymous scripts will have {@code __playwright_evaluation_script__} as their URL.
|
|
||||||
* @param options Set of configurable options for coverage
|
|
||||||
* @return Promise that resolves when coverage is started
|
|
||||||
*/
|
|
||||||
void startJSCoverage(StartJSCoverageOptions options);
|
|
||||||
/**
|
|
||||||
* <strong>NOTE</strong> CSS Coverage doesn't include dynamically injected style tags without sourceURLs.
|
|
||||||
* @return Promise that resolves to the array of coverage reports for all stylesheets
|
|
||||||
*/
|
|
||||||
ChromiumCoverageStopCSSCoverage stopCSSCoverage();
|
|
||||||
/**
|
|
||||||
* <strong>NOTE</strong> JavaScript Coverage doesn't include anonymous scripts by default. However, scripts with sourceURLs are
|
|
||||||
* <p>
|
|
||||||
* reported.
|
|
||||||
* @return Promise that resolves to the array of coverage reports for all scripts
|
|
||||||
*/
|
|
||||||
ChromiumCoverageStopJSCoverage stopJSCoverage();
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Firefox browser instance does not expose Firefox-specific features.
|
|
||||||
*/
|
|
||||||
public interface FirefoxBrowser extends Browser {
|
|
||||||
}
|
|
||||||
|
|
@ -1503,7 +1503,6 @@ public interface Page {
|
|||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Returns frame matching the specified criteria. Either {@code name} or {@code url} must be specified.
|
* Returns frame matching the specified criteria. Either {@code name} or {@code url} must be specified.
|
||||||
* @param options Frame name or other frame lookup options.
|
|
||||||
* @return frame matching the criteria. Returns {@code null} if no frame matches.
|
* @return frame matching the criteria. Returns {@code null} if no frame matches.
|
||||||
*/
|
*/
|
||||||
Frame frameByUrl(Predicate<String> predicate);
|
Frame frameByUrl(Predicate<String> predicate);
|
||||||
@ -1976,7 +1975,6 @@ public interface Page {
|
|||||||
* <p>
|
* <p>
|
||||||
* is fired.
|
* is fired.
|
||||||
* @param event Event name, same one would pass into {@code page.on(event)}.
|
* @param event Event name, same one would pass into {@code page.on(event)}.
|
||||||
* @param optionsOrPredicate Either a predicate that receives an event or an options object.
|
|
||||||
* @return Promise which resolves to the event data value.
|
* @return Promise which resolves to the event data value.
|
||||||
*/
|
*/
|
||||||
Deferred<Event<EventType>> waitForEvent(EventType event, WaitForEventOptions options);
|
Deferred<Event<EventType>> waitForEvent(EventType event, WaitForEventOptions options);
|
||||||
@ -2082,10 +2080,6 @@ public interface Page {
|
|||||||
*/
|
*/
|
||||||
List<Worker> workers();
|
List<Worker> workers();
|
||||||
Accessibility accessibility();
|
Accessibility accessibility();
|
||||||
/**
|
|
||||||
* Browser-specific Coverage implementation, only available for Chromium atm. See ChromiumCoverage for more details.
|
|
||||||
*/
|
|
||||||
ChromiumCoverage coverage();
|
|
||||||
Keyboard keyboard();
|
Keyboard keyboard();
|
||||||
Mouse mouse();
|
Mouse mouse();
|
||||||
Touchscreen touchscreen();
|
Touchscreen touchscreen();
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WebKit browser instance does not expose WebKit-specific features.
|
|
||||||
*/
|
|
||||||
public interface WebKitBrowser extends Browser {
|
|
||||||
}
|
|
||||||
|
|
@ -287,11 +287,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
return browserContext;
|
return browserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChromiumCoverage coverage() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dblclick(String selector, DblclickOptions options) {
|
public void dblclick(String selector, DblclickOptions options) {
|
||||||
mainFrame.dblclick(selector, convertViaJson(options, Frame.DblclickOptions.class));
|
mainFrame.dblclick(selector, convertViaJson(options, Frame.DblclickOptions.class));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user