2021-03-03 13:13:59 -08:00
|
|
|
## method: Page.onceDialog
|
|
|
|
* langs: java
|
|
|
|
|
|
|
|
Adds one-off [Dialog] handler. The handler will be removed immediately after next [Dialog] is created.
|
|
|
|
```java
|
|
|
|
page.onceDialog(dialog -> {
|
|
|
|
dialog.accept("foo");
|
|
|
|
});
|
|
|
|
|
|
|
|
// prints 'foo'
|
|
|
|
System.out.println(page.evaluate("prompt('Enter string:')"));
|
|
|
|
|
|
|
|
// prints 'null' as the dialog will be auto-dismissed because there are no handlers.
|
|
|
|
System.out.println(page.evaluate("prompt('Enter string:')"));
|
|
|
|
```
|
|
|
|
|
|
|
|
This code above is equivalent to:
|
|
|
|
```java
|
|
|
|
Consumer<Dialog> handler = new Consumer<Dialog>() {
|
|
|
|
@Override
|
|
|
|
public void accept(Dialog dialog) {
|
|
|
|
dialog.accept("foo");
|
|
|
|
page.offDialog(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
page.onDialog(handler);
|
|
|
|
|
|
|
|
// prints 'foo'
|
|
|
|
System.out.println(page.evaluate("prompt('Enter string:')"));
|
|
|
|
|
|
|
|
// prints 'null' as the dialog will be auto-dismissed because there are no handlers.
|
|
|
|
System.out.println(page.evaluate("prompt('Enter string:')"));
|
|
|
|
```
|
|
|
|
|
|
|
|
### param: Page.onceDialog.handler
|
|
|
|
- `handler` <[function]\([Dialog]\)>
|
|
|
|
|
|
|
|
Receives the [Dialog] object, it **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise
|
|
|
|
the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog,
|
|
|
|
and actions like click will never finish.
|
|
|
|
|
2021-02-01 12:05:01 -08:00
|
|
|
## method: Playwright.close
|
|
|
|
* langs: java
|
|
|
|
|
2021-02-02 10:46:36 -08:00
|
|
|
Terminates this instance of Playwright, will also close all created browsers if they are still running.
|
|
|
|
|
2021-02-23 16:43:37 -08:00
|
|
|
## method: Playwright.create
|
|
|
|
* langs: java
|
|
|
|
- returns: <[Playwright]>
|
|
|
|
|
|
|
|
Launches new Playwright driver process and connects to it. [`method: Playwright.close`] should be called when the instance is no longer needed.
|
|
|
|
|
|
|
|
```java
|
|
|
|
Playwright playwright = Playwright.create()) {
|
|
|
|
Browser browser = playwright.webkit().launch();
|
|
|
|
Page page = browser.newPage();
|
|
|
|
page.navigate("https://www.w3.org/");
|
|
|
|
playwright.close();
|
|
|
|
```
|
|
|
|
|
2021-02-04 21:15:14 -08:00
|
|
|
### param: BrowserContext.waitForPage.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
2021-02-12 09:15:18 -08:00
|
|
|
### param: Frame.waitForNavigation.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
2021-02-04 21:15:14 -08:00
|
|
|
### param: Page.waitForClose.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForDownload.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForFileChooser.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForPopup.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForRequest.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForResponse.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
2021-02-12 09:15:18 -08:00
|
|
|
### param: Page.waitForNavigation.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
2021-02-04 21:15:14 -08:00
|
|
|
### param: Page.waitForWebSocket.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Page.waitForWorker.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: WebSocket.waitForFrameReceived.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: WebSocket.waitForFrameSent.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
|
|
|
### param: Worker.waitForClose.callback = %%-java-wait-for-event-callback-%%
|
|
|
|
|
2021-02-02 10:46:36 -08:00
|
|
|
### option: BrowserType.launch.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
|
|
|
|
### option: BrowserType.launchPersistentContext.ignoreDefaultArgs = %%-csharp-java-browser-option-ignoredefaultargs-%%
|
|
|
|
### option: BrowserType.launch.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%
|
|
|
|
### option: BrowserType.launchPersistentContext.ignoreAllDefaultArgs = %%-csharp-java-browser-option-ignorealldefaultargs-%%
|