diff --git a/lib/src/main/java/com/microsoft/playwright/Accessibility.java b/lib/src/main/java/com/microsoft/playwright/Accessibility.java new file mode 100644 index 00000000..32e97d1b --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Accessibility.java @@ -0,0 +1,30 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Accessibility{ + + class SnapshotOptions { + Boolean interestingOnly; + ElementHandle root; + } + Object snapshot(SnapshotOptions options); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Browser.java b/lib/src/main/java/com/microsoft/playwright/Browser.java new file mode 100644 index 00000000..3573c05e --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Browser.java @@ -0,0 +1,82 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Browser{ + void close(); + List contexts(); + boolean isConnected(); + + class NewContextOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + BrowserContext newContext(NewContextOptions options); + + class NewPageOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + Page newPage(NewPageOptions options); + String version(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserContext.java b/lib/src/main/java/com/microsoft/playwright/BrowserContext.java new file mode 100644 index 00000000..d173b9fe --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -0,0 +1,63 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface BrowserContext{ + void close(); + void addCookies(List cookies); + + class AddInitScriptArg { + } + void addInitScript(String script, AddInitScriptArg arg); + Browser browser(); + void clearCookies(); + void clearPermissions(); + List cookies(String urls); + void exposeBinding(String name, String playwrightBinding); + void exposeFunction(String name, String playwrightFunction); + + class GrantPermissionsOptions { + String origin; + } + void grantPermissions(List permissions, GrantPermissionsOptions options); + Page newPage(); + List pages(); + void route(String url, BiConsumer handler); + void setDefaultNavigationTimeout(int timeout); + void setDefaultTimeout(int timeout); + void setExtraHTTPHeaders(Map headers); + + class SetGeolocationGeolocation { + Integer latitude; + Integer longitude; + Integer accuracy; + } + void setGeolocation(SetGeolocationGeolocation geolocation); + + class SetHTTPCredentialsHttpCredentials { + String username; + String password; + } + void setHTTPCredentials(SetHTTPCredentialsHttpCredentials httpCredentials); + void setOffline(boolean offline); + void unroute(String url, BiConsumer handler); + Object waitForEvent(String event, String optionsOrPredicate); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserServer.java b/lib/src/main/java/com/microsoft/playwright/BrowserServer.java new file mode 100644 index 00000000..6603122f --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/BrowserServer.java @@ -0,0 +1,28 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface BrowserServer{ + void close(); + void kill(); + Object process(); + String wsEndpoint(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/BrowserType.java b/lib/src/main/java/com/microsoft/playwright/BrowserType.java new file mode 100644 index 00000000..a32a348e --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/BrowserType.java @@ -0,0 +1,118 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface BrowserType{ + + class ConnectOptions { + String wsEndpoint; + Integer slowMo; + Logger logger; + Integer timeout; + } + Browser connect(ConnectOptions options); + String executablePath(); + + class LaunchOptions { + Boolean headless; + String executablePath; + List args; + Boolean ignoreDefaultArgs; + Object proxy; + String downloadsPath; + String artifactsPath; + Boolean chromiumSandbox; + Map firefoxUserPrefs; + Boolean handleSIGINT; + Boolean handleSIGTERM; + Boolean handleSIGHUP; + Logger logger; + Integer timeout; + Map env; + Boolean devtools; + Integer slowMo; + } + Browser launch(LaunchOptions options); + + class LaunchPersistentContextOptions { + Boolean headless; + String executablePath; + List args; + Boolean ignoreDefaultArgs; + Object proxy; + Boolean acceptDownloads; + String downloadsPath; + String artifactsPath; + Boolean chromiumSandbox; + Boolean handleSIGINT; + Boolean handleSIGTERM; + Boolean handleSIGHUP; + Logger logger; + Integer timeout; + Map env; + Boolean devtools; + Integer slowMo; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + BrowserContext launchPersistentContext(String userDataDir, LaunchPersistentContextOptions options); + + class LaunchServerOptions { + Boolean headless; + Integer port; + String executablePath; + List args; + Boolean ignoreDefaultArgs; + Object proxy; + String downloadsPath; + String artifactsPath; + Boolean chromiumSandbox; + Map firefoxUserPrefs; + Boolean handleSIGINT; + Boolean handleSIGTERM; + Boolean handleSIGHUP; + Logger logger; + Integer timeout; + Map env; + Boolean devtools; + } + BrowserServer launchServer(LaunchServerOptions options); + String name(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/CDPSession.java b/lib/src/main/java/com/microsoft/playwright/CDPSession.java new file mode 100644 index 00000000..88ec8444 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/CDPSession.java @@ -0,0 +1,29 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface CDPSession{ + void detach(); + + class SendParams { + } + Object send(String method, SendParams params); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java new file mode 100644 index 00000000..7da44827 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowser.java @@ -0,0 +1,91 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface ChromiumBrowser{ + CDPSession newBrowserCDPSession(); + + class StartTracingOptions { + String path; + Boolean screenshots; + List categories; + } + void startTracing(Page page, StartTracingOptions options); + byte[] stopTracing(); + void close(); + List contexts(); + boolean isConnected(); + + class NewContextOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + BrowserContext newContext(NewContextOptions options); + + class NewPageOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + Page newPage(NewPageOptions options); + String version(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java new file mode 100644 index 00000000..7aa1afa3 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumBrowserContext.java @@ -0,0 +1,66 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface ChromiumBrowserContext{ + List backgroundPages(); + CDPSession newCDPSession(Page page); + List serviceWorkers(); + void close(); + void addCookies(List cookies); + + class AddInitScriptArg { + } + void addInitScript(String script, AddInitScriptArg arg); + Browser browser(); + void clearCookies(); + void clearPermissions(); + List cookies(String urls); + void exposeBinding(String name, String playwrightBinding); + void exposeFunction(String name, String playwrightFunction); + + class GrantPermissionsOptions { + String origin; + } + void grantPermissions(List permissions, GrantPermissionsOptions options); + Page newPage(); + List pages(); + void route(String url, BiConsumer handler); + void setDefaultNavigationTimeout(int timeout); + void setDefaultTimeout(int timeout); + void setExtraHTTPHeaders(Map headers); + + class SetGeolocationGeolocation { + Integer latitude; + Integer longitude; + Integer accuracy; + } + void setGeolocation(SetGeolocationGeolocation geolocation); + + class SetHTTPCredentialsHttpCredentials { + String username; + String password; + } + void setHTTPCredentials(SetHTTPCredentialsHttpCredentials httpCredentials); + void setOffline(boolean offline); + void unroute(String url, BiConsumer handler); + Object waitForEvent(String event, String optionsOrPredicate); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java b/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java new file mode 100644 index 00000000..ecd52318 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/ChromiumCoverage.java @@ -0,0 +1,37 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface ChromiumCoverage{ + + class StartCSSCoverageOptions { + Boolean resetOnNavigation; + } + void startCSSCoverage(StartCSSCoverageOptions options); + + class StartJSCoverageOptions { + Boolean resetOnNavigation; + Boolean reportAnonymousScripts; + } + void startJSCoverage(StartJSCoverageOptions options); + List stopCSSCoverage(); + List stopJSCoverage(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java b/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java new file mode 100644 index 00000000..b678b715 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/ConsoleMessage.java @@ -0,0 +1,28 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface ConsoleMessage{ + List args(); + Object location(); + String text(); + String type(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Dialog.java b/lib/src/main/java/com/microsoft/playwright/Dialog.java new file mode 100644 index 00000000..56e36c63 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Dialog.java @@ -0,0 +1,29 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Dialog{ + void accept(String promptText); + String defaultValue(); + void dismiss(); + String message(); + String type(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Download.java b/lib/src/main/java/com/microsoft/playwright/Download.java new file mode 100644 index 00000000..5eb04fb6 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Download.java @@ -0,0 +1,31 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Download{ + Readable createReadStream(); + void delete(); + String failure(); + String path(); + void saveAs(String path); + String suggestedFilename(); + String url(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/ElementHandle.java b/lib/src/main/java/com/microsoft/playwright/ElementHandle.java new file mode 100644 index 00000000..32330a0d --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/ElementHandle.java @@ -0,0 +1,160 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface ElementHandle{ + ElementHandle querySelector(String selector); + List querySelectorAll(String selector); + Object evalOnSelector(String selector, String pageFunction, Object arg); + Object evalOnSelectorAll(String selector, String pageFunction, Object arg); + Object boundingBox(); + + class CheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void check(CheckOptions options); + + class ClickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void click(ClickOptions options); + Frame contentFrame(); + + class DblclickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void dblclick(DblclickOptions options); + void dispatchEvent(String type, Object eventInit); + + class FillOptions { + Boolean noWaitAfter; + Integer timeout; + } + void fill(String value, FillOptions options); + void focus(); + String getAttribute(String name); + + class HoverOptions { + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Integer timeout; + } + void hover(HoverOptions options); + String innerHTML(); + String innerText(); + Frame ownerFrame(); + + class PressOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void press(String key, PressOptions options); + + class ScreenshotOptions { + String path; + enum Type { JPEG, PNG } + Type type; + Integer quality; + Boolean omitBackground; + Integer timeout; + } + byte[] screenshot(ScreenshotOptions options); + + class ScrollIntoViewIfNeededOptions { + Integer timeout; + } + void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options); + + class SelectOptionOptions { + Boolean noWaitAfter; + Integer timeout; + } + List selectOption(String values, SelectOptionOptions options); + + class SelectTextOptions { + Integer timeout; + } + void selectText(SelectTextOptions options); + + class SetInputFilesOptions { + Boolean noWaitAfter; + Integer timeout; + } + void setInputFiles(String files, SetInputFilesOptions options); + String textContent(); + String toString(); + + class TypeOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void type(String text, TypeOptions options); + + class UncheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void uncheck(UncheckOptions options); + enum ElementState { DISABLED, ENABLED, HIDDEN, STABLE, VISIBLE } + + class WaitForElementStateOptions { + Integer timeout; + } + void waitForElementState(ElementState state, WaitForElementStateOptions options); + + class WaitForSelectorOptions { + enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE } + State state; + Integer timeout; + } + ElementHandle waitForSelector(String selector, WaitForSelectorOptions options); + ElementHandle asElement(); + void dispose(); + Object evaluate(String pageFunction, Object arg); + JSHandle evaluateHandle(String pageFunction, Object arg); + Map getProperties(); + JSHandle getProperty(String propertyName); + Object jsonValue(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/FileChooser.java b/lib/src/main/java/com/microsoft/playwright/FileChooser.java new file mode 100644 index 00000000..fe959dbb --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/FileChooser.java @@ -0,0 +1,33 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface FileChooser{ + ElementHandle element(); + boolean isMultiple(); + Page page(); + + class SetFilesOptions { + Boolean noWaitAfter; + Integer timeout; + } + void setFiles(String files, SetFilesOptions options); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java b/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java new file mode 100644 index 00000000..1e64c985 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/FirefoxBrowser.java @@ -0,0 +1,82 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface FirefoxBrowser{ + void close(); + List contexts(); + boolean isConnected(); + + class NewContextOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + BrowserContext newContext(NewContextOptions options); + + class NewPageOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + Page newPage(NewPageOptions options); + String version(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Frame.java b/lib/src/main/java/com/microsoft/playwright/Frame.java new file mode 100644 index 00000000..719493b2 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Frame.java @@ -0,0 +1,210 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Frame{ + ElementHandle querySelector(String selector); + List querySelectorAll(String selector); + Object evalOnSelector(String selector, String pageFunction, Object arg); + Object evalOnSelectorAll(String selector, String pageFunction, Object arg); + + class AddScriptTagOptions { + String url; + String path; + String content; + String type; + } + ElementHandle addScriptTag(AddScriptTagOptions options); + + class AddStyleTagOptions { + String url; + String path; + String content; + } + ElementHandle addStyleTag(AddStyleTagOptions options); + + class CheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void check(String selector, CheckOptions options); + List childFrames(); + + class ClickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void click(String selector, ClickOptions options); + String content(); + + class DblclickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void dblclick(String selector, DblclickOptions options); + + class DispatchEventOptions { + Integer timeout; + } + void dispatchEvent(String selector, String type, Object eventInit, DispatchEventOptions options); + Object evaluate(String pageFunction, Object arg); + JSHandle evaluateHandle(String pageFunction, Object arg); + + class FillOptions { + Boolean noWaitAfter; + Integer timeout; + } + void fill(String selector, String value, FillOptions options); + + class FocusOptions { + Integer timeout; + } + void focus(String selector, FocusOptions options); + ElementHandle frameElement(); + + class GetAttributeOptions { + Integer timeout; + } + String getAttribute(String selector, String name, GetAttributeOptions options); + + class GotoOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + String referer; + } + Response navigate(String url, GotoOptions options); + + class HoverOptions { + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Integer timeout; + } + void hover(String selector, HoverOptions options); + + class InnerHTMLOptions { + Integer timeout; + } + String innerHTML(String selector, InnerHTMLOptions options); + + class InnerTextOptions { + Integer timeout; + } + String innerText(String selector, InnerTextOptions options); + boolean isDetached(); + String name(); + Page page(); + Frame parentFrame(); + + class PressOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void press(String selector, String key, PressOptions options); + + class SelectOptionOptions { + Boolean noWaitAfter; + Integer timeout; + } + List selectOption(String selector, String values, SelectOptionOptions options); + + class SetContentOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + void setContent(String html, SetContentOptions options); + + class SetInputFilesOptions { + Boolean noWaitAfter; + Integer timeout; + } + void setInputFiles(String selector, String files, SetInputFilesOptions options); + + class TextContentOptions { + Integer timeout; + } + String textContent(String selector, TextContentOptions options); + String title(); + + class TypeOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void type(String selector, String text, TypeOptions options); + + class UncheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void uncheck(String selector, UncheckOptions options); + String url(); + + class WaitForFunctionOptions { + enum Polling { UMBE, RAF } + Polling polling; + Integer timeout; + } + JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunctionOptions options); + enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + + class WaitForLoadStateOptions { + Integer timeout; + } + void waitForLoadState(LoadState state, WaitForLoadStateOptions options); + + class WaitForNavigationOptions { + Integer timeout; + String url; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + Response waitForNavigation(WaitForNavigationOptions options); + + class WaitForSelectorOptions { + enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE } + State state; + Integer timeout; + } + ElementHandle waitForSelector(String selector, WaitForSelectorOptions options); + void waitForTimeout(int timeout); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/JSHandle.java b/lib/src/main/java/com/microsoft/playwright/JSHandle.java new file mode 100644 index 00000000..9fe5c09d --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/JSHandle.java @@ -0,0 +1,31 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface JSHandle{ + ElementHandle asElement(); + void dispose(); + Object evaluate(String pageFunction, Object arg); + JSHandle evaluateHandle(String pageFunction, Object arg); + Map getProperties(); + JSHandle getProperty(String propertyName); + Object jsonValue(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Keyboard.java b/lib/src/main/java/com/microsoft/playwright/Keyboard.java new file mode 100644 index 00000000..3257fcfe --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Keyboard.java @@ -0,0 +1,37 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Keyboard{ + void down(String key); + void insertText(String text); + + class PressOptions { + Integer delay; + } + void press(String key, PressOptions options); + + class TypeOptions { + Integer delay; + } + void type(String text, TypeOptions options); + void up(String key); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Logger.java b/lib/src/main/java/com/microsoft/playwright/Logger.java new file mode 100644 index 00000000..433fc8f3 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Logger.java @@ -0,0 +1,31 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Logger{ + enum Severity { ERROR, INFO, VERBOSE, WARNING } + boolean isEnabled(String name, Severity severity); + + class LogHints { + String color; + } + void log(String name, Severity severity, String message, List args, LogHints hints); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Mouse.java b/lib/src/main/java/com/microsoft/playwright/Mouse.java new file mode 100644 index 00000000..2d6dc170 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Mouse.java @@ -0,0 +1,58 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Mouse{ + + class ClickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + Integer delay; + } + void click(int x, int y, ClickOptions options); + + class DblclickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer delay; + } + void dblclick(int x, int y, DblclickOptions options); + + class DownOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + } + void down(DownOptions options); + + class MoveOptions { + Integer steps; + } + void move(int x, int y, MoveOptions options); + + class UpOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + } + void up(UpOptions options); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Page.java b/lib/src/main/java/com/microsoft/playwright/Page.java new file mode 100644 index 00000000..2c743f7a --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Page.java @@ -0,0 +1,304 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Page{ + + class CloseOptions { + Boolean runBeforeUnload; + } + void close(CloseOptions options); + ElementHandle querySelector(String selector); + List querySelectorAll(String selector); + Object evalOnSelector(String selector, String pageFunction, Object arg); + Object evalOnSelectorAll(String selector, String pageFunction, Object arg); + + class AddInitScriptArg { + } + void addInitScript(String script, AddInitScriptArg arg); + + class AddScriptTagOptions { + String url; + String path; + String content; + String type; + } + ElementHandle addScriptTag(AddScriptTagOptions options); + + class AddStyleTagOptions { + String url; + String path; + String content; + } + ElementHandle addStyleTag(AddStyleTagOptions options); + void bringToFront(); + + class CheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void check(String selector, CheckOptions options); + + class ClickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer clickCount; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void click(String selector, ClickOptions options); + String content(); + BrowserContext context(); + + class DblclickOptions { + enum Button { LEFT, MIDDLE, RIGHT } + Button button; + Integer delay; + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void dblclick(String selector, DblclickOptions options); + + class DispatchEventOptions { + Integer timeout; + } + void dispatchEvent(String selector, String type, Object eventInit, DispatchEventOptions options); + + class EmulateMediaOptions { + enum Media { PRINT, SCREEN } + Media media; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + } + void emulateMedia(EmulateMediaOptions options); + Object evaluate(String pageFunction, Object arg); + JSHandle evaluateHandle(String pageFunction, Object arg); + void exposeBinding(String name, String playwrightBinding); + void exposeFunction(String name, String playwrightFunction); + + class FillOptions { + Boolean noWaitAfter; + Integer timeout; + } + void fill(String selector, String value, FillOptions options); + + class FocusOptions { + Integer timeout; + } + void focus(String selector, FocusOptions options); + Frame frame(String options); + List frames(); + + class GetAttributeOptions { + Integer timeout; + } + String getAttribute(String selector, String name, GetAttributeOptions options); + + class GoBackOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + Response goBack(GoBackOptions options); + + class GoForwardOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + Response goForward(GoForwardOptions options); + + class GotoOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + String referer; + } + Response navigate(String url, GotoOptions options); + + class HoverOptions { + Object position; + enum Modifier { ALT, CONTROL, META, SHIFT } + Set modifiers; + Boolean force; + Integer timeout; + } + void hover(String selector, HoverOptions options); + + class InnerHTMLOptions { + Integer timeout; + } + String innerHTML(String selector, InnerHTMLOptions options); + + class InnerTextOptions { + Integer timeout; + } + String innerText(String selector, InnerTextOptions options); + boolean isClosed(); + Frame mainFrame(); + Page opener(); + + class PdfOptions { + String path; + Integer scale; + Boolean displayHeaderFooter; + String headerTemplate; + String footerTemplate; + Boolean printBackground; + Boolean landscape; + String pageRanges; + String format; + String width; + String height; + Object margin; + Boolean preferCSSPageSize; + } + byte[] pdf(PdfOptions options); + + class PressOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void press(String selector, String key, PressOptions options); + + class ReloadOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + Response reload(ReloadOptions options); + void route(String url, BiConsumer handler); + + class ScreenshotOptions { + String path; + enum Type { JPEG, PNG } + Type type; + Integer quality; + Boolean fullPage; + Object clip; + Boolean omitBackground; + Integer timeout; + } + byte[] screenshot(ScreenshotOptions options); + + class SelectOptionOptions { + Boolean noWaitAfter; + Integer timeout; + } + List selectOption(String selector, String values, SelectOptionOptions options); + + class SetContentOptions { + Integer timeout; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + void setContent(String html, SetContentOptions options); + void setDefaultNavigationTimeout(int timeout); + void setDefaultTimeout(int timeout); + void setExtraHTTPHeaders(Map headers); + + class SetInputFilesOptions { + Boolean noWaitAfter; + Integer timeout; + } + void setInputFiles(String selector, String files, SetInputFilesOptions options); + + class SetViewportSizeViewportSize { + Integer width; + Integer height; + } + void setViewportSize(SetViewportSizeViewportSize viewportSize); + + class TextContentOptions { + Integer timeout; + } + String textContent(String selector, TextContentOptions options); + String title(); + + class TypeOptions { + Integer delay; + Boolean noWaitAfter; + Integer timeout; + } + void type(String selector, String text, TypeOptions options); + + class UncheckOptions { + Boolean force; + Boolean noWaitAfter; + Integer timeout; + } + void uncheck(String selector, UncheckOptions options); + void unroute(String url, BiConsumer handler); + String url(); + Object viewportSize(); + Object waitForEvent(String event, String optionsOrPredicate); + + class WaitForFunctionOptions { + enum Polling { UMBE, RAF } + Polling polling; + Integer timeout; + } + JSHandle waitForFunction(String pageFunction, Object arg, WaitForFunctionOptions options); + enum LoadState { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + + class WaitForLoadStateOptions { + Integer timeout; + } + void waitForLoadState(LoadState state, WaitForLoadStateOptions options); + + class WaitForNavigationOptions { + Integer timeout; + String url; + enum WaitUntil { DOMCONTENTLOADED, LOAD, NETWORKIDLE } + WaitUntil waitUntil; + } + Response waitForNavigation(WaitForNavigationOptions options); + + class WaitForRequestOptions { + Integer timeout; + } + Request waitForRequest(String urlOrPredicate, WaitForRequestOptions options); + + class WaitForResponseOptions { + Integer timeout; + } + Response waitForResponse(String urlOrPredicate, WaitForResponseOptions options); + + class WaitForSelectorOptions { + enum State { ATTACHED, DETACHED, HIDDEN, VISIBLE } + State state; + Integer timeout; + } + ElementHandle waitForSelector(String selector, WaitForSelectorOptions options); + void waitForTimeout(int timeout); + List workers(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Request.java b/lib/src/main/java/com/microsoft/playwright/Request.java new file mode 100644 index 00000000..07abe607 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Request.java @@ -0,0 +1,37 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Request{ + Object failure(); + Frame frame(); + Map headers(); + boolean isNavigationRequest(); + String method(); + String postData(); + byte[] postDataBuffer(); + Object postDataJSON(); + Request redirectedFrom(); + Request redirectedTo(); + String resourceType(); + Response response(); + String url(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Response.java b/lib/src/main/java/com/microsoft/playwright/Response.java new file mode 100644 index 00000000..bb96ca1a --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Response.java @@ -0,0 +1,35 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Response{ + byte[] body(); + Error finished(); + Frame frame(); + Map headers(); + Object json(); + boolean ok(); + Request request(); + int status(); + String statusText(); + String text(); + String url(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Route.java b/lib/src/main/java/com/microsoft/playwright/Route.java new file mode 100644 index 00000000..162b8b95 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Route.java @@ -0,0 +1,42 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Route{ + void abort(String errorCode); + + class ContinueOverrides { + String method; + String postData; + Map headers; + } + void continue_(ContinueOverrides overrides); + + class FulfillResponse { + Integer status; + Map headers; + String contentType; + String body; + String path; + } + void fulfill(FulfillResponse response); + Request request(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Selectors.java b/lib/src/main/java/com/microsoft/playwright/Selectors.java new file mode 100644 index 00000000..78971448 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Selectors.java @@ -0,0 +1,29 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Selectors{ + + class RegisterOptions { + Boolean contentScript; + } + void register(String name, String script, RegisterOptions options); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/TimeoutError.java b/lib/src/main/java/com/microsoft/playwright/TimeoutError.java new file mode 100644 index 00000000..0e08f0a3 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/TimeoutError.java @@ -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.*; +import java.util.function.BiConsumer; + +interface TimeoutError{ +} + diff --git a/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java b/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java new file mode 100644 index 00000000..825f4841 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/WebKitBrowser.java @@ -0,0 +1,82 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface WebKitBrowser{ + void close(); + List contexts(); + boolean isConnected(); + + class NewContextOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + BrowserContext newContext(NewContextOptions options); + + class NewPageOptions { + Boolean acceptDownloads; + Boolean ignoreHTTPSErrors; + Boolean bypassCSP; + Object viewport; + String userAgent; + Integer deviceScaleFactor; + Boolean isMobile; + Boolean hasTouch; + Boolean javaScriptEnabled; + String timezoneId; + Object geolocation; + String locale; + List permissions; + Map extraHTTPHeaders; + Boolean offline; + Object httpCredentials; + enum ColorScheme { DARK, LIGHT, NO_PREFERENCE } + ColorScheme colorScheme; + Logger logger; + String relativeArtifactsPath; + Boolean recordVideos; + Object videoSize; + Boolean recordTrace; + } + Page newPage(NewPageOptions options); + String version(); +} + diff --git a/lib/src/main/java/com/microsoft/playwright/Worker.java b/lib/src/main/java/com/microsoft/playwright/Worker.java new file mode 100644 index 00000000..e4a167c8 --- /dev/null +++ b/lib/src/main/java/com/microsoft/playwright/Worker.java @@ -0,0 +1,27 @@ +/** + * 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.*; +import java.util.function.BiConsumer; + +interface Worker{ + Object evaluate(String pageFunction, Object arg); + JSHandle evaluateHandle(String pageFunction, Object arg); + String url(); +} +