Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66dd81777b |
@@ -75,7 +75,7 @@ extends:
|
|||||||
targetPath: $(Build.ArtifactStagingDirectory)/esrp-build
|
targetPath: $(Build.ArtifactStagingDirectory)/esrp-build
|
||||||
steps:
|
steps:
|
||||||
- checkout: none
|
- checkout: none
|
||||||
- task: EsrpRelease@11
|
- task: EsrpRelease@9
|
||||||
inputs:
|
inputs:
|
||||||
connectedservicename: 'Playwright-ESRP-PME'
|
connectedservicename: 'Playwright-ESRP-PME'
|
||||||
usemanagedidentity: true
|
usemanagedidentity: true
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
---
|
|
||||||
name: playwright-java-release
|
|
||||||
description: Prepare a Playwright Java release after the rolling PR has merged — cut the release branch, mark the Maven version, draft the GitHub release, and tick the Java boxes in the internal checklist.
|
|
||||||
---
|
|
||||||
|
|
||||||
Use this skill once the `chore: roll driver to 1.X.0` PR has merged into `main` and the upstream JS `v1.X.0` is published. The rolling work itself is covered by the [[playwright-roll]] skill.
|
|
||||||
|
|
||||||
Throughout this doc, replace `X` with the minor version (e.g. `60` for `1.60.0`) and `<user>` with the fork owner (`gh api user --jq .login`).
|
|
||||||
|
|
||||||
The full release checklist lives in the private `microsoft/playwright-internal` repo as the `v1.X checklist` issue. Find its number once:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
unset GITHUB_TOKEN
|
|
||||||
ISSUE=$(gh search issues --repo microsoft/playwright-internal "v1.X checklist" --json number --jq '.[0].number')
|
|
||||||
```
|
|
||||||
|
|
||||||
Tick each Java box incrementally (one PATCH per item) so the issue reflects accurate state if the flow is interrupted:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gh api repos/microsoft/playwright-internal/issues/$ISSUE --jq '.body' > /tmp/body.md
|
|
||||||
# edit /tmp/body.md to flip "- [ ]" → "- [x]" on the relevant Java item
|
|
||||||
gh api repos/microsoft/playwright-internal/issues/$ISSUE -X PATCH --field body=@/tmp/body.md
|
|
||||||
```
|
|
||||||
|
|
||||||
## 1. Cut the release branch
|
|
||||||
|
|
||||||
Push `release-1.X` from current `upstream/main` (which now contains the merged roll commit):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git fetch upstream main
|
|
||||||
git push upstream upstream/main:refs/heads/release-1.X
|
|
||||||
```
|
|
||||||
|
|
||||||
## 2. Draft the GitHub release
|
|
||||||
|
|
||||||
Generate the release notes from the upstream docs:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ~/playwright
|
|
||||||
node utils/render_release_notes.mjs java 1.X > /tmp/v1.X.0-release-notes.md
|
|
||||||
```
|
|
||||||
|
|
||||||
The renderer leaves JS-isms that need fixing for Java. Apply these substitutions — the list is not exhaustive, eyeball the diff before publishing:
|
|
||||||
|
|
||||||
- `toMatchAriaSnapshot()` → `matchesAriaSnapshot()`
|
|
||||||
- `toHaveCSS()` → `hasCSS()` (and other `toHaveX` matchers → `hasX`)
|
|
||||||
- `browser.on('context')` → `browser.onContext()`
|
|
||||||
- `browserContext.on('download' | 'frameattached' | ...)` → `browserContext.onDownload()` / `onFrameAttached()` / …
|
|
||||||
|
|
||||||
Create the draft directly against `release-1.X` — drafting against `main` and retargeting later is fragile because every `gh release edit` rotates the `untagged-<hash>` ID:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
gh release create v1.X.0 --repo microsoft/playwright-java --draft \
|
|
||||||
--title "v1.X.0" --notes-file /tmp/v1.X.0-release-notes.md --target release-1.X
|
|
||||||
```
|
|
||||||
|
|
||||||
## 3. Bump the Maven version on the release branch
|
|
||||||
|
|
||||||
Cut `mark-v-1.X.0` off `upstream/release-1.X`, run `set_maven_version.sh`, and PR back to the release branch:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git checkout -b mark-v-1.X.0 upstream/release-1.X
|
|
||||||
./scripts/set_maven_version.sh 1.X.0
|
|
||||||
git add -u
|
|
||||||
git commit -m "chore: mark 1.X.0"
|
|
||||||
git push -u origin mark-v-1.X.0
|
|
||||||
gh pr create --repo microsoft/playwright-java --head <user>:mark-v-1.X.0 --base release-1.X \
|
|
||||||
--title "chore: mark 1.X.0" \
|
|
||||||
--body "Updates Maven version in all modules to \`1.X.0\` for the v1.X release."
|
|
||||||
```
|
|
||||||
|
|
||||||
`set_maven_version.sh` only invokes `mvn versions:set` on `pom.xml`, `tools/*/pom.xml`, and `examples/pom.xml`, but the root invocation cascades through the reactor, so the expected diff is 11 poms: root + `driver/` + `driver-bundle/` + `playwright/` (from the reactor cascade) + 6 under `tools/` + `examples/`, all flipping `1.<prev>.0-SNAPSHOT` → `1.X.0`. Any other file in the diff is a red flag.
|
|
||||||
|
|
||||||
## 4. Publish
|
|
||||||
|
|
||||||
The user publishes the draft release manually once the `mark-v-1.X.0` PR is merged. After publishing, CI pushes the artifacts to Maven Central and runs the Docker workflow automatically: https://github.com/microsoft/playwright-java/actions.
|
|
||||||
@@ -6,161 +6,17 @@ description: Roll Playwright Java to a new version
|
|||||||
Help the user roll to a new version of Playwright.
|
Help the user roll to a new version of Playwright.
|
||||||
ROLLING.md contains general instructions and scripts.
|
ROLLING.md contains general instructions and scripts.
|
||||||
|
|
||||||
Start with running ./scripts/roll_driver.sh to update the version and generate the API to see the state of things.
|
Start with updating the version and generating the API to see the state of things.
|
||||||
Afterwards, walk through the upstream changes that affect the Java client and port the relevant ones.
|
Afterwards, work through the list of changes that need to be backported.
|
||||||
|
You can find a list of pull requests that might need to be taking into account in the issue titled "Backport changes".
|
||||||
## Determining what to port
|
Work through them one-by-one and check off the items that you have handled.
|
||||||
|
Not all of them will be relevant, some might have partially been reverted, etc. - so feel free to check with the upstream release branch.
|
||||||
List the upstream commits that touched a client-relevant path since the last release. The paths cover everything that can change the public Java surface or the wire protocol:
|
|
||||||
|
|
||||||
- `docs/src/api/` — the source of truth for `api.json`. Method/option additions, removals, and `langs:` filter changes flow from here.
|
|
||||||
- `packages/playwright-core/src/client/` — the JS client implementation that the Java client mirrors.
|
|
||||||
- `packages/isomorphic/` — selector engines, locator generation/parsing, and aria-snapshot logic shared between client and server. Changes here can affect client-side helpers like `getByRoleSelector`.
|
|
||||||
- `packages/playwright/src/matchers/matchers.ts` — assertion-method definitions. Changes here usually correspond to new options on `LocatorAssertions` / `PageAssertions`.
|
|
||||||
- `packages/protocol/src/protocol.yml` — the wire protocol schema. Method/event additions, parameter renames, and result-shape changes affect what the Java `*Impl` classes need to send/receive.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ~/playwright
|
|
||||||
PREV_TAG=$(git tag | grep -E '^v1\.[0-9]+\.[0-9]+$' | sort -V | tail -1) # e.g. v1.59.1
|
|
||||||
git log "$PREV_TAG"..HEAD --oneline -- \
|
|
||||||
'docs/src/api/' \
|
|
||||||
'packages/playwright-core/src/client/' \
|
|
||||||
'packages/isomorphic/' \
|
|
||||||
'packages/playwright/src/matchers/matchers.ts' \
|
|
||||||
'packages/protocol/src/protocol.yml'
|
|
||||||
```
|
|
||||||
|
|
||||||
Walk that list top-to-bottom (oldest-first is easier — newest is at top, so reverse). For each commit:
|
|
||||||
1. Read the commit (`git show <sha>`) to see what client/protocol/docs changed.
|
|
||||||
2. If it's JS-internal (bundling, dispatcher conventions, electron, mcp, dashboard, trace-viewer, test-runner) — skip.
|
|
||||||
3. If it touches `docs/src/api/` or types, check `langs:` annotations — features marked `langs: js`/`langs: js, python` don't apply to Java.
|
|
||||||
4. If it adds/changes a public API method or option that applies to Java, port it. The api.json regenerated by `roll_driver.sh` already contains the new types/options, so the generated Java interfaces usually pick them up automatically — what's typically missing is the `*Impl` wiring.
|
|
||||||
5. Watch for follow-up reverts — a "feat: X" commit might be undone by a later "Revert X". Check whether the change still exists in HEAD before porting.
|
|
||||||
6. Maintain a running notes file (e.g. `/tmp/roll-notes.md`) listing each upstream PR as ported / skipped / verified-already-supported, with a one-line reason. This file becomes the body of the eventual PR.
|
|
||||||
|
|
||||||
## What to include in the rolling PR
|
|
||||||
|
|
||||||
- Driver version bump
|
|
||||||
- Generated interface diffs from `roll_driver.sh`
|
|
||||||
- `*Impl` wiring for each ported feature
|
|
||||||
- Generator updates (import lists, special-cases) if new types appeared
|
|
||||||
- A small test per new public API surface — listener for new events, basic call for new methods, regression for changed return types
|
|
||||||
- PR description: list each upstream PR ported, each skipped (with reason), and each verified-already-supported
|
|
||||||
|
|
||||||
Rolling includes:
|
Rolling includes:
|
||||||
- updating client implementation to match changes in the upstream JS implementation (see ../playwright/packages/playwright-core/src/client)
|
- updating client implementation to match changes in the upstream JS implementation (see ../playwright/packages/playwright-core/src/client)
|
||||||
- adding a couple of new tests to verify new/changed functionality
|
- adding a couple of new tests to verify new/changed functionality
|
||||||
|
|
||||||
## Mimicking the JavaScript implementation
|
## Tips & Tricks
|
||||||
|
- Project checkouts are in the parent directory (`../`).
|
||||||
The Java client is a port of the JS client in `../playwright/packages/playwright-core/src/client/`. When implementing a new or changed method, always read the corresponding JS file first and mirror its logic:
|
- When updating checkboxes, store the issue content into /tmp and edit it there, then update the issue based on the file
|
||||||
|
- use the "gh" cli to interact with GitHub
|
||||||
```
|
|
||||||
../playwright/packages/playwright-core/src/client/browserContext.ts
|
|
||||||
../playwright/packages/playwright-core/src/client/page.ts
|
|
||||||
../playwright/packages/playwright-core/src/client/tracing.ts
|
|
||||||
../playwright/packages/playwright-core/src/client/video.ts
|
|
||||||
../playwright/packages/playwright-core/src/client/locator.ts
|
|
||||||
../playwright/packages/playwright-core/src/client/network.ts
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
Key translation rules:
|
|
||||||
|
|
||||||
**Protocol calls** — `await this._channel.methodName(params)` → `sendMessage("methodName", params, NO_TIMEOUT)`
|
|
||||||
|
|
||||||
**Extracting a returned channel object from a result** — JS uses `SomeClass.from(result.foo)` which resolves the JS-side object for a channel reference. In Java, the object was already created when the server sent `__create__`, so extract it from the connection: `connection.getExistingObject(result.getAsJsonObject("foo").get("guid").getAsString())`
|
|
||||||
|
|
||||||
**Async/await** — all `await` calls become synchronous `sendMessage(...)` calls since the Java client is synchronous.
|
|
||||||
|
|
||||||
**`undefined` / optional params** — JS `options?.foo` checks translate to `if (options != null && options.foo != null)` null checks before adding to the params `JsonObject`.
|
|
||||||
|
|
||||||
**`_channel` fields** — the JS `this._channel.foo` maps to calling `sendMessage("foo", ...)` on `this` in the Impl class.
|
|
||||||
|
|
||||||
**Channel object references in params** — when a JS call passes a channel object as a param (e.g. `{ frame: frame._channel }`), in Java pass the guid: `params.addProperty("frame", ((FrameImpl) frame).guid)`.
|
|
||||||
|
|
||||||
## Fixing generator and compilation errors
|
|
||||||
|
|
||||||
After running `./scripts/roll_driver.sh`, the build often fails because the generated Java interfaces reference new types or methods that the generator doesn't know how to handle yet, and the `*Impl` classes don't implement new interface methods.
|
|
||||||
|
|
||||||
### ApiGenerator.java fixes (tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java)
|
|
||||||
|
|
||||||
The generator has hardcoded lists that control which imports are added to each generated file. When new classes appear in the API, add them to the relevant lists in `Interface.writeTo`:
|
|
||||||
- `options.*` import list — add new classes that use types from the options package
|
|
||||||
- `java.util.*` import list — add new classes that use `List`, `Map`, etc.
|
|
||||||
- `java.util.function.Consumer` list — add new classes with `Consumer`-typed event handlers
|
|
||||||
|
|
||||||
Type mapping: when JS-only types (like `Disposable`) are used as return types in Java-compatible methods, add a mapping in `convertBuiltinType`. For example, `Disposable` → `AutoCloseable`.
|
|
||||||
|
|
||||||
Event handler generation: events with `void` type generate invalid `Consumer<void>`. Handle this case in `Event.writeListenerMethods` by emitting `Runnable` instead.
|
|
||||||
|
|
||||||
After editing the generator, recompile and re-run it:
|
|
||||||
```
|
|
||||||
mvn -f tools/api-generator/pom.xml compile -q
|
|
||||||
mvn -f tools/api-generator/pom.xml exec:java -Dexec.mainClass=com.microsoft.playwright.tools.ApiGenerator
|
|
||||||
```
|
|
||||||
|
|
||||||
### Impl class fixes (playwright/src/main/java/com/microsoft/playwright/impl/)
|
|
||||||
|
|
||||||
After regenerating, compile `playwright/` to find what's missing:
|
|
||||||
```
|
|
||||||
mvn -f playwright/pom.xml compile 2>&1 | grep "ERROR"
|
|
||||||
```
|
|
||||||
|
|
||||||
Common patterns:
|
|
||||||
|
|
||||||
**Return type changed (e.g. `void` → `AutoCloseable`):** Update the method signature in the Impl class and return an appropriate `AutoCloseable`. Check the JS client to see what kind of disposable is used:
|
|
||||||
- If JS returns `DisposableObject.from(result.disposable)` — the server created a disposable channel object. Extract its guid from the protocol result and return `connection.getExistingObject(guid)` (a `DisposableObject`).
|
|
||||||
- If JS returns `new DisposableStub(() => this.someCleanup())` — it's a local callback. Return `new DisposableStub(this::someCleanup)` in Java.
|
|
||||||
- Examples: `addInitScript`/`exposeBinding`/`exposeFunction` → `DisposableObject`; `route(...)` → `DisposableStub(() -> unroute(...))`; `Tracing.group` → `DisposableStub(this::groupEnd)`; `Video.start` → `DisposableStub(this::stop)`.
|
|
||||||
|
|
||||||
**New method missing:** Add a stub implementation. Common patterns:
|
|
||||||
- Simple protocol message: `sendMessage("methodName", params, NO_TIMEOUT)`
|
|
||||||
- New property accessor (e.g. from initializer): `return initializer.get("fieldName").getAsString()`
|
|
||||||
- Delegation to mainFrame (for Page methods): `return mainFrame.locator(":root").method(...)`
|
|
||||||
|
|
||||||
**New interface entirely (e.g. `Debugger`):** Create a new `*Impl` class extending `ChannelOwner`, implement the interface, and register the type in `Connection.java`'s switch statement. Initialize the field from the parent's initializer in the parent's constructor (e.g. `connection.getExistingObject(initializer.getAsJsonObject("debugger").get("guid").getAsString())`).
|
|
||||||
|
|
||||||
**Field visibility:** If a field needs to be accessed from a sibling Impl class (e.g. setting `existingResponse` on `RequestImpl` from `BrowserContextImpl`), change it from `private` to package-private.
|
|
||||||
|
|
||||||
**`ListenerCollection` only supports `Consumer<T>`, not `Runnable`.** For void events that use `Runnable` handlers, maintain a plain `List<Runnable>` instead.
|
|
||||||
|
|
||||||
**Protocol changes that remove events** — when a method's response now returns an object directly instead of via a subsequent event, update the Impl to capture it from the `sendMessage` result and remove the old event handler. Example: `videoStart` used to fire a `"video"` page event to deliver the artifact; it now returns the artifact directly in the response. Check git history of the upstream JS client when tests hang unexpectedly.
|
|
||||||
|
|
||||||
**Protocol parameter renames** — protocol parameter names can change between versions (e.g. `wsEndpoint` → `endpoint` in `BrowserType.connect`). When a test fails with `expected string, got undefined` or similar validation errors from the driver, check `packages/protocol/src/protocol.yml` for the current parameter names and update the corresponding `params.addProperty(...)` call in the Impl class. Also check the JS client (`src/client/`) to see how it builds the params object.
|
|
||||||
|
|
||||||
## Rebuilding the driver-bundle after a roll
|
|
||||||
|
|
||||||
`./scripts/roll_driver.sh` does the whole roll pipeline end-to-end: bumps `DRIVER_VERSION`, downloads new driver files into `driver-bundle/src/main/resources/driver/<platform>/`, regenerates `api.json` and the Java interfaces, and updates the README. When all of that succeeds, the next `mvn` invocation that touches `driver-bundle` will pick up the new files and you don't need to think about it.
|
|
||||||
|
|
||||||
But if any step in the pipeline fails (the very common case is the API generator throwing on a new type — see *Fixing generator and compilation errors*), the run aborts before `driver-bundle/target/classes/` has been refreshed. From that point on, until you manually rebuild `driver-bundle`, the test JVM will load the **old** driver from the cached `target/classes`/installed jar even though the source resources have already been swapped to the new version.
|
|
||||||
|
|
||||||
Fix — rebuild `driver-bundle` once before re-running tests:
|
|
||||||
```
|
|
||||||
mvn -f driver-bundle/pom.xml install -DskipTests
|
|
||||||
```
|
|
||||||
|
|
||||||
## Porting and verifying tests
|
|
||||||
|
|
||||||
**Before porting an upstream test file, check the API exists in Java.** The upstream repo may have test files for brand-new APIs that haven't been added to the Java interface yet (e.g., `screencast.spec.ts` tests `page.screencast` which may not be in the generated `Page.java`). Check `git diff main --name-only` to see what interfaces were added this roll, and verify the method exists in the generated Java interface before porting.
|
|
||||||
|
|
||||||
**Java test file names don't always match upstream spec names.** `TestScreencast.java` tests `recordVideo` video-file recording (which corresponds to `video.spec.ts`), not the newer `page.screencast` streaming API (`screencast.spec.ts`). When comparing coverage, check test *content*, not just file names.
|
|
||||||
|
|
||||||
**Remove tests for behavior that was removed upstream.** When the JS client drops a client-side error check (e.g., "Page is not yet closed before saveAs", "Page did not produce any video frames"), delete the corresponding Java tests rather than trying to keep them passing. Check the upstream `tests/library/` spec to confirm the behavior is gone.
|
|
||||||
|
|
||||||
**Run the full suite to catch regressions, re-run flaky failures in isolation.** Some tests (e.g., `TestClientCertificates#shouldKeepSupportingHttp`) time out only under heavy parallel load. Run the failing test alone to confirm it's flaky before investigating further.
|
|
||||||
|
|
||||||
## Diagnosing hanging tests
|
|
||||||
|
|
||||||
When `mvn test` hangs and surefire eventually times the JVM out, it writes thread dumps to `playwright/target/surefire-reports/<timestamp>-jvmRun*.dump`. To find the stuck test:
|
|
||||||
|
|
||||||
```
|
|
||||||
grep "com.microsoft.playwright.Test" playwright/target/surefire-reports/*-jvmRun1.dump | sort -u
|
|
||||||
```
|
|
||||||
|
|
||||||
Each line is a stack frame inside a test method — typically you'll see one or two test methods blocked on a `Future.get()`, `waitForCondition`, or similar. That's the hanging test.
|
|
||||||
|
|
||||||
When you've identified a hanging test:
|
|
||||||
1. Run it in isolation: `mvn -f playwright/pom.xml test -Dtest='TestClass#testMethod'`. If it passes alone, it's a parallel-load flake — note it but move on.
|
|
||||||
2. If it still hangs in isolation, look for a recent fix in the upstream repo for the *same* test name. Use `git log --oneline tests/library/<spec>.spec.ts` in `~/playwright`. Upstream fixes for client-side hangs are often small and portable (e.g. `about:blank` → `server.EMPTY_PAGE` from microsoft/playwright#39840 fixed `route-web-socket.spec.ts` arraybuffer hangs — apparently some browser changed the WebSocket origin policy on `about:blank`).
|
|
||||||
3. When porting an upstream fix, mirror the helper signature change rather than hard-coding workarounds. E.g. if upstream added a `server` parameter to `setupWS`, do the same in Java by injecting `Server server` via the JUnit fixture (`@FixtureTest` already wires up `ServerLifecycle`, so adding `Server server` to the test method signature is enough — no class-level boilerplate). Watch for local-variable shadowing when you add a `Server server` parameter to a method that already has a `WebSocketRoute server` local; rename the local.
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ jobs:
|
|||||||
environment: Docker
|
environment: Docker
|
||||||
if: github.repository == 'microsoft/playwright-java'
|
if: github.repository == 'microsoft/playwright-java'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Azure login
|
- name: Azure login
|
||||||
uses: azure/login@v3
|
uses: azure/login@v2
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.AZURE_DOCKER_CLIENT_ID }}
|
client-id: ${{ secrets.AZURE_DOCKER_CLIENT_ID }}
|
||||||
tenant-id: ${{ secrets.AZURE_DOCKER_TENANT_ID }}
|
tenant-id: ${{ secrets.AZURE_DOCKER_TENANT_ID }}
|
||||||
@@ -23,8 +23,8 @@ jobs:
|
|||||||
- name: Login to ACR via OIDC
|
- name: Login to ACR via OIDC
|
||||||
run: az acr login --name playwright
|
run: az acr login --name playwright
|
||||||
- name: Set up Docker QEMU for arm64 docker builds
|
- name: Set up Docker QEMU for arm64 docker builds
|
||||||
uses: docker/setup-qemu-action@v4
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: arm64
|
platforms: arm64
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- run: ./utils/docker/publish_docker.sh stable
|
- run: ./utils/docker/publish_docker.sh stable
|
||||||
|
|||||||
@@ -18,17 +18,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
browser: [chromium, firefox, webkit]
|
browser: [chromium, firefox, webkit]
|
||||||
exclude:
|
|
||||||
# macos-latest is the free M1 runner (3 vCPU / 7 GB); WebKit needs more headroom.
|
|
||||||
# Upstream's webkit matrix runs on macos-15-xlarge for the same reason.
|
|
||||||
- os: macos-latest
|
|
||||||
browser: webkit
|
|
||||||
include:
|
|
||||||
- os: macos-15-xlarge
|
|
||||||
browser: webkit
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Set up JDK 1.8
|
- name: Set up JDK 1.8
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
@@ -73,7 +65,7 @@ jobs:
|
|||||||
browser-channel: msedge
|
browser-channel: msedge
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Install Media Pack
|
- name: Install Media Pack
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -108,7 +100,7 @@ jobs:
|
|||||||
browser: [chromium, firefox, webkit]
|
browser: [chromium, firefox, webkit]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v6
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|||||||
@@ -26,51 +26,26 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
flavor: [jammy, noble, resolute]
|
flavor: [jammy, noble]
|
||||||
runs-on: [ubuntu-24.04, ubuntu-24.04-arm]
|
runs-on: [ubuntu-24.04, ubuntu-24.04-arm]
|
||||||
include:
|
|
||||||
- runs-on: ubuntu-24.04
|
|
||||||
arch: amd64
|
|
||||||
- runs-on: ubuntu-24.04-arm
|
|
||||||
arch: arm64
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
bash utils/docker/build.sh --${{ matrix.arch }} ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
|
ARCH="${{ matrix.runs-on == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}"
|
||||||
|
bash utils/docker/build.sh --$ARCH ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
|
||||||
- name: Start container
|
- name: Start container
|
||||||
run: |
|
run: |
|
||||||
CONTAINER_ID=$(docker run \
|
CONTAINER_ID=$(docker run --rm -e CI -e PW_MAX_RETRIES --ipc=host -v "$(pwd)":/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)
|
||||||
--rm \
|
|
||||||
--name playwright-docker-test \
|
|
||||||
--platform linux/${{ matrix.arch }} \
|
|
||||||
--user=pwuser \
|
|
||||||
--workdir /home/pwuser \
|
|
||||||
--shm-size=2g \
|
|
||||||
-e CI \
|
|
||||||
-e PW_MAX_RETRIES \
|
|
||||||
-d -t \
|
|
||||||
playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)
|
|
||||||
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
|
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Copy repository inside docker container
|
- name: Run test in container
|
||||||
run: |
|
run: |
|
||||||
docker cp . "$CONTAINER_ID":/home/pwuser/playwright
|
docker exec "$CONTAINER_ID" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
|
||||||
# /root/.m2 was populated as root during image build; move it to
|
|
||||||
# pwuser so the locally-installed SNAPSHOT artifacts resolve.
|
|
||||||
docker exec --user root "$CONTAINER_ID" bash -c '
|
|
||||||
chown -R pwuser /home/pwuser/playwright
|
|
||||||
mv /root/.m2 /home/pwuser/.m2
|
|
||||||
chown -R pwuser /home/pwuser/.m2
|
|
||||||
'
|
|
||||||
|
|
||||||
- name: Run smoke tests in container
|
|
||||||
run: |
|
|
||||||
docker exec "$CONTAINER_ID" /home/pwuser/playwright/tools/test-local-installation/create_project_and_run_tests.sh -Dgroups=smoke
|
|
||||||
|
|
||||||
- name: Test ClassLoader
|
- name: Test ClassLoader
|
||||||
run: |
|
run: |
|
||||||
docker exec "${CONTAINER_ID}" /home/pwuser/playwright/tools/test-spring-boot-starter/package_and_run_async_test.sh
|
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-spring-boot-starter/package_and_run_async_test.sh
|
||||||
|
|
||||||
- name: Stop container
|
- name: Stop container
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v6
|
||||||
- name: Download drivers
|
- name: Download drivers
|
||||||
run: scripts/download_driver.sh
|
run: scripts/download_driver.sh
|
||||||
- name: Regenerate APIs
|
- name: Regenerate APIs
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
# Playwright Java
|
|
||||||
|
|
||||||
The Java client is a port of the JavaScript client in `../playwright/packages/playwright-core/src/client/`. When implementing or changing a method, read the corresponding JS file first and mirror its logic.
|
|
||||||
|
|
||||||
Project checkouts (including the upstream `playwright` repo) live in the parent directory (`../`). Use the `gh` cli to interact with GitHub.
|
|
||||||
|
|
||||||
## Commit Convention
|
|
||||||
|
|
||||||
Semantic commit messages: `label(scope): description`
|
|
||||||
|
|
||||||
Labels: `fix`, `feat`, `chore`, `docs`, `test`, `devops`
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git checkout -b fix-39562
|
|
||||||
# ... make changes ...
|
|
||||||
git add <changed-files>
|
|
||||||
git commit -m "$(cat <<'EOF'
|
|
||||||
fix(proxy): handle SOCKS proxy authentication
|
|
||||||
|
|
||||||
Fixes: https://github.com/microsoft/playwright-java/issues/39562
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
# **Never `git push` without an explicit instruction to push.**
|
|
||||||
git push origin fix-39562
|
|
||||||
gh pr create --repo microsoft/playwright-java --head <user>:fix-39562 \
|
|
||||||
--title "fix(proxy): handle SOCKS proxy authentication" \
|
|
||||||
--body "$(cat <<'EOF'
|
|
||||||
## Summary
|
|
||||||
- <describe the change very! briefly>
|
|
||||||
|
|
||||||
Fixes https://github.com/microsoft/playwright-java/issues/39562
|
|
||||||
EOF
|
|
||||||
)"
|
|
||||||
```
|
|
||||||
|
|
||||||
Never add Co-Authored-By agents in commit message.
|
|
||||||
Never add "Generated with" in commit message.
|
|
||||||
Never add test plan to PR description. Keep PR description short — a few bullet points at most.
|
|
||||||
Branch naming for issue fixes: `fix-<issue-number>`.
|
|
||||||
|
|
||||||
**Never amend commits.** Always create a new commit for follow-up changes, even when iterating on an open PR. Amending rewrites history and forces a force-push, losing the incremental review trail. Only amend if the user explicitly says so.
|
|
||||||
|
|
||||||
**Never `git push` without an explicit instruction to push.** Applies even when a PR is already open for the branch — additional commits are immediately visible to reviewers. Commit locally, report what was committed, and wait. Only push when the user's message contains "push", "upload", "create PR", "ship it", or equivalent.
|
|
||||||
|
|
||||||
## Skills
|
|
||||||
|
|
||||||
- **playwright-roll** (`.claude/skills/playwright-roll/SKILL.md`) — roll Playwright Java to a new upstream version: bump the driver, regenerate the API, and port relevant upstream changes.
|
|
||||||
- **playwright-java-release** (`.claude/skills/playwright-java-release/SKILL.md`) — prepare a release after the rolling PR merges: cut the release branch, mark the Maven version, and draft the GitHub release.
|
|
||||||
+3
-4
@@ -20,14 +20,12 @@ git clone https://github.com/microsoft/playwright-java
|
|||||||
cd playwright-java
|
cd playwright-java
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Run the following script to download and assemble the Playwright driver. The platform-independent `playwright-core` package is assembled once into `driver/src/main/resources/driver/package/`, and the Node.js binary for each platform into `driver-bundle/src/main/resources/driver/<platform>/` (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
|
2. Run the following script to download Playwright driver for all platforms into `driver-bundle/src/main/resources/driver/` directory (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scripts/download_driver.sh
|
scripts/download_driver.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Each driver is assembled from the [`playwright-core`](https://www.npmjs.com/package/playwright-core) npm package (version pinned in [scripts/DRIVER_VERSION](scripts/DRIVER_VERSION)) and the matching Node.js binary from https://nodejs.org, the same way the upstream Playwright build does it.
|
|
||||||
|
|
||||||
### Building and running the tests with Maven
|
### Building and running the tests with Maven
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -41,9 +39,10 @@ BROWSER=chromium mvn test -Dtest=TestPageNetworkSizes
|
|||||||
|
|
||||||
### Generating API
|
### Generating API
|
||||||
|
|
||||||
Public Java API is generated from api.json, which is generated from the upstream Playwright source at the exact commit that produced the driver version in [scripts/DRIVER_VERSION](scripts/DRIVER_VERSION) (resolved via `npm view playwright@<version> gitHead`). `scripts/generate_api.sh` fetches a minimal upstream checkout automatically; set `PW_SRC_DIR` to reuse an existing `microsoft/playwright` checkout instead. To regenerate Java interfaces for the current driver run:
|
Public Java API is generated from api.json which is produced by `print-api-json` command of playwright CLI. To regenerate Java interfaces for the current driver run the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
./scripts/download_driver.sh
|
||||||
./scripts/generate_api.sh
|
./scripts/generate_api.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
|||||||
|
|
||||||
| | Linux | macOS | Windows |
|
| | Linux | macOS | Windows |
|
||||||
| :--- | :---: | :---: | :---: |
|
| :--- | :---: | :---: | :---: |
|
||||||
| Chromium <!-- GEN:chromium-version -->151.0.7922.34<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Chromium <!-- GEN:chromium-version -->145.0.7632.6<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| WebKit <!-- GEN:webkit-version -->26.5<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||||
| Firefox <!-- GEN:firefox-version -->153.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Firefox <!-- GEN:firefox-version -->146.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
|
|||||||
+14
-2
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
* make sure to have at least Java 8 and Maven 3.6.3
|
* make sure to have at least Java 8 and Maven 3.6.3
|
||||||
* clone playwright for java: http://github.com/microsoft/playwright-java
|
* clone playwright for java: http://github.com/microsoft/playwright-java
|
||||||
* roll the driver and update generated sources: `./scripts/roll_driver.sh next`
|
* `./scripts/roll_driver.sh 1.47.0-beta-1726138322000`
|
||||||
* fix any errors
|
|
||||||
* commit & send PR with the roll
|
* commit & send PR with the roll
|
||||||
|
|
||||||
|
## Finding driver version
|
||||||
|
|
||||||
|
For development versions of Playwright, you can find the latest version by looking at [publish_canary](https://github.com/microsoft/playwright/actions/workflows/publish_canary.yml) workflow -> `publish canary NPM & Publish canary Docker` -> `build & publish driver` step -> `PACKAGE_VERSION`
|
||||||
|
<img width="960" alt="image" src="https://github.com/microsoft/playwright-java/assets/9798949/4f33a7f1-b39a-4179-8ae7-fb1d84094c75">
|
||||||
|
|
||||||
|
|
||||||
|
# Updating Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/set_maven_version.sh 1.15.0
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
+16
-17
@@ -6,27 +6,26 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.62.0</version>
|
<version>1.58.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>driver-bundle</artifactId>
|
<artifactId>driver-bundle</artifactId>
|
||||||
<name>Playwright - Node.js For All Platforms</name>
|
<name>Playwright - Drivers For All Platforms</name>
|
||||||
<description>
|
<description>
|
||||||
Node.js binaries for the Playwright driver on every supported platform. Can be excluded when
|
This module includes Playwright driver and related utilities for all supported platforms.
|
||||||
Node.js is preinstalled on the host (see PLAYWRIGHT_NODEJS_PATH).
|
It is intended to be used on the systems where Playwright driver is not preinstalled.
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<build>
|
<dependencies>
|
||||||
<plugins>
|
<dependency>
|
||||||
<!-- The Node.js binaries for all platforms live in src/main/resources and must not
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
be packaged into the sources JAR (see issue #1913). -->
|
<artifactId>driver</artifactId>
|
||||||
<plugin>
|
<version>${project.version}</version>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<scope>compile</scope>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
</dependency>
|
||||||
<configuration>
|
<dependency>
|
||||||
<excludeResources>true</excludeResources>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
</configuration>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
</plugin>
|
</dependency>
|
||||||
</plugins>
|
</dependencies>
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+18
-50
@@ -30,11 +30,17 @@ public class DriverJar extends Driver {
|
|||||||
private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
|
private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
|
||||||
private static final String SELENIUM_REMOTE_URL = "SELENIUM_REMOTE_URL";
|
private static final String SELENIUM_REMOTE_URL = "SELENIUM_REMOTE_URL";
|
||||||
private final Path driverTempDir;
|
private final Path driverTempDir;
|
||||||
private final boolean deleteOnExit;
|
|
||||||
private Path preinstalledNodePath;
|
private Path preinstalledNodePath;
|
||||||
|
|
||||||
public DriverJar() throws IOException {
|
public DriverJar() throws IOException {
|
||||||
this(createTempDriverDir(), true);
|
// Allow specifying custom path for the driver installation
|
||||||
|
// See https://github.com/microsoft/playwright-java/issues/728
|
||||||
|
String alternativeTmpdir = System.getProperty("playwright.driver.tmpdir");
|
||||||
|
String prefix = "playwright-java-";
|
||||||
|
driverTempDir = alternativeTmpdir == null
|
||||||
|
? Files.createTempDirectory(prefix)
|
||||||
|
: Files.createTempDirectory(Paths.get(alternativeTmpdir), prefix);
|
||||||
|
driverTempDir.toFile().deleteOnExit();
|
||||||
String nodePath = System.getProperty("playwright.nodejs.path");
|
String nodePath = System.getProperty("playwright.nodejs.path");
|
||||||
if (nodePath != null) {
|
if (nodePath != null) {
|
||||||
preinstalledNodePath = Paths.get(nodePath);
|
preinstalledNodePath = Paths.get(nodePath);
|
||||||
@@ -45,32 +51,6 @@ public class DriverJar extends Driver {
|
|||||||
logMessage("created DriverJar: " + driverTempDir);
|
logMessage("created DriverJar: " + driverTempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DriverJar(Path driverDir, boolean deleteOnExit) {
|
|
||||||
this.driverTempDir = driverDir;
|
|
||||||
this.deleteOnExit = deleteOnExit;
|
|
||||||
if (deleteOnExit) {
|
|
||||||
driverTempDir.toFile().deleteOnExit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Path createTempDriverDir() throws IOException {
|
|
||||||
// Allow specifying custom path for the driver installation
|
|
||||||
// See https://github.com/microsoft/playwright-java/issues/728
|
|
||||||
String alternativeTmpdir = System.getProperty("playwright.driver.tmpdir");
|
|
||||||
String prefix = "playwright-java-";
|
|
||||||
return alternativeTmpdir == null
|
|
||||||
? Files.createTempDirectory(prefix)
|
|
||||||
: Files.createTempDirectory(Paths.get(alternativeTmpdir), prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extracts the driver (playwright-core package and the Node.js binary for the current platform)
|
|
||||||
// into the given directory, persistently. Point playwright.cli.dir / PLAYWRIGHT_DRIVER_DIR at it
|
|
||||||
// to run without extracting to a temp directory on every launch. See issue #1268.
|
|
||||||
public static void installDriverTo(Path driverDir) throws IOException, URISyntaxException {
|
|
||||||
Files.createDirectories(driverDir);
|
|
||||||
new DriverJar(driverDir, false).extractDriverToTempDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize(Boolean installBrowsers) throws Exception {
|
protected void initialize(Boolean installBrowsers) throws Exception {
|
||||||
if (preinstalledNodePath == null && env.containsKey(PLAYWRIGHT_NODEJS_PATH)) {
|
if (preinstalledNodePath == null && env.containsKey(PLAYWRIGHT_NODEJS_PATH)) {
|
||||||
@@ -139,21 +119,7 @@ public class DriverJar extends Driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void extractDriverToTempDir() throws URISyntaxException, IOException {
|
void extractDriverToTempDir() throws URISyntaxException, IOException {
|
||||||
extractResourceToDir("driver/package", driverTempDir.resolve("package"));
|
URI originalUri = getDriverResourceURI();
|
||||||
if (preinstalledNodePath == null) {
|
|
||||||
String platformResource = "driver/" + platformDir();
|
|
||||||
if (DriverJar.class.getClassLoader().getResource(platformResource) == null) {
|
|
||||||
throw new RuntimeException("Failed to find the bundled Node.js for platform '" + platformDir()
|
|
||||||
+ "'. Add the com.microsoft.playwright:driver-bundle dependency, or set the "
|
|
||||||
+ PLAYWRIGHT_NODEJS_PATH + " environment variable (or the playwright.nodejs.path system "
|
|
||||||
+ "property) to point at a preinstalled Node.js.");
|
|
||||||
}
|
|
||||||
extractResourceToDir(platformResource, driverTempDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void extractResourceToDir(String resourcePath, Path destDir) throws URISyntaxException, IOException {
|
|
||||||
URI originalUri = DriverJar.class.getClassLoader().getResource(resourcePath).toURI();
|
|
||||||
URI uri = maybeExtractNestedJar(originalUri);
|
URI uri = maybeExtractNestedJar(originalUri);
|
||||||
|
|
||||||
// Create zip filesystem if loading from jar.
|
// Create zip filesystem if loading from jar.
|
||||||
@@ -165,8 +131,14 @@ public class DriverJar extends Driver {
|
|||||||
// See https://github.com/microsoft/playwright-java/issues/306
|
// See https://github.com/microsoft/playwright-java/issues/306
|
||||||
Path srcRootDefaultFs = Paths.get(srcRoot.toString());
|
Path srcRootDefaultFs = Paths.get(srcRoot.toString());
|
||||||
Files.walk(srcRoot).forEach(fromPath -> {
|
Files.walk(srcRoot).forEach(fromPath -> {
|
||||||
|
if (preinstalledNodePath != null) {
|
||||||
|
String fileName = fromPath.getFileName().toString();
|
||||||
|
if ("node.exe".equals(fileName) || "node".equals(fileName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Path relative = srcRootDefaultFs.relativize(Paths.get(fromPath.toString()));
|
Path relative = srcRootDefaultFs.relativize(Paths.get(fromPath.toString()));
|
||||||
Path toPath = destDir.resolve(relative.toString());
|
Path toPath = driverTempDir.resolve(relative.toString());
|
||||||
try {
|
try {
|
||||||
if (Files.isDirectory(fromPath)) {
|
if (Files.isDirectory(fromPath)) {
|
||||||
Files.createDirectories(toPath);
|
Files.createDirectories(toPath);
|
||||||
@@ -176,9 +148,7 @@ public class DriverJar extends Driver {
|
|||||||
toPath.toFile().setExecutable(true, true);
|
toPath.toFile().setExecutable(true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deleteOnExit) {
|
toPath.toFile().deleteOnExit();
|
||||||
toPath.toFile().deleteOnExit();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to extract driver from " + uri + ", full uri: " + originalUri, e);
|
throw new RuntimeException("Failed to extract driver from " + uri + ", full uri: " + originalUri, e);
|
||||||
}
|
}
|
||||||
@@ -201,9 +171,7 @@ public class DriverJar extends Driver {
|
|||||||
Path fromPath = Paths.get(jarUri);
|
Path fromPath = Paths.get(jarUri);
|
||||||
Path toPath = driverTempDir.resolve(fromPath.getFileName().toString());
|
Path toPath = driverTempDir.resolve(fromPath.getFileName().toString());
|
||||||
Files.copy(fromPath, toPath);
|
Files.copy(fromPath, toPath);
|
||||||
if (deleteOnExit) {
|
toPath.toFile().deleteOnExit();
|
||||||
toPath.toFile().deleteOnExit();
|
|
||||||
}
|
|
||||||
return new URI("jar:" + toPath.toUri() + JAR_URL_SEPARATOR + parts[2]);
|
return new URI("jar:" + toPath.toUri() + JAR_URL_SEPARATOR + parts[2]);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to extract driver's nested .jar from " + jarUri + "; full uri: " + uri, e);
|
throw new RuntimeException("Failed to extract driver's nested .jar from " + jarUri + "; full uri: " + uri, e);
|
||||||
-24
@@ -132,30 +132,6 @@ public class TestInstall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void canInstallDriverToDirectoryAndReuseIt(@TempDir Path tmpDir) throws Exception {
|
|
||||||
Path driverDir = tmpDir.resolve("driver");
|
|
||||||
DriverJar.installDriverTo(driverDir);
|
|
||||||
// The directory is self-contained: the playwright-core package and the Node.js binary.
|
|
||||||
assertTrue(Files.exists(driverDir.resolve("package").resolve("cli.js")));
|
|
||||||
assertTrue(Files.exists(driverDir.resolve(isWindows() ? "node.exe" : "node")));
|
|
||||||
|
|
||||||
// Pointing playwright.cli.dir at it must reuse it as-is, without extracting to a temp directory.
|
|
||||||
System.setProperty("playwright.cli.dir", driverDir.toString());
|
|
||||||
Driver driver = Driver.createAndInstall(Collections.emptyMap(), false);
|
|
||||||
assertEquals(driverDir, driver.driverDir());
|
|
||||||
|
|
||||||
ProcessBuilder pb = driver.createProcessBuilder();
|
|
||||||
pb.command().add("--version");
|
|
||||||
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
|
|
||||||
Path out = tmpDir.resolve("out.txt");
|
|
||||||
pb.redirectOutput(out.toFile());
|
|
||||||
Process p = pb.start();
|
|
||||||
assertTrue(p.waitFor(1, TimeUnit.MINUTES), "Timed out waiting for version to be printed");
|
|
||||||
String stdout = new String(Files.readAllBytes(out), StandardCharsets.UTF_8);
|
|
||||||
assertTrue(stdout.contains("Version "), stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String extractNodeJsToTemp() throws URISyntaxException, IOException {
|
private static String extractNodeJsToTemp() throws URISyntaxException, IOException {
|
||||||
DriverJar auxDriver = new DriverJar();
|
DriverJar auxDriver = new DriverJar();
|
||||||
auxDriver.extractDriverToTempDir();
|
auxDriver.extractDriverToTempDir();
|
||||||
+2
-17
@@ -6,14 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.62.0</version>
|
<version>1.58.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>driver</artifactId>
|
<artifactId>driver</artifactId>
|
||||||
<name>Playwright - Driver</name>
|
<name>Playwright - Driver</name>
|
||||||
<description>
|
<description>
|
||||||
API for launching the Playwright driver. Bundles the platform-independent playwright-core
|
This module provides API for discovery and launching of Playwright driver.
|
||||||
package; the Node.js binary comes from the driver-bundle module or a preinstalled Node.js.
|
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -22,18 +21,4 @@
|
|||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- The playwright-core package lives in src/main/resources and must not be packaged
|
|
||||||
into the sources JAR (see issue #1913). -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<excludeResources>true</excludeResources>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -25,14 +25,12 @@ import static com.microsoft.playwright.impl.driver.DriverLogging.logWithTimestam
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides access to playwright-cli. It can be either preinstalled
|
* This class provides access to playwright-cli. It can be either preinstalled
|
||||||
* in the host system and its path is passed as a system property, or it can be
|
* in the host system and its path is passed as a system property or it can be
|
||||||
* loaded from the classpath: the platform-independent driver code ships in the
|
* loaded from the driver-bundle module if that module is in the classpath.
|
||||||
* driver module and the Node.js binary in the optional driver-bundle module.
|
|
||||||
*/
|
*/
|
||||||
public abstract class Driver {
|
public abstract class Driver {
|
||||||
protected final Map<String, String> env = new LinkedHashMap<>(System.getenv());
|
protected final Map<String, String> env = new LinkedHashMap<>(System.getenv());
|
||||||
public static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
|
public static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
|
||||||
public static final String PLAYWRIGHT_DRIVER_DIR = "PLAYWRIGHT_DRIVER_DIR";
|
|
||||||
|
|
||||||
private static Driver instance;
|
private static Driver instance;
|
||||||
|
|
||||||
@@ -109,12 +107,9 @@ public abstract class Driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Driver newInstance() throws Exception {
|
private static Driver newInstance() throws Exception {
|
||||||
String driverDir = System.getProperty("playwright.cli.dir");
|
String pathFromProperty = System.getProperty("playwright.cli.dir");
|
||||||
if (driverDir == null) {
|
if (pathFromProperty != null) {
|
||||||
driverDir = System.getenv(PLAYWRIGHT_DRIVER_DIR);
|
return new PreinstalledDriver(Paths.get(pathFromProperty));
|
||||||
}
|
|
||||||
if (driverDir != null) {
|
|
||||||
return new PreinstalledDriver(Paths.get(driverDir));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String driverImpl =
|
String driverImpl =
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
driver/
|
|
||||||
local-driver/
|
|
||||||
+2
-2
@@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>examples</artifactId>
|
<artifactId>examples</artifactId>
|
||||||
<version>1.62.0</version>
|
<version>1.58.0</version>
|
||||||
<name>Playwright Client Examples</name>
|
<name>Playwright Client Examples</name>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<playwright.version>1.62.0</playwright.version>
|
<playwright.version>1.58.0</playwright.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
<groupId>com.microsoft.playwright</groupId>
|
||||||
<artifactId>parent-pom</artifactId>
|
<artifactId>parent-pom</artifactId>
|
||||||
<version>1.62.0</version>
|
<version>1.58.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>playwright</artifactId>
|
<artifactId>playwright</artifactId>
|
||||||
|
|||||||
@@ -23,23 +23,24 @@ import java.nio.file.Path;
|
|||||||
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
||||||
* environment or the service to your e2e test.
|
* environment or the service to your e2e test.
|
||||||
*
|
*
|
||||||
* <p> Each Playwright browser context has an associated {@code APIRequestContext}, accessible via {@link
|
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage
|
||||||
* com.microsoft.playwright.BrowserContext#request BrowserContext.request()} or {@link
|
* with the browser context and can be accessed via {@link com.microsoft.playwright.BrowserContext#request
|
||||||
* com.microsoft.playwright.Page#request Page.request()} (these return the
|
* BrowserContext.request()} or {@link com.microsoft.playwright.Page#request Page.request()}. It is also possible to create
|
||||||
*
|
* a new APIRequestContext instance manually by calling {@link com.microsoft.playwright.APIRequest#newContext
|
||||||
* <p> **same instance** — {@code page.request} is a shortcut for {@code page.context().request}). You can also create a
|
* APIRequest.newContext()}.
|
||||||
* standalone, isolated instance with {@link com.microsoft.playwright.APIRequest#newContext APIRequest.newContext()}.
|
|
||||||
*
|
*
|
||||||
* <p> <strong>Cookie management</strong>
|
* <p> <strong>Cookie management</strong>
|
||||||
*
|
*
|
||||||
* <p> The {@code APIRequestContext} returned by {@link com.microsoft.playwright.BrowserContext#request
|
* <p> {@code APIRequestContext} returned by {@link com.microsoft.playwright.BrowserContext#request BrowserContext.request()}
|
||||||
* BrowserContext.request()} and
|
* and {@link com.microsoft.playwright.Page#request Page.request()} shares cookie storage with the corresponding {@code
|
||||||
|
* BrowserContext}. Each API request will have {@code Cookie} header populated with the values from the browser context. If
|
||||||
|
* the API response contains {@code Set-Cookie} header it will automatically update {@code BrowserContext} cookies and
|
||||||
|
* requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be
|
||||||
|
* logged in and vice versa.
|
||||||
*
|
*
|
||||||
* <p> {@link com.microsoft.playwright.Page#request Page.request()} uses the same cookie jar as its {@code BrowserContext}:
|
* <p> If you want API requests to not interfere with the browser cookies you should create a new {@code APIRequestContext} by
|
||||||
*
|
* calling {@link com.microsoft.playwright.APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext}
|
||||||
* <p> If you want API requests that do **not** share cookies with the browser, create an isolated context via {@link
|
* object will have its own isolated cookie storage.
|
||||||
* com.microsoft.playwright.APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have
|
|
||||||
* its own isolated cookie storage.
|
|
||||||
*/
|
*/
|
||||||
public interface APIRequestContext {
|
public interface APIRequestContext {
|
||||||
class DisposeOptions {
|
class DisposeOptions {
|
||||||
@@ -483,11 +484,5 @@ public interface APIRequestContext {
|
|||||||
* @since v1.16
|
* @since v1.16
|
||||||
*/
|
*/
|
||||||
String storageState(StorageStateOptions options);
|
String storageState(StorageStateOptions options);
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
Tracing tracing();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,20 +55,6 @@ public interface APIResponse {
|
|||||||
* @since v1.16
|
* @since v1.16
|
||||||
*/
|
*/
|
||||||
boolean ok();
|
boolean ok();
|
||||||
/**
|
|
||||||
* Returns SSL and other security information. Resolves to {@code null} for non-HTTPS responses. For redirected requests,
|
|
||||||
* returns the information for the last request in the redirect chain.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
SecurityDetails securityDetails();
|
|
||||||
/**
|
|
||||||
* Returns the IP address and port of the server. Resolves to {@code null} if the server address is not available. For
|
|
||||||
* redirected requests, returns the information for the last request in the redirect chain.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
ServerAddr serverAddr();
|
|
||||||
/**
|
/**
|
||||||
* Contains the status code of the response (e.g., 200 for a success).
|
* Contains the status code of the response (e.g., 200 for a success).
|
||||||
*
|
*
|
||||||
@@ -87,16 +73,6 @@ public interface APIResponse {
|
|||||||
* @since v1.16
|
* @since v1.16
|
||||||
*/
|
*/
|
||||||
String text();
|
String text();
|
||||||
/**
|
|
||||||
* Returns resource timing information for given response. For redirected requests, returns the information for the last
|
|
||||||
* request in the redirect chain. When the response is served <a
|
|
||||||
* href="https://playwright.dev/java/docs/mock#replaying-from-har">from the HAR file</a>, timing information is not
|
|
||||||
* available and all the values are -1. Find more information at <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming">Resource Timing API</a>.
|
|
||||||
*
|
|
||||||
* @since v1.62
|
|
||||||
*/
|
|
||||||
Timing timing();
|
|
||||||
/**
|
/**
|
||||||
* Contains the URL of the response.
|
* Contains the URL of the response.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -43,15 +43,6 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public interface Browser extends AutoCloseable {
|
public interface Browser extends AutoCloseable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a new browser context is created.
|
|
||||||
*/
|
|
||||||
void onContext(Consumer<BrowserContext> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onContext onContext(handler)}.
|
|
||||||
*/
|
|
||||||
void offContext(Consumer<BrowserContext> handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
|
* Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
|
||||||
* <ul>
|
* <ul>
|
||||||
@@ -1231,44 +1222,6 @@ public interface Browser extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class BindOptions {
|
|
||||||
/**
|
|
||||||
* Host to bind the web socket server to. When specified, a web socket server is created instead of a named pipe.
|
|
||||||
*/
|
|
||||||
public String host;
|
|
||||||
/**
|
|
||||||
* Port to bind the web socket server to. When specified, a web socket server is created instead of a named pipe. Use
|
|
||||||
* {@code 0} to let the OS pick an available port.
|
|
||||||
*/
|
|
||||||
public Integer port;
|
|
||||||
/**
|
|
||||||
* Working directory associated with this browser server.
|
|
||||||
*/
|
|
||||||
public String workspaceDir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Host to bind the web socket server to. When specified, a web socket server is created instead of a named pipe.
|
|
||||||
*/
|
|
||||||
public BindOptions setHost(String host) {
|
|
||||||
this.host = host;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Port to bind the web socket server to. When specified, a web socket server is created instead of a named pipe. Use
|
|
||||||
* {@code 0} to let the OS pick an available port.
|
|
||||||
*/
|
|
||||||
public BindOptions setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Working directory associated with this browser server.
|
|
||||||
*/
|
|
||||||
public BindOptions setWorkspaceDir(String workspaceDir) {
|
|
||||||
this.workspaceDir = workspaceDir;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class StartTracingOptions {
|
class StartTracingOptions {
|
||||||
/**
|
/**
|
||||||
* specify custom categories to use instead of default.
|
* specify custom categories to use instead of default.
|
||||||
@@ -1451,22 +1404,6 @@ public interface Browser extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Page newPage(NewPageOptions options);
|
Page newPage(NewPageOptions options);
|
||||||
/**
|
|
||||||
* Binds the browser to a named pipe or web socket, making it available for other clients to connect to.
|
|
||||||
*
|
|
||||||
* @param title Title of the browser server, used for identification.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default BindResult bind(String title) {
|
|
||||||
return bind(title, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Binds the browser to a named pipe or web socket, making it available for other clients to connect to.
|
|
||||||
*
|
|
||||||
* @param title Title of the browser server, used for identification.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
BindResult bind(String title, BindOptions options);
|
|
||||||
/**
|
/**
|
||||||
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
|
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
|
||||||
* which is a low-level chromium-specific debugging tool. API to control <a
|
* which is a low-level chromium-specific debugging tool. API to control <a
|
||||||
@@ -1547,12 +1484,6 @@ public interface Browser extends AutoCloseable {
|
|||||||
* @since v1.11
|
* @since v1.11
|
||||||
*/
|
*/
|
||||||
byte[] stopTracing();
|
byte[] stopTracing();
|
||||||
/**
|
|
||||||
* Unbinds the browser server previously bound with {@link com.microsoft.playwright.Browser#bind Browser.bind()}.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void unbind();
|
|
||||||
/**
|
/**
|
||||||
* Returns the browser version.
|
* Returns the browser version.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -114,48 +114,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
void offDialog(Consumer<Dialog> handler);
|
void offDialog(Consumer<Dialog> handler);
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when attachment download started in any page belonging to this context. User can access basic file operations on
|
|
||||||
* downloaded content via the passed {@code Download} instance. See also {@link com.microsoft.playwright.Page#onDownload
|
|
||||||
* Page.onDownload()} to receive events about a specific page.
|
|
||||||
*/
|
|
||||||
void onDownload(Consumer<Download> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onDownload onDownload(handler)}.
|
|
||||||
*/
|
|
||||||
void offDownload(Consumer<Download> handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a frame is attached in any page belonging to this context. See also {@link
|
|
||||||
* com.microsoft.playwright.Page#onFrameAttached Page.onFrameAttached()} to receive events about a specific page.
|
|
||||||
*/
|
|
||||||
void onFrameAttached(Consumer<Frame> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onFrameAttached onFrameAttached(handler)}.
|
|
||||||
*/
|
|
||||||
void offFrameAttached(Consumer<Frame> handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a frame is detached in any page belonging to this context. See also {@link
|
|
||||||
* com.microsoft.playwright.Page#onFrameDetached Page.onFrameDetached()} to receive events about a specific page.
|
|
||||||
*/
|
|
||||||
void onFrameDetached(Consumer<Frame> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onFrameDetached onFrameDetached(handler)}.
|
|
||||||
*/
|
|
||||||
void offFrameDetached(Consumer<Frame> handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a frame is navigated to a new url in any page belonging to this context. See also {@link
|
|
||||||
* com.microsoft.playwright.Page#onFrameNavigated Page.onFrameNavigated()} to receive events about navigations in a
|
|
||||||
* specific page.
|
|
||||||
*/
|
|
||||||
void onFrameNavigated(Consumer<Frame> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onFrameNavigated onFrameNavigated(handler)}.
|
|
||||||
*/
|
|
||||||
void offFrameNavigated(Consumer<Frame> handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
|
* The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
|
||||||
* also fire for popup pages. See also {@link com.microsoft.playwright.Page#onPopup Page.onPopup()} to receive events about
|
* also fire for popup pages. See also {@link com.microsoft.playwright.Page#onPopup Page.onPopup()} to receive events about
|
||||||
@@ -183,27 +141,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
void offPage(Consumer<Page> handler);
|
void offPage(Consumer<Page> handler);
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a page in this context is closed. See also {@link com.microsoft.playwright.Page#onClose Page.onClose()} to
|
|
||||||
* receive events about a specific page.
|
|
||||||
*/
|
|
||||||
void onPageClose(Consumer<Page> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onPageClose onPageClose(handler)}.
|
|
||||||
*/
|
|
||||||
void offPageClose(Consumer<Page> handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when the JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/Events/load">{@code load}</a> event is
|
|
||||||
* dispatched in any page belonging to this context. See also {@link com.microsoft.playwright.Page#onLoad Page.onLoad()} to
|
|
||||||
* receive events about a specific page.
|
|
||||||
*/
|
|
||||||
void onPageLoad(Consumer<Page> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onPageLoad onPageLoad(handler)}.
|
|
||||||
*/
|
|
||||||
void offPageLoad(Consumer<Page> handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular page,
|
* Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular page,
|
||||||
* use {@link com.microsoft.playwright.Page#onPageError Page.onPageError()} instead.
|
* use {@link com.microsoft.playwright.Page#onPageError Page.onPageError()} instead.
|
||||||
@@ -334,6 +271,20 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class ExposeBindingOptions {
|
||||||
|
/**
|
||||||
|
* @deprecated This option will be removed in the future.
|
||||||
|
*/
|
||||||
|
public Boolean handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This option will be removed in the future.
|
||||||
|
*/
|
||||||
|
public ExposeBindingOptions setHandle(boolean handle) {
|
||||||
|
this.handle = handle;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
class GrantPermissionsOptions {
|
class GrantPermissionsOptions {
|
||||||
/**
|
/**
|
||||||
* The [origin] to grant permissions to, e.g. "https://example.com".
|
* The [origin] to grant permissions to, e.g. "https://example.com".
|
||||||
@@ -449,16 +400,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class StorageStateOptions {
|
class StorageStateOptions {
|
||||||
/**
|
|
||||||
* Set to {@code true} to include the context's virtual WebAuthn {@link com.microsoft.playwright.BrowserContext#credentials
|
|
||||||
* BrowserContext.credentials()} (passkeys) in the storage state snapshot. The captured credentials carry their private
|
|
||||||
* keys, so they can be re-seeded into a later context via the {@code storageState} option or {@link
|
|
||||||
* com.microsoft.playwright.BrowserContext#setStorageState BrowserContext.setStorageState()}. Note that restoring the
|
|
||||||
* storage state that contains credentials will automatically install the virtual WebAuthn authenticator (see {@link
|
|
||||||
* com.microsoft.playwright.Credentials#install Credentials.install()}), and prevent all real authenticators from working
|
|
||||||
* in this context.
|
|
||||||
*/
|
|
||||||
public Boolean credentials;
|
|
||||||
/**
|
/**
|
||||||
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
|
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
|
||||||
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
|
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
|
||||||
@@ -471,19 +412,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public Path path;
|
public Path path;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code true} to include the context's virtual WebAuthn {@link com.microsoft.playwright.BrowserContext#credentials
|
|
||||||
* BrowserContext.credentials()} (passkeys) in the storage state snapshot. The captured credentials carry their private
|
|
||||||
* keys, so they can be re-seeded into a later context via the {@code storageState} option or {@link
|
|
||||||
* com.microsoft.playwright.BrowserContext#setStorageState BrowserContext.setStorageState()}. Note that restoring the
|
|
||||||
* storage state that contains credentials will automatically install the virtual WebAuthn authenticator (see {@link
|
|
||||||
* com.microsoft.playwright.Credentials#install Credentials.install()}), and prevent all real authenticators from working
|
|
||||||
* in this context.
|
|
||||||
*/
|
|
||||||
public StorageStateOptions setCredentials(boolean credentials) {
|
|
||||||
this.credentials = credentials;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
|
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
|
||||||
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
|
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
|
||||||
@@ -586,19 +514,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @since v1.45
|
* @since v1.45
|
||||||
*/
|
*/
|
||||||
Clock clock();
|
Clock clock();
|
||||||
/**
|
|
||||||
* Virtual WebAuthn authenticator for this context. Lets tests seed credentials and intercept {@code
|
|
||||||
* navigator.credentials.create()} / {@code navigator.credentials.get()} ceremonies.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
Credentials credentials();
|
|
||||||
/**
|
|
||||||
* Debugger allows to pause and resume the execution.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
Debugger debugger();
|
|
||||||
/**
|
/**
|
||||||
* Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
|
* Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
|
||||||
* obtained via {@link com.microsoft.playwright.BrowserContext#cookies BrowserContext.cookies()}.
|
* obtained via {@link com.microsoft.playwright.BrowserContext#cookies BrowserContext.cookies()}.
|
||||||
@@ -637,7 +552,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param script Script to be evaluated in all pages in the browser context.
|
* @param script Script to be evaluated in all pages in the browser context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable addInitScript(String script);
|
void addInitScript(String script);
|
||||||
/**
|
/**
|
||||||
* Adds a script which would be evaluated in one of the following scenarios:
|
* Adds a script which would be evaluated in one of the following scenarios:
|
||||||
* <ul>
|
* <ul>
|
||||||
@@ -664,7 +579,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param script Script to be evaluated in all pages in the browser context.
|
* @param script Script to be evaluated in all pages in the browser context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable addInitScript(Path script);
|
void addInitScript(Path script);
|
||||||
/**
|
/**
|
||||||
* @deprecated Background pages have been removed from Chromium together with Manifest V2 extensions.
|
* @deprecated Background pages have been removed from Chromium together with Manifest V2 extensions.
|
||||||
*
|
*
|
||||||
@@ -815,7 +730,54 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param callback Callback function that will be called in the Playwright's context.
|
* @param callback Callback function that will be called in the Playwright's context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable exposeBinding(String name, BindingCallback callback);
|
default void exposeBinding(String name, BindingCallback callback) {
|
||||||
|
exposeBinding(name, callback, null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The method adds a function called {@code name} on the {@code window} object of every frame in every page in the context.
|
||||||
|
* When called, the function executes {@code callback} and returns a <a
|
||||||
|
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a> which
|
||||||
|
* resolves to the return value of {@code callback}. If the {@code callback} returns a <a
|
||||||
|
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, it will be
|
||||||
|
* awaited.
|
||||||
|
*
|
||||||
|
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
|
||||||
|
* BrowserContext, page: Page, frame: Frame }}.
|
||||||
|
*
|
||||||
|
* <p> See {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} for page-only version.
|
||||||
|
*
|
||||||
|
* <p> <strong>Usage</strong>
|
||||||
|
*
|
||||||
|
* <p> An example of exposing page URL to all frames in all pages in the context:
|
||||||
|
* <pre>{@code
|
||||||
|
* import com.microsoft.playwright.*;
|
||||||
|
*
|
||||||
|
* public class Example {
|
||||||
|
* public static void main(String[] args) {
|
||||||
|
* try (Playwright playwright = Playwright.create()) {
|
||||||
|
* BrowserType webkit = playwright.webkit();
|
||||||
|
* Browser browser = webkit.launch(new BrowserType.LaunchOptions().setHeadless(false));
|
||||||
|
* BrowserContext context = browser.newContext();
|
||||||
|
* context.exposeBinding("pageURL", (source, args) -> source.page().url());
|
||||||
|
* Page page = context.newPage();
|
||||||
|
* page.setContent("<script>\n" +
|
||||||
|
* " async function onClick() {\n" +
|
||||||
|
* " document.querySelector('div').textContent = await window.pageURL();\n" +
|
||||||
|
* " }\n" +
|
||||||
|
* "</script>\n" +
|
||||||
|
* "<button onclick=\"onClick()\">Click me</button>\n" +
|
||||||
|
* "<div></div>");
|
||||||
|
* page.getByRole(AriaRole.BUTTON).click();
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @param name Name of the function on the window object.
|
||||||
|
* @param callback Callback function that will be called in the Playwright's context.
|
||||||
|
* @since v1.8
|
||||||
|
*/
|
||||||
|
void exposeBinding(String name, BindingCallback callback, ExposeBindingOptions options);
|
||||||
/**
|
/**
|
||||||
* The method adds a function called {@code name} on the {@code window} object of every frame in every page in the context.
|
* The method adds a function called {@code name} on the {@code window} object of every frame in every page in the context.
|
||||||
* When called, the function executes {@code callback} and returns a <a
|
* When called, the function executes {@code callback} and returns a <a
|
||||||
@@ -874,7 +836,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param callback Callback function that will be called in the Playwright's context.
|
* @param callback Callback function that will be called in the Playwright's context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable exposeFunction(String name, FunctionCallback callback);
|
void exposeFunction(String name, FunctionCallback callback);
|
||||||
/**
|
/**
|
||||||
* Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
|
* Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
|
||||||
* specified.
|
* specified.
|
||||||
@@ -903,7 +865,6 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* <li> {@code "notifications"}</li>
|
* <li> {@code "notifications"}</li>
|
||||||
* <li> {@code "payment-handler"}</li>
|
* <li> {@code "payment-handler"}</li>
|
||||||
* <li> {@code "storage-access"}</li>
|
* <li> {@code "storage-access"}</li>
|
||||||
* <li> {@code "screen-wake-lock"}</li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -938,17 +899,10 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* <li> {@code "notifications"}</li>
|
* <li> {@code "notifications"}</li>
|
||||||
* <li> {@code "payment-handler"}</li>
|
* <li> {@code "payment-handler"}</li>
|
||||||
* <li> {@code "storage-access"}</li>
|
* <li> {@code "storage-access"}</li>
|
||||||
* <li> {@code "screen-wake-lock"}</li>
|
|
||||||
* </ul>
|
* </ul>
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
void grantPermissions(List<String> permissions, GrantPermissionsOptions options);
|
void grantPermissions(List<String> permissions, GrantPermissionsOptions options);
|
||||||
/**
|
|
||||||
* Indicates that the browser context is in the process of closing or has already been closed.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
boolean isClosed();
|
|
||||||
/**
|
/**
|
||||||
* <strong>NOTE:</strong> CDP sessions are only supported on Chromium-based browsers.
|
* <strong>NOTE:</strong> CDP sessions are only supported on Chromium-based browsers.
|
||||||
*
|
*
|
||||||
@@ -1040,8 +994,8 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(String url, Consumer<Route> handler) {
|
default void route(String url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
||||||
@@ -1096,7 +1050,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(String url, Consumer<Route> handler, RouteOptions options);
|
void route(String url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
||||||
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
||||||
@@ -1150,8 +1104,8 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(Pattern url, Consumer<Route> handler) {
|
default void route(Pattern url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
||||||
@@ -1206,7 +1160,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(Pattern url, Consumer<Route> handler, RouteOptions options);
|
void route(Pattern url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
||||||
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
||||||
@@ -1260,8 +1214,8 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(Predicate<String> url, Consumer<Route> handler) {
|
default void route(Predicate<String> url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
|
||||||
@@ -1316,7 +1270,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(Predicate<String> url, Consumer<Route> handler, RouteOptions options);
|
void route(Predicate<String> url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* If specified the network requests that are made in the context will be served from the HAR file. Read more about <a
|
* If specified the network requests that are made in the context will be served from the HAR file. Read more about <a
|
||||||
* href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR</a>.
|
* href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR</a>.
|
||||||
@@ -1492,8 +1446,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
void setOffline(boolean offline);
|
void setOffline(boolean offline);
|
||||||
/**
|
/**
|
||||||
* Returns storage state for this browser context, contains current cookies, local storage snapshot, IndexedDB snapshot and
|
* Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.
|
||||||
* virtual WebAuthn credentials.
|
|
||||||
*
|
*
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -1501,30 +1454,11 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
return storageState(null);
|
return storageState(null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns storage state for this browser context, contains current cookies, local storage snapshot, IndexedDB snapshot and
|
* Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.
|
||||||
* virtual WebAuthn credentials.
|
|
||||||
*
|
*
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
String storageState(StorageStateOptions options);
|
String storageState(StorageStateOptions options);
|
||||||
/**
|
|
||||||
* Clears the existing cookies, local storage, IndexedDB entries and virtual WebAuthn credentials, and sets the new storage
|
|
||||||
* state. When the storage state contains credentials, the virtual WebAuthn authenticator is installed (equivalent to
|
|
||||||
* {@link com.microsoft.playwright.Credentials#install Credentials.install()}), preventing all real authenticators from
|
|
||||||
* working in this context.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* // Load storage state from a file and apply it to the context.
|
|
||||||
* context.setStorageState(Paths.get("state.json"));
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @param storageState Populates context with given storage state. This option can be used to initialize context with logged-in information
|
|
||||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
|
||||||
* file with saved storage state.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void setStorageState(Path storageState);
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -1542,7 +1476,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -1553,7 +1487,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||||
* BrowserContext.route()}.
|
* BrowserContext.route()}.
|
||||||
@@ -1564,7 +1498,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -1575,7 +1509,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||||
* BrowserContext.route()}.
|
* BrowserContext.route()}.
|
||||||
@@ -1586,7 +1520,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -1597,7 +1531,7 @@ public interface BrowserContext extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
|
||||||
* handler} is not specified, removes all routes for the {@code url}.
|
* handler} is not specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with {@link
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
|
||||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||||
* BrowserContext.route()}.
|
* BrowserContext.route()}.
|
||||||
|
|||||||
@@ -124,10 +124,6 @@ public interface BrowserType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class ConnectOverCDPOptions {
|
class ConnectOverCDPOptions {
|
||||||
/**
|
|
||||||
* If specified, browser artifacts (such as traces and downloads) are saved into this directory.
|
|
||||||
*/
|
|
||||||
public Path artifactsDir;
|
|
||||||
/**
|
/**
|
||||||
* Additional HTTP headers to be sent with connect request. Optional.
|
* Additional HTTP headers to be sent with connect request. Optional.
|
||||||
*/
|
*/
|
||||||
@@ -137,15 +133,6 @@ public interface BrowserType {
|
|||||||
* the file system being the same between Playwright and the Browser.
|
* the file system being the same between Playwright and the Browser.
|
||||||
*/
|
*/
|
||||||
public Boolean isLocal;
|
public Boolean isLocal;
|
||||||
/**
|
|
||||||
* When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, {@code
|
|
||||||
* acceptDownloads} is left at the browser's setting, focus emulation is not enabled, and media emulation options (such as
|
|
||||||
* {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are not applied. Useful when
|
|
||||||
* attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New
|
|
||||||
* contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not affected. Defaults
|
|
||||||
* to {@code false}.
|
|
||||||
*/
|
|
||||||
public Boolean noDefaults;
|
|
||||||
/**
|
/**
|
||||||
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
|
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
|
||||||
* Defaults to 0.
|
* Defaults to 0.
|
||||||
@@ -157,13 +144,6 @@ public interface BrowserType {
|
|||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
|
|
||||||
/**
|
|
||||||
* If specified, browser artifacts (such as traces and downloads) are saved into this directory.
|
|
||||||
*/
|
|
||||||
public ConnectOverCDPOptions setArtifactsDir(Path artifactsDir) {
|
|
||||||
this.artifactsDir = artifactsDir;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Additional HTTP headers to be sent with connect request. Optional.
|
* Additional HTTP headers to be sent with connect request. Optional.
|
||||||
*/
|
*/
|
||||||
@@ -179,18 +159,6 @@ public interface BrowserType {
|
|||||||
this.isLocal = isLocal;
|
this.isLocal = isLocal;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, {@code
|
|
||||||
* acceptDownloads} is left at the browser's setting, focus emulation is not enabled, and media emulation options (such as
|
|
||||||
* {@code colorScheme}, {@code reducedMotion}, {@code forcedColors}, and {@code contrast}) are not applied. Useful when
|
|
||||||
* attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New
|
|
||||||
* contexts created via {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} are not affected. Defaults
|
|
||||||
* to {@code false}.
|
|
||||||
*/
|
|
||||||
public ConnectOverCDPOptions setNoDefaults(boolean noDefaults) {
|
|
||||||
this.noDefaults = noDefaults;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
|
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
|
||||||
* Defaults to 0.
|
* Defaults to 0.
|
||||||
@@ -216,12 +184,6 @@ public interface BrowserType {
|
|||||||
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
||||||
*/
|
*/
|
||||||
public List<String> args;
|
public List<String> args;
|
||||||
/**
|
|
||||||
* If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not
|
|
||||||
* cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser
|
|
||||||
* closes.
|
|
||||||
*/
|
|
||||||
public Path artifactsDir;
|
|
||||||
/**
|
/**
|
||||||
* Browser distribution channel.
|
* Browser distribution channel.
|
||||||
*
|
*
|
||||||
@@ -317,15 +279,6 @@ public interface BrowserType {
|
|||||||
this.args = args;
|
this.args = args;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not
|
|
||||||
* cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser
|
|
||||||
* closes.
|
|
||||||
*/
|
|
||||||
public LaunchOptions setArtifactsDir(Path artifactsDir) {
|
|
||||||
this.artifactsDir = artifactsDir;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
/**
|
/**
|
||||||
* Browser distribution channel.
|
* Browser distribution channel.
|
||||||
@@ -492,12 +445,6 @@ public interface BrowserType {
|
|||||||
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
||||||
*/
|
*/
|
||||||
public List<String> args;
|
public List<String> args;
|
||||||
/**
|
|
||||||
* If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not
|
|
||||||
* cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser
|
|
||||||
* closes.
|
|
||||||
*/
|
|
||||||
public Path artifactsDir;
|
|
||||||
/**
|
/**
|
||||||
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
|
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
|
||||||
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
|
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
|
||||||
@@ -792,15 +739,6 @@ public interface BrowserType {
|
|||||||
this.args = args;
|
this.args = args;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not
|
|
||||||
* cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser
|
|
||||||
* closes.
|
|
||||||
*/
|
|
||||||
public LaunchPersistentContextOptions setArtifactsDir(Path artifactsDir) {
|
|
||||||
this.artifactsDir = artifactsDir;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
|
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
|
||||||
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
|
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
|
||||||
@@ -1286,11 +1224,11 @@ public interface BrowserType {
|
|||||||
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
|
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
|
||||||
* launches the browser (1.2.3 → is compatible with 1.2.x).
|
* launches the browser (1.2.3 → is compatible with 1.2.x).
|
||||||
*
|
*
|
||||||
* @param endpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
|
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default Browser connect(String endpoint) {
|
default Browser connect(String wsEndpoint) {
|
||||||
return connect(endpoint, null);
|
return connect(wsEndpoint, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This method attaches Playwright to an existing browser instance created via {@code BrowserType.launchServer} in Node.js.
|
* This method attaches Playwright to an existing browser instance created via {@code BrowserType.launchServer} in Node.js.
|
||||||
@@ -1298,10 +1236,10 @@ public interface BrowserType {
|
|||||||
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
|
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
|
||||||
* launches the browser (1.2.3 → is compatible with 1.2.x).
|
* launches the browser (1.2.3 → is compatible with 1.2.x).
|
||||||
*
|
*
|
||||||
* @param endpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
|
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Browser connect(String endpoint, ConnectOptions options);
|
Browser connect(String wsEndpoint, ConnectOptions options);
|
||||||
/**
|
/**
|
||||||
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
||||||
*
|
*
|
||||||
@@ -1314,9 +1252,6 @@ public interface BrowserType {
|
|||||||
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
|
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
|
||||||
* BrowserType.connect()}.
|
* BrowserType.connect()}.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> Playwright maintains a curated list of arguments for launching the browser. If you launch the browser without Playwright
|
|
||||||
* and do not pass the exact same arguments, some of Playwright functionality may be broken upon connecting to the browser.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
* <p> <strong>Usage</strong>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
||||||
@@ -1343,9 +1278,6 @@ public interface BrowserType {
|
|||||||
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
|
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
|
||||||
* BrowserType.connect()}.
|
* BrowserType.connect()}.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> Playwright maintains a curated list of arguments for launching the browser. If you launch the browser without Playwright
|
|
||||||
* and do not pass the exact same arguments, some of Playwright functionality may be broken upon connecting to the browser.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
* <p> <strong>Usage</strong>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
||||||
|
|||||||
@@ -48,16 +48,6 @@ import com.google.gson.JsonObject;
|
|||||||
* }</pre>
|
* }</pre>
|
||||||
*/
|
*/
|
||||||
public interface CDPSession {
|
public interface CDPSession {
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when the session is closed, either because the target was closed or {@code session.detach()} was called.
|
|
||||||
*/
|
|
||||||
void onClose(Consumer<CDPSession> handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onClose onClose(handler)}.
|
|
||||||
*/
|
|
||||||
void offClose(Consumer<CDPSession> handler);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
|
* Detaches the CDPSession from the target. Once detached, the CDPSession object won't emit any events and can't be used to
|
||||||
* send messages.
|
* send messages.
|
||||||
|
|||||||
@@ -17,12 +17,9 @@
|
|||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import com.microsoft.playwright.impl.driver.Driver;
|
import com.microsoft.playwright.impl.driver.Driver;
|
||||||
import com.microsoft.playwright.impl.driver.jar.DriverJar;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
@@ -31,13 +28,7 @@ import static java.util.Arrays.asList;
|
|||||||
* Use this class to launch playwright cli.
|
* Use this class to launch playwright cli.
|
||||||
*/
|
*/
|
||||||
public class CLI {
|
public class CLI {
|
||||||
public static void main(String[] args) throws IOException, InterruptedException, URISyntaxException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
// Extract the driver into a fixed directory instead of running the playwright CLI. This is
|
|
||||||
// handled in Java because it must not require an already-extracted driver. See issue #1268.
|
|
||||||
if (args.length > 0 && "install-driver".equals(args[0])) {
|
|
||||||
installDriver(args);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Driver driver = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
|
Driver driver = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
|
||||||
ProcessBuilder pb = driver.createProcessBuilder();
|
ProcessBuilder pb = driver.createProcessBuilder();
|
||||||
pb.command().addAll(asList(args));
|
pb.command().addAll(asList(args));
|
||||||
@@ -49,17 +40,4 @@ public class CLI {
|
|||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
System.exit(process.waitFor());
|
System.exit(process.waitFor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void installDriver(String[] args) throws IOException, URISyntaxException {
|
|
||||||
String dir = args.length > 1 ? args[1] : System.getenv(Driver.PLAYWRIGHT_DRIVER_DIR);
|
|
||||||
if (dir == null) {
|
|
||||||
System.err.println("Usage: install-driver <dir> (or set the " + Driver.PLAYWRIGHT_DRIVER_DIR
|
|
||||||
+ " environment variable)");
|
|
||||||
System.exit(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Path driverDir = Paths.get(dir);
|
|
||||||
DriverJar.installDriverTo(driverDir);
|
|
||||||
System.out.println("Installed Playwright driver into " + driverDir.toAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,12 +69,6 @@ public interface ConsoleMessage {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
String text();
|
String text();
|
||||||
/**
|
|
||||||
* The timestamp of the console message in milliseconds since the Unix epoch.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
double timestamp();
|
|
||||||
/**
|
/**
|
||||||
* One of the following values: {@code "log"}, {@code "debug"}, {@code "info"}, {@code "error"}, {@code "warning"}, {@code
|
* One of the following values: {@code "log"}, {@code "debug"}, {@code "info"}, {@code "error"}, {@code "warning"}, {@code
|
||||||
* "dir"}, {@code "dirxml"}, {@code "table"}, {@code "trace"}, {@code "clear"}, {@code "startGroup"}, {@code
|
* "dir"}, {@code "dirxml"}, {@code "table"}, {@code "trace"}, {@code "clear"}, {@code "startGroup"}, {@code
|
||||||
|
|||||||
@@ -1,243 +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 com.microsoft.playwright.options.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@code Credentials} is a virtual WebAuthn authenticator scoped to a {@code BrowserContext}. It lets tests register
|
|
||||||
* passkeys and answer {@code navigator.credentials.create()} / {@code navigator.credentials.get()} ceremonies in the page,
|
|
||||||
* without a real authenticator or hardware security key.
|
|
||||||
*
|
|
||||||
* <p> There are three common ways to use it:
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage: seed a known credential</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* BrowserContext context = browser.newContext();
|
|
||||||
*
|
|
||||||
* // A passkey your backend already provisioned for a test user.
|
|
||||||
* context.credentials().create("example.com", new Credentials.CreateOptions()
|
|
||||||
* .setId(knownCredentialId) // base64url
|
|
||||||
* .setUserHandle(knownUserHandle) // base64url
|
|
||||||
* .setPrivateKey(knownPrivateKey) // base64url PKCS#8 (DER)
|
|
||||||
* .setPublicKey(knownPublicKey)); // base64url SPKI (DER)
|
|
||||||
* context.credentials().install();
|
|
||||||
*
|
|
||||||
* Page page = context.newPage();
|
|
||||||
* page.navigate("https://example.com/login");
|
|
||||||
* // The page's navigator.credentials.get() is answered with the seeded passkey.
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage: capture a credential, then reuse it</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* // setup test: let the app register a passkey, then save it.
|
|
||||||
* BrowserContext context = browser.newContext();
|
|
||||||
* context.credentials().install();
|
|
||||||
*
|
|
||||||
* Page page = context.newPage();
|
|
||||||
* page.navigate("https://example.com/register");
|
|
||||||
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Create a passkey")).click();
|
|
||||||
*
|
|
||||||
* // Read back the passkey the page registered — it includes the private key.
|
|
||||||
* VirtualCredential credential = context.credentials().get(
|
|
||||||
* new Credentials.GetOptions().setRpId("example.com")).get(0);
|
|
||||||
* Files.writeString(Paths.get("playwright/.auth/passkey.json"), new Gson().toJson(credential));
|
|
||||||
* }</pre>
|
|
||||||
* <pre>{@code
|
|
||||||
* // later test: seed the captured passkey so the app starts already enrolled.
|
|
||||||
* VirtualCredential credential = new Gson().fromJson(
|
|
||||||
* Files.readString(Paths.get("playwright/.auth/passkey.json")), VirtualCredential.class);
|
|
||||||
* BrowserContext context = browser.newContext();
|
|
||||||
* context.credentials().create(credential.rpId, new Credentials.CreateOptions()
|
|
||||||
* .setId(credential.id)
|
|
||||||
* .setUserHandle(credential.userHandle)
|
|
||||||
* .setPrivateKey(credential.privateKey)
|
|
||||||
* .setPublicKey(credential.publicKey));
|
|
||||||
* context.credentials().install();
|
|
||||||
*
|
|
||||||
* Page page = context.newPage();
|
|
||||||
* page.navigate("https://example.com/login");
|
|
||||||
* // navigator.credentials.get() resolves the captured passkey — already signed in.
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage: save credentials in the storage state, restore later</strong>
|
|
||||||
*
|
|
||||||
* <p> See <a href="https://playwright.dev/java/docs/auth">authentication guide</a> for examples of using saving and resotring
|
|
||||||
* the storage state.
|
|
||||||
*
|
|
||||||
* <p> <strong>Defaults</strong>
|
|
||||||
*/
|
|
||||||
public interface Credentials {
|
|
||||||
class CreateOptions {
|
|
||||||
/**
|
|
||||||
* Base64url-encoded credential id. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public String id;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded PKCS#8 (DER) private key. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public String privateKey;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded SPKI (DER) public key. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public String publicKey;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded user handle. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public String userHandle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base64url-encoded credential id. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public CreateOptions setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Base64url-encoded PKCS#8 (DER) private key. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public CreateOptions setPrivateKey(String privateKey) {
|
|
||||||
this.privateKey = privateKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Base64url-encoded SPKI (DER) public key. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public CreateOptions setPublicKey(String publicKey) {
|
|
||||||
this.publicKey = publicKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Base64url-encoded user handle. Auto-generated if omitted.
|
|
||||||
*/
|
|
||||||
public CreateOptions setUserHandle(String userHandle) {
|
|
||||||
this.userHandle = userHandle;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class GetOptions {
|
|
||||||
/**
|
|
||||||
* Only return the credential with this base64url-encoded id.
|
|
||||||
*/
|
|
||||||
public String id;
|
|
||||||
/**
|
|
||||||
* Only return credentials for this relying party id.
|
|
||||||
*/
|
|
||||||
public String rpId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only return the credential with this base64url-encoded id.
|
|
||||||
*/
|
|
||||||
public GetOptions setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Only return credentials for this relying party id.
|
|
||||||
*/
|
|
||||||
public GetOptions setRpId(String rpId) {
|
|
||||||
this.rpId = rpId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Installs the virtual WebAuthn authenticator into the context, overriding {@code navigator.credentials.create()} and
|
|
||||||
* {@code navigator.credentials.get()} in all current and future pages. Call this before the page first touches {@code
|
|
||||||
* navigator.credentials}.
|
|
||||||
*
|
|
||||||
* <p> Required: until {@link com.microsoft.playwright.Credentials#install Credentials.install()} is called, no interception is
|
|
||||||
* in place and the page sees the platform's native (or absent) WebAuthn behaviour. Seeding credentials with {@link
|
|
||||||
* com.microsoft.playwright.Credentials#create Credentials.create()} without installing populates the authenticator, but
|
|
||||||
* the page will never see those credentials.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
void install();
|
|
||||||
/**
|
|
||||||
* Seeds a virtual WebAuthn credential and returns it.
|
|
||||||
*
|
|
||||||
* <p> With only {@code rpId}, generates a fresh **ECDSA P-256** keypair, credential id and user handle. The seeded credential
|
|
||||||
* is discoverable (resident), so the page can resolve it from both username-then-passkey and usernameless passkey flows.
|
|
||||||
* The returned object carries the private and public keys, so it can be persisted to disk and re-seeded in a later test.
|
|
||||||
*
|
|
||||||
* <p> To **import a known credential**, supply all four of {@code id}, {@code userHandle}, {@code privateKey} and {@code
|
|
||||||
* publicKey} together.
|
|
||||||
*
|
|
||||||
* <p> Call {@link com.microsoft.playwright.Credentials#install Credentials.install()} before navigating to a page that uses
|
|
||||||
* WebAuthn.
|
|
||||||
*
|
|
||||||
* @param rpId Relying party id (typically the site's effective domain).
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
default VirtualCredential create(String rpId) {
|
|
||||||
return create(rpId, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Seeds a virtual WebAuthn credential and returns it.
|
|
||||||
*
|
|
||||||
* <p> With only {@code rpId}, generates a fresh **ECDSA P-256** keypair, credential id and user handle. The seeded credential
|
|
||||||
* is discoverable (resident), so the page can resolve it from both username-then-passkey and usernameless passkey flows.
|
|
||||||
* The returned object carries the private and public keys, so it can be persisted to disk and re-seeded in a later test.
|
|
||||||
*
|
|
||||||
* <p> To **import a known credential**, supply all four of {@code id}, {@code userHandle}, {@code privateKey} and {@code
|
|
||||||
* publicKey} together.
|
|
||||||
*
|
|
||||||
* <p> Call {@link com.microsoft.playwright.Credentials#install Credentials.install()} before navigating to a page that uses
|
|
||||||
* WebAuthn.
|
|
||||||
*
|
|
||||||
* @param rpId Relying party id (typically the site's effective domain).
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
VirtualCredential create(String rpId, CreateOptions options);
|
|
||||||
/**
|
|
||||||
* Removes a credential from the authenticator by its id. Works for any credential currently held — both those seeded with
|
|
||||||
* {@link com.microsoft.playwright.Credentials#create Credentials.create()} and those the page registered itself by calling
|
|
||||||
* {@code navigator.credentials.create()}.
|
|
||||||
*
|
|
||||||
* @param id Base64url-encoded credential id.
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
void delete(String id);
|
|
||||||
/**
|
|
||||||
* Returns every credential currently held by the authenticator, optionally filtered by {@code rpId} or {@code id}. This
|
|
||||||
* includes both credentials seeded with {@link com.microsoft.playwright.Credentials#create Credentials.create()} and
|
|
||||||
* credentials the page registered itself by calling {@code navigator.credentials.create()}.
|
|
||||||
*
|
|
||||||
* <p> Each returned credential includes its private and public keys, so a passkey the app just registered can be saved and
|
|
||||||
* re-seeded into a later test with {@link com.microsoft.playwright.Credentials#create Credentials.create()} — see the
|
|
||||||
* second example in the class overview.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
default List<VirtualCredential> get() {
|
|
||||||
return get(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns every credential currently held by the authenticator, optionally filtered by {@code rpId} or {@code id}. This
|
|
||||||
* includes both credentials seeded with {@link com.microsoft.playwright.Credentials#create Credentials.create()} and
|
|
||||||
* credentials the page registered itself by calling {@code navigator.credentials.create()}.
|
|
||||||
*
|
|
||||||
* <p> Each returned credential includes its private and public keys, so a passkey the app just registered can be saved and
|
|
||||||
* re-seeded into a later test with {@link com.microsoft.playwright.Credentials#create Credentials.create()} — see the
|
|
||||||
* second example in the class overview.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
List<VirtualCredential> get(GetOptions options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,78 +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 com.microsoft.playwright.options.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API for controlling the Playwright debugger. The debugger allows pausing script execution and inspecting the page.
|
|
||||||
* Obtain the debugger instance via {@link com.microsoft.playwright.BrowserContext#debugger BrowserContext.debugger()}.
|
|
||||||
*/
|
|
||||||
public interface Debugger {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when the debugger pauses or resumes.
|
|
||||||
*/
|
|
||||||
void onPausedStateChanged(Runnable handler);
|
|
||||||
/**
|
|
||||||
* Removes handler that was previously added with {@link #onPausedStateChanged onPausedStateChanged(handler)}.
|
|
||||||
*/
|
|
||||||
void offPausedStateChanged(Runnable handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns details about the currently paused call. Returns {@code null} if the debugger is not paused.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
DebuggerPausedDetails pausedDetails();
|
|
||||||
/**
|
|
||||||
* Configures the debugger to pause before the next action is executed.
|
|
||||||
*
|
|
||||||
* <p> Throws if the debugger is already paused. Use {@link com.microsoft.playwright.Debugger#next Debugger.next()} or {@link
|
|
||||||
* com.microsoft.playwright.Debugger#runTo Debugger.runTo()} to step while paused.
|
|
||||||
*
|
|
||||||
* <p> Note that {@link com.microsoft.playwright.Page#pause Page.pause()} is equivalent to a "debugger" statement — it pauses
|
|
||||||
* execution at the call site immediately. On the contrary, {@link com.microsoft.playwright.Debugger#requestPause
|
|
||||||
* Debugger.requestPause()} is equivalent to "pause on next statement" — it configures the debugger to pause before the
|
|
||||||
* next action is executed.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void requestPause();
|
|
||||||
/**
|
|
||||||
* Resumes script execution. Throws if the debugger is not paused.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void resume();
|
|
||||||
/**
|
|
||||||
* Resumes script execution and pauses again before the next action. Throws if the debugger is not paused.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void next();
|
|
||||||
/**
|
|
||||||
* Resumes script execution and pauses when an action originates from the given source location. Throws if the debugger is
|
|
||||||
* not paused.
|
|
||||||
*
|
|
||||||
* @param location The source location to pause at.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void runTo(Location location);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -73,13 +73,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -124,16 +117,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public CheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -187,13 +170,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -274,16 +250,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ClickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -342,13 +308,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -422,16 +381,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DblclickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -526,13 +475,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -586,16 +528,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public HoverOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -618,12 +550,18 @@ public interface ElementHandle extends JSHandle {
|
|||||||
}
|
}
|
||||||
class InputValueOptions {
|
class InputValueOptions {
|
||||||
/**
|
/**
|
||||||
* @deprecated This option is ignored. The value is returned immediately.
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
|
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
||||||
|
* methods.
|
||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This option is ignored. The value is returned immediately.
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
|
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
||||||
|
* methods.
|
||||||
*/
|
*/
|
||||||
public InputValueOptions setTimeout(double timeout) {
|
public InputValueOptions setTimeout(double timeout) {
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@@ -714,9 +652,7 @@ public interface ElementHandle extends JSHandle {
|
|||||||
*/
|
*/
|
||||||
public Path path;
|
public Path path;
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public Integer quality;
|
public Integer quality;
|
||||||
/**
|
/**
|
||||||
@@ -804,9 +740,7 @@ public interface ElementHandle extends JSHandle {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public ScreenshotOptions setQuality(int quality) {
|
public ScreenshotOptions setQuality(int quality) {
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
@@ -962,13 +896,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1013,16 +940,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public SetCheckedOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1095,13 +1012,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1155,16 +1065,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public TapOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1242,13 +1142,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1293,16 +1186,6 @@ public interface ElementHandle extends JSHandle {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public UncheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
|
|||||||
@@ -165,13 +165,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -221,16 +214,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public CheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -292,13 +275,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -379,16 +355,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ClickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -447,13 +413,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -527,16 +486,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DblclickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -609,13 +558,6 @@ public interface Frame {
|
|||||||
* @deprecated This option has no effect.
|
* @deprecated This option has no effect.
|
||||||
*/
|
*/
|
||||||
public Boolean noWaitAfter;
|
public Boolean noWaitAfter;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -665,16 +607,6 @@ public interface Frame {
|
|||||||
this.noWaitAfter = noWaitAfter;
|
this.noWaitAfter = noWaitAfter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DragAndDropOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -935,13 +867,6 @@ public interface Frame {
|
|||||||
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
||||||
*/
|
*/
|
||||||
public Boolean checked;
|
public Boolean checked;
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public Object description;
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -950,8 +875,8 @@ public interface Frame {
|
|||||||
*/
|
*/
|
||||||
public Boolean disabled;
|
public Boolean disabled;
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public Boolean exact;
|
public Boolean exact;
|
||||||
/**
|
/**
|
||||||
@@ -1003,26 +928,6 @@ public interface Frame {
|
|||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(Pattern description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -1034,8 +939,8 @@ public interface Frame {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public GetByRoleOptions setExact(boolean exact) {
|
public GetByRoleOptions setExact(boolean exact) {
|
||||||
this.exact = exact;
|
this.exact = exact;
|
||||||
@@ -1224,13 +1129,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -1290,16 +1188,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public HoverOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -1857,13 +1745,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -1913,16 +1794,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public SetCheckedOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2065,13 +1936,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2131,16 +1995,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public TapOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2273,13 +2127,6 @@ public interface Frame {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2329,16 +2176,6 @@ public interface Frame {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public UncheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2435,7 +2272,7 @@ public interface Frame {
|
|||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -2465,7 +2302,7 @@ public interface Frame {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -2474,7 +2311,7 @@ public interface Frame {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -2483,7 +2320,7 @@ public interface Frame {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -3101,7 +2938,7 @@ public interface Frame {
|
|||||||
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Frame#evaluate
|
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Frame#evaluate
|
||||||
* Frame.evaluate()}:
|
* Frame.evaluate()}:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* ElementHandle bodyHandle = frame.evaluateHandle("document.body");
|
* ElementHandle bodyHandle = frame.evaluate("document.body");
|
||||||
* String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
* String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
||||||
* bodyHandle.dispose();
|
* bodyHandle.dispose();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -3141,7 +2978,7 @@ public interface Frame {
|
|||||||
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Frame#evaluate
|
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Frame#evaluate
|
||||||
* Frame.evaluate()}:
|
* Frame.evaluate()}:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* ElementHandle bodyHandle = frame.evaluateHandle("document.body");
|
* ElementHandle bodyHandle = frame.evaluate("document.body");
|
||||||
* String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
* String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
||||||
* bodyHandle.dispose();
|
* bodyHandle.dispose();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -3543,7 +3380,7 @@ public interface Frame {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -3586,7 +3423,7 @@ public interface Frame {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -3625,7 +3462,7 @@ public interface Frame {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -3647,7 +3484,7 @@ public interface Frame {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -5302,7 +5139,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -5319,7 +5156,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -5334,7 +5171,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -5351,7 +5188,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -5366,7 +5203,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -5383,7 +5220,7 @@ public interface Frame {
|
|||||||
* frame.waitForURL("**\/target.html");
|
* frame.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
|
|||||||
@@ -107,13 +107,6 @@ public interface FrameLocator {
|
|||||||
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
||||||
*/
|
*/
|
||||||
public Boolean checked;
|
public Boolean checked;
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public Object description;
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -122,8 +115,8 @@ public interface FrameLocator {
|
|||||||
*/
|
*/
|
||||||
public Boolean disabled;
|
public Boolean disabled;
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public Boolean exact;
|
public Boolean exact;
|
||||||
/**
|
/**
|
||||||
@@ -175,26 +168,6 @@ public interface FrameLocator {
|
|||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(Pattern description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -206,8 +179,8 @@ public interface FrameLocator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public GetByRoleOptions setExact(boolean exact) {
|
public GetByRoleOptions setExact(boolean exact) {
|
||||||
this.exact = exact;
|
this.exact = exact;
|
||||||
@@ -629,7 +602,7 @@ public interface FrameLocator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -672,7 +645,7 @@ public interface FrameLocator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -711,7 +684,7 @@ public interface FrameLocator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -733,7 +706,7 @@ public interface FrameLocator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
|
|||||||
@@ -30,22 +30,6 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public interface Locator {
|
public interface Locator {
|
||||||
class AriaSnapshotOptions {
|
class AriaSnapshotOptions {
|
||||||
/**
|
|
||||||
* When {@code true}, appends each element's bounding box as {@code [box=x,y,width,height]} to the snapshot. Coordinates
|
|
||||||
* are relative to the viewport, in CSS pixels, as returned by <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">{@code
|
|
||||||
* Element.getBoundingClientRect()}</a>. Defaults to {@code false}.
|
|
||||||
*/
|
|
||||||
public Boolean boxes;
|
|
||||||
/**
|
|
||||||
* When specified, limits the depth of the snapshot.
|
|
||||||
*/
|
|
||||||
public Integer depth;
|
|
||||||
/**
|
|
||||||
* When set to {@code "ai"}, returns a snapshot optimized for AI consumption. Defaults to {@code "default"}. See details
|
|
||||||
* for more information.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotMode mode;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -54,31 +38,6 @@ public interface Locator {
|
|||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
|
|
||||||
/**
|
|
||||||
* When {@code true}, appends each element's bounding box as {@code [box=x,y,width,height]} to the snapshot. Coordinates
|
|
||||||
* are relative to the viewport, in CSS pixels, as returned by <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">{@code
|
|
||||||
* Element.getBoundingClientRect()}</a>. Defaults to {@code false}.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setBoxes(boolean boxes) {
|
|
||||||
this.boxes = boxes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* When specified, limits the depth of the snapshot.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setDepth(int depth) {
|
|
||||||
this.depth = depth;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* When set to {@code "ai"}, returns a snapshot optimized for AI consumption. Defaults to {@code "default"}. See details
|
|
||||||
* for more information.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setMode(AriaSnapshotMode mode) {
|
|
||||||
this.mode = mode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -145,13 +104,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -196,16 +148,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public CheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -303,13 +245,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -391,16 +326,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ClickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -460,13 +385,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -541,16 +459,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DblclickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
* Defaults to 1. Sends {@code n} interpolated {@code mousemove} events to represent travel between Playwright's current
|
||||||
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
* cursor position and the provided destination. When set to 1, emits a single {@code mousemove} event at the destination
|
||||||
@@ -611,13 +519,6 @@ public interface Locator {
|
|||||||
* @deprecated This option has no effect.
|
* @deprecated This option has no effect.
|
||||||
*/
|
*/
|
||||||
public Boolean noWaitAfter;
|
public Boolean noWaitAfter;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -662,16 +563,6 @@ public interface Locator {
|
|||||||
this.noWaitAfter = noWaitAfter;
|
this.noWaitAfter = noWaitAfter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DragToOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -730,46 +621,6 @@ public interface Locator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class DropOptions {
|
|
||||||
/**
|
|
||||||
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
|
|
||||||
* element.
|
|
||||||
*/
|
|
||||||
public Position position;
|
|
||||||
/**
|
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public Double timeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
|
|
||||||
* element.
|
|
||||||
*/
|
|
||||||
public DropOptions setPosition(double x, double y) {
|
|
||||||
return setPosition(new Position(x, y));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
|
|
||||||
* element.
|
|
||||||
*/
|
|
||||||
public DropOptions setPosition(Position position) {
|
|
||||||
this.position = position;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public DropOptions setTimeout(double timeout) {
|
|
||||||
this.timeout = timeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ElementHandleOptions {
|
class ElementHandleOptions {
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
@@ -1068,13 +919,6 @@ public interface Locator {
|
|||||||
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
||||||
*/
|
*/
|
||||||
public Boolean checked;
|
public Boolean checked;
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public Object description;
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -1083,8 +927,8 @@ public interface Locator {
|
|||||||
*/
|
*/
|
||||||
public Boolean disabled;
|
public Boolean disabled;
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public Boolean exact;
|
public Boolean exact;
|
||||||
/**
|
/**
|
||||||
@@ -1136,26 +980,6 @@ public interface Locator {
|
|||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(Pattern description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -1167,8 +991,8 @@ public interface Locator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public GetByRoleOptions setExact(boolean exact) {
|
public GetByRoleOptions setExact(boolean exact) {
|
||||||
this.exact = exact;
|
this.exact = exact;
|
||||||
@@ -1274,20 +1098,6 @@ public interface Locator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class HighlightOptions {
|
|
||||||
/**
|
|
||||||
* Additional inline CSS applied to the highlight overlay, e.g. {@code "outline: 2px dashed red"}.
|
|
||||||
*/
|
|
||||||
public String style;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Additional inline CSS applied to the highlight overlay, e.g. {@code "outline: 2px dashed red"}.
|
|
||||||
*/
|
|
||||||
public HighlightOptions setStyle(String style) {
|
|
||||||
this.style = style;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class HoverOptions {
|
class HoverOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
||||||
@@ -1309,13 +1119,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1370,16 +1173,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public HoverOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -1795,9 +1588,7 @@ public interface Locator {
|
|||||||
*/
|
*/
|
||||||
public Path path;
|
public Path path;
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public Integer quality;
|
public Integer quality;
|
||||||
/**
|
/**
|
||||||
@@ -1885,9 +1676,7 @@ public interface Locator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public ScreenshotOptions setQuality(int quality) {
|
public ScreenshotOptions setQuality(int quality) {
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
@@ -2043,13 +1832,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2094,16 +1876,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public SetCheckedOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2176,13 +1948,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2237,16 +2002,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public TapOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2345,13 +2100,6 @@ public interface Locator {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2396,16 +2144,6 @@ public interface Locator {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public UncheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||||
@@ -2473,26 +2211,6 @@ public interface Locator {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class WaitForFunctionOptions {
|
|
||||||
/**
|
|
||||||
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
|
|
||||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public Double timeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
|
|
||||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public WaitForFunctionOptions setTimeout(double timeout) {
|
|
||||||
this.timeout = timeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.
|
* When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.
|
||||||
*
|
*
|
||||||
@@ -2519,7 +2237,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> <strong>Usage</strong>
|
* <p> <strong>Usage</strong>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* List<String> texts = page.getByRole(AriaRole.LINK).allInnerTexts();
|
* String[] texts = page.getByRole(AriaRole.LINK).allInnerTexts();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @since v1.14
|
* @since v1.14
|
||||||
@@ -2534,7 +2252,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> <strong>Usage</strong>
|
* <p> <strong>Usage</strong>
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* List<String> texts = page.getByRole(AriaRole.LINK).allTextContents();
|
* String[] texts = page.getByRole(AriaRole.LINK).allTextContents();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @since v1.14
|
* @since v1.14
|
||||||
@@ -2580,12 +2298,6 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Below is the HTML markup and the respective ARIA snapshot:
|
* <p> Below is the HTML markup and the respective ARIA snapshot:
|
||||||
*
|
*
|
||||||
* <p> An AI-optimized snapshot, controlled by {@code mode}, is different from a default snapshot:
|
|
||||||
* <ol>
|
|
||||||
* <li> Includes element references {@code [ref=e2]}. 2. Does not wait for an element matching the locator, and throws when no
|
|
||||||
* elements match. 3. Includes snapshots of {@code <iframe>}s inside the target.</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* @since v1.49
|
* @since v1.49
|
||||||
*/
|
*/
|
||||||
default String ariaSnapshot() {
|
default String ariaSnapshot() {
|
||||||
@@ -2617,12 +2329,6 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Below is the HTML markup and the respective ARIA snapshot:
|
* <p> Below is the HTML markup and the respective ARIA snapshot:
|
||||||
*
|
*
|
||||||
* <p> An AI-optimized snapshot, controlled by {@code mode}, is different from a default snapshot:
|
|
||||||
* <ol>
|
|
||||||
* <li> Includes element references {@code [ref=e2]}. 2. Does not wait for an element matching the locator, and throws when no
|
|
||||||
* elements match. 3. Includes snapshots of {@code <iframe>}s inside the target.</li>
|
|
||||||
* </ol>
|
|
||||||
*
|
|
||||||
* @since v1.49
|
* @since v1.49
|
||||||
*/
|
*/
|
||||||
String ariaSnapshot(AriaSnapshotOptions options);
|
String ariaSnapshot(AriaSnapshotOptions options);
|
||||||
@@ -3158,54 +2864,6 @@ public interface Locator {
|
|||||||
* @since v1.18
|
* @since v1.18
|
||||||
*/
|
*/
|
||||||
void dragTo(Locator target, DragToOptions options);
|
void dragTo(Locator target, DragToOptions options);
|
||||||
/**
|
|
||||||
* Simulate an external drag-and-drop of files or clipboard-like data onto this locator.
|
|
||||||
*
|
|
||||||
* <p> <strong>Details</strong>
|
|
||||||
*
|
|
||||||
* <p> Dispatches the native {@code dragenter}, {@code dragover}, and {@code drop} events at the center of the target element
|
|
||||||
* with a synthetic [DataTransfer] carrying the provided files and/or data entries. Works cross-browser by constructing the
|
|
||||||
* [DataTransfer] in the page context.
|
|
||||||
*
|
|
||||||
* <p> If the target element's {@code dragover} listener does not call {@code preventDefault()}, the target is considered to
|
|
||||||
* have rejected the drop: Playwright dispatches {@code dragleave} and this method throws.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> Drop a file buffer onto an upload area:
|
|
||||||
*
|
|
||||||
* <p> Drop plain text and a URL together:
|
|
||||||
*
|
|
||||||
* @param payload Data to drop onto the target. Provide {@code files} (file paths or in-memory buffers), {@code data} (a mime-type →
|
|
||||||
* string map for clipboard-like content such as {@code text/plain}, {@code text/html}, {@code text/uri-list}), or both.
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
default void drop(DropPayload payload) {
|
|
||||||
drop(payload, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Simulate an external drag-and-drop of files or clipboard-like data onto this locator.
|
|
||||||
*
|
|
||||||
* <p> <strong>Details</strong>
|
|
||||||
*
|
|
||||||
* <p> Dispatches the native {@code dragenter}, {@code dragover}, and {@code drop} events at the center of the target element
|
|
||||||
* with a synthetic [DataTransfer] carrying the provided files and/or data entries. Works cross-browser by constructing the
|
|
||||||
* [DataTransfer] in the page context.
|
|
||||||
*
|
|
||||||
* <p> If the target element's {@code dragover} listener does not call {@code preventDefault()}, the target is considered to
|
|
||||||
* have rejected the drop: Playwright dispatches {@code dragleave} and this method throws.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> Drop a file buffer onto an upload area:
|
|
||||||
*
|
|
||||||
* <p> Drop plain text and a URL together:
|
|
||||||
*
|
|
||||||
* @param payload Data to drop onto the target. Provide {@code files} (file paths or in-memory buffers), {@code data} (a mime-type →
|
|
||||||
* string map for clipboard-like content such as {@code text/plain}, {@code text/html}, {@code text/uri-list}), or both.
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
void drop(DropPayload payload, DropOptions options);
|
|
||||||
/**
|
/**
|
||||||
* Resolves given locator to the first matching DOM element. If there are no matching elements, waits for one. If multiple
|
* Resolves given locator to the first matching DOM element. If there are no matching elements, waits for one. If multiple
|
||||||
* elements match the locator, throws.
|
* elements match the locator, throws.
|
||||||
@@ -3834,7 +3492,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -3877,7 +3535,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -3916,7 +3574,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -3938,7 +3596,7 @@ public interface Locator {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -4185,28 +3843,13 @@ public interface Locator {
|
|||||||
* @since v1.27
|
* @since v1.27
|
||||||
*/
|
*/
|
||||||
Locator getByTitle(Pattern text, GetByTitleOptions options);
|
Locator getByTitle(Pattern text, GetByTitleOptions options);
|
||||||
/**
|
|
||||||
* Hides the element highlight previously added by {@link com.microsoft.playwright.Locator#highlight Locator.highlight()}.
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
void hideHighlight();
|
|
||||||
/**
|
/**
|
||||||
* Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses {@link
|
* Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses {@link
|
||||||
* com.microsoft.playwright.Locator#highlight Locator.highlight()}.
|
* com.microsoft.playwright.Locator#highlight Locator.highlight()}.
|
||||||
*
|
*
|
||||||
* @since v1.20
|
* @since v1.20
|
||||||
*/
|
*/
|
||||||
default AutoCloseable highlight() {
|
void highlight();
|
||||||
return highlight(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses {@link
|
|
||||||
* com.microsoft.playwright.Locator#highlight Locator.highlight()}.
|
|
||||||
*
|
|
||||||
* @since v1.20
|
|
||||||
*/
|
|
||||||
AutoCloseable highlight(HighlightOptions options);
|
|
||||||
/**
|
/**
|
||||||
* Hover over the matching element.
|
* Hover over the matching element.
|
||||||
*
|
*
|
||||||
@@ -4602,14 +4245,6 @@ public interface Locator {
|
|||||||
* @since v1.14
|
* @since v1.14
|
||||||
*/
|
*/
|
||||||
Locator locator(Locator selectorOrLocator, LocatorOptions options);
|
Locator locator(Locator selectorOrLocator, LocatorOptions options);
|
||||||
/**
|
|
||||||
* Returns a new locator that uses best practices for referencing the matched element, prioritizing test ids, aria roles,
|
|
||||||
* and other user-facing attributes over CSS selectors. This is useful for converting implementation-detail selectors into
|
|
||||||
* more resilient, human-readable locators.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
Locator normalize();
|
|
||||||
/**
|
/**
|
||||||
* Returns locator to the n-th matching element. It's zero based, {@code nth(0)} selects the first element.
|
* Returns locator to the n-th matching element. It's zero based, {@code nth(0)} selects the first element.
|
||||||
*
|
*
|
||||||
@@ -5856,83 +5491,5 @@ public interface Locator {
|
|||||||
* @since v1.16
|
* @since v1.16
|
||||||
*/
|
*/
|
||||||
void waitFor(WaitForOptions options);
|
void waitFor(WaitForOptions options);
|
||||||
/**
|
|
||||||
* Returns when {@code expression} returns a truthy value, called with the matching element as a first argument, and {@code
|
|
||||||
* arg} as a second argument.
|
|
||||||
*
|
|
||||||
* <p> This is a generic way to wait for an element to reach a custom condition without asserting it. The locator is
|
|
||||||
* re-resolved on each retry, so it tolerates the element being re-rendered while waiting.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} returns a <a
|
|
||||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, this method
|
|
||||||
* will wait for the promise to resolve before checking its value.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} throws or rejects, this method throws.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> Wait for an attribute to appear:
|
|
||||||
*
|
|
||||||
* <p> Passing argument to {@code expression}:
|
|
||||||
*
|
|
||||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
|
||||||
* automatically invoked.
|
|
||||||
* @param arg Optional argument to pass to {@code expression}.
|
|
||||||
* @since v1.62
|
|
||||||
*/
|
|
||||||
default void waitForFunction(String expression, Object arg) {
|
|
||||||
waitForFunction(expression, arg, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns when {@code expression} returns a truthy value, called with the matching element as a first argument, and {@code
|
|
||||||
* arg} as a second argument.
|
|
||||||
*
|
|
||||||
* <p> This is a generic way to wait for an element to reach a custom condition without asserting it. The locator is
|
|
||||||
* re-resolved on each retry, so it tolerates the element being re-rendered while waiting.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} returns a <a
|
|
||||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, this method
|
|
||||||
* will wait for the promise to resolve before checking its value.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} throws or rejects, this method throws.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> Wait for an attribute to appear:
|
|
||||||
*
|
|
||||||
* <p> Passing argument to {@code expression}:
|
|
||||||
*
|
|
||||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
|
||||||
* automatically invoked.
|
|
||||||
* @since v1.62
|
|
||||||
*/
|
|
||||||
default void waitForFunction(String expression) {
|
|
||||||
waitForFunction(expression, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns when {@code expression} returns a truthy value, called with the matching element as a first argument, and {@code
|
|
||||||
* arg} as a second argument.
|
|
||||||
*
|
|
||||||
* <p> This is a generic way to wait for an element to reach a custom condition without asserting it. The locator is
|
|
||||||
* re-resolved on each retry, so it tolerates the element being re-rendered while waiting.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} returns a <a
|
|
||||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, this method
|
|
||||||
* will wait for the promise to resolve before checking its value.
|
|
||||||
*
|
|
||||||
* <p> If {@code expression} throws or rejects, this method throws.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> Wait for an attribute to appear:
|
|
||||||
*
|
|
||||||
* <p> Passing argument to {@code expression}:
|
|
||||||
*
|
|
||||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
|
||||||
* automatically invoked.
|
|
||||||
* @param arg Optional argument to pass to {@code expression}.
|
|
||||||
* @since v1.62
|
|
||||||
*/
|
|
||||||
void waitForFunction(String expression, Object arg, WaitForFunctionOptions options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -435,13 +435,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -491,16 +484,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public CheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -562,13 +545,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -649,16 +625,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ClickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -744,13 +710,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -824,16 +783,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DblclickOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -906,13 +855,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @deprecated This option has no effect.
|
* @deprecated This option has no effect.
|
||||||
*/
|
*/
|
||||||
public Boolean noWaitAfter;
|
public Boolean noWaitAfter;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -962,16 +904,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.noWaitAfter = noWaitAfter;
|
this.noWaitAfter = noWaitAfter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public DragAndDropOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||||
* specified, some visible point of the element is used.
|
* specified, some visible point of the element is used.
|
||||||
@@ -1126,6 +1058,20 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class ExposeBindingOptions {
|
||||||
|
/**
|
||||||
|
* @deprecated This option will be removed in the future.
|
||||||
|
*/
|
||||||
|
public Boolean handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This option will be removed in the future.
|
||||||
|
*/
|
||||||
|
public ExposeBindingOptions setHandle(boolean handle) {
|
||||||
|
this.handle = handle;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
class FillOptions {
|
class FillOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
||||||
@@ -1304,13 +1250,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
* <p> Learn more about <a href="https://www.w3.org/TR/wai-aria-1.2/#aria-checked">{@code aria-checked}</a>.
|
||||||
*/
|
*/
|
||||||
public Boolean checked;
|
public Boolean checked;
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public Object description;
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -1319,8 +1258,8 @@ public interface Page extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public Boolean disabled;
|
public Boolean disabled;
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public Boolean exact;
|
public Boolean exact;
|
||||||
/**
|
/**
|
||||||
@@ -1372,26 +1311,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.checked = checked;
|
this.checked = checked;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Option to match the <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>. By
|
|
||||||
* default, matching is case-insensitive and searches for a substring, use {@code exact} to control this behavior.
|
|
||||||
*
|
|
||||||
* <p> Learn more about <a href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
|
|
||||||
*/
|
|
||||||
public GetByRoleOptions setDescription(Pattern description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
* An attribute that is usually set by {@code aria-disabled} or {@code disabled}.
|
||||||
*
|
*
|
||||||
@@ -1403,8 +1322,8 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Whether {@code name} and {@code description} are matched exactly: case-sensitive and whole-string. Defaults to false.
|
* Whether {@code name} is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when {@code name}
|
||||||
* Ignored when the value is a regular expression. Note that exact match still trims whitespace.
|
* is a regular expression. Note that exact match still trims whitespace.
|
||||||
*/
|
*/
|
||||||
public GetByRoleOptions setExact(boolean exact) {
|
public GetByRoleOptions setExact(boolean exact) {
|
||||||
this.exact = exact;
|
this.exact = exact;
|
||||||
@@ -1691,13 +1610,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -1757,16 +1669,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public HoverOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2085,20 +1987,6 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class ConsoleMessagesOptions {
|
|
||||||
/**
|
|
||||||
* Controls which messages are returned:
|
|
||||||
*/
|
|
||||||
public ConsoleMessagesFilter filter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls which messages are returned:
|
|
||||||
*/
|
|
||||||
public ConsoleMessagesOptions setFilter(ConsoleMessagesFilter filter) {
|
|
||||||
this.filter = filter;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class LocatorOptions {
|
class LocatorOptions {
|
||||||
/**
|
/**
|
||||||
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
|
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
|
||||||
@@ -2683,9 +2571,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public Path path;
|
public Path path;
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public Integer quality;
|
public Integer quality;
|
||||||
/**
|
/**
|
||||||
@@ -2794,9 +2680,7 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The quality of the image, between 0-100. Not applicable to {@code png} images. For {@code jpeg} the default is {@code
|
* The quality of the image, between 0-100. Not applicable to {@code png} images.
|
||||||
* 80}. For {@code webp}, a quality of {@code 100} (the default) produces a lossless image, while lower values use lossy
|
|
||||||
* compression.
|
|
||||||
*/
|
*/
|
||||||
public ScreenshotOptions setQuality(int quality) {
|
public ScreenshotOptions setQuality(int quality) {
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
@@ -2912,13 +2796,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -2968,16 +2845,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public SetCheckedOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -3099,67 +2966,6 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class AriaSnapshotOptions {
|
|
||||||
/**
|
|
||||||
* When {@code true}, appends each element's bounding box as {@code [box=x,y,width,height]} to the snapshot. Coordinates
|
|
||||||
* are relative to the viewport, in CSS pixels, as returned by <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">{@code
|
|
||||||
* Element.getBoundingClientRect()}</a>. Defaults to {@code false}.
|
|
||||||
*/
|
|
||||||
public Boolean boxes;
|
|
||||||
/**
|
|
||||||
* When specified, limits the depth of the snapshot.
|
|
||||||
*/
|
|
||||||
public Integer depth;
|
|
||||||
/**
|
|
||||||
* When set to {@code "ai"}, returns a snapshot optimized for AI consumption: including element references like {@code
|
|
||||||
* [ref=e2]} and snapshots of {@code <iframe>}s. Defaults to {@code "default"}.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotMode mode;
|
|
||||||
/**
|
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public Double timeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When {@code true}, appends each element's bounding box as {@code [box=x,y,width,height]} to the snapshot. Coordinates
|
|
||||||
* are relative to the viewport, in CSS pixels, as returned by <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect">{@code
|
|
||||||
* Element.getBoundingClientRect()}</a>. Defaults to {@code false}.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setBoxes(boolean boxes) {
|
|
||||||
this.boxes = boxes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* When specified, limits the depth of the snapshot.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setDepth(int depth) {
|
|
||||||
this.depth = depth;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* When set to {@code "ai"}, returns a snapshot optimized for AI consumption: including element references like {@code
|
|
||||||
* [ref=e2]} and snapshots of {@code <iframe>}s. Defaults to {@code "default"}.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setMode(AriaSnapshotMode mode) {
|
|
||||||
this.mode = mode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
|
||||||
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
|
||||||
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
|
|
||||||
* methods.
|
|
||||||
*/
|
|
||||||
public AriaSnapshotOptions setTimeout(double timeout) {
|
|
||||||
this.timeout = timeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class TapOptions {
|
class TapOptions {
|
||||||
/**
|
/**
|
||||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
|
||||||
@@ -3181,13 +2987,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -3247,16 +3046,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public TapOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -3389,13 +3178,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* element.
|
* element.
|
||||||
*/
|
*/
|
||||||
public Position position;
|
public Position position;
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public ScrollMode scroll;
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -3445,16 +3227,6 @@ public interface Page extends AutoCloseable {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Controls whether Playwright scrolls the element into view before performing the action. Defaults to {@code "auto"},
|
|
||||||
* which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to {@code
|
|
||||||
* "none"}, Playwright does not scroll the element and the action fails if the element is not already in the viewport. This
|
|
||||||
* is useful to assert that an element is reachable by the user without additional scrolling.
|
|
||||||
*/
|
|
||||||
public UncheckOptions setScroll(ScrollMode scroll) {
|
|
||||||
this.scroll = scroll;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
|
||||||
* element, the call throws an exception.
|
* element, the call throws an exception.
|
||||||
@@ -3656,7 +3428,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -3686,7 +3458,7 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -3695,7 +3467,7 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -3704,7 +3476,7 @@ public interface Page extends AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
*/
|
*/
|
||||||
@@ -4040,7 +3812,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param script Script to be evaluated in all pages in the browser context.
|
* @param script Script to be evaluated in all pages in the browser context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable addInitScript(String script);
|
void addInitScript(String script);
|
||||||
/**
|
/**
|
||||||
* Adds a script which would be evaluated in one of the following scenarios:
|
* Adds a script which would be evaluated in one of the following scenarios:
|
||||||
* <ul>
|
* <ul>
|
||||||
@@ -4067,7 +3839,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param script Script to be evaluated in all pages in the browser context.
|
* @param script Script to be evaluated in all pages in the browser context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable addInitScript(Path script);
|
void addInitScript(Path script);
|
||||||
/**
|
/**
|
||||||
* Adds a {@code <script>} tag into the page with the desired url or content. Returns the added tag when the script's
|
* Adds a {@code <script>} tag into the page with the desired url or content. Returns the added tag when the script's
|
||||||
* onload fires or when the script content was injected into frame.
|
* onload fires or when the script content was injected into frame.
|
||||||
@@ -4108,13 +3880,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
void bringToFront();
|
void bringToFront();
|
||||||
/**
|
|
||||||
* Cancels an ongoing {@link com.microsoft.playwright.Page#pickLocator Page.pickLocator()} call by deactivating pick
|
|
||||||
* locator mode. If no pick locator mode is active, this method is a no-op.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void cancelPickLocator();
|
|
||||||
/**
|
/**
|
||||||
* This method checks an element matching {@code selector} by performing the following steps:
|
* This method checks an element matching {@code selector} by performing the following steps:
|
||||||
* <ol>
|
* <ol>
|
||||||
@@ -4669,7 +4434,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Page#evaluate
|
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Page#evaluate
|
||||||
* Page.evaluate()}:
|
* Page.evaluate()}:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* ElementHandle bodyHandle = page.evaluateHandle("document.body");
|
* ElementHandle bodyHandle = page.evaluate("document.body");
|
||||||
* String html = (String) page.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
* String html = (String) page.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
||||||
* bodyHandle.dispose();
|
* bodyHandle.dispose();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -4711,7 +4476,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Page#evaluate
|
* <p> {@code ElementHandle} instances can be passed as an argument to the {@link com.microsoft.playwright.Page#evaluate
|
||||||
* Page.evaluate()}:
|
* Page.evaluate()}:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* ElementHandle bodyHandle = page.evaluateHandle("document.body");
|
* ElementHandle bodyHandle = page.evaluate("document.body");
|
||||||
* String html = (String) page.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
* String html = (String) page.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
||||||
* bodyHandle.dispose();
|
* bodyHandle.dispose();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -4846,7 +4611,57 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param callback Callback function that will be called in the Playwright's context.
|
* @param callback Callback function that will be called in the Playwright's context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable exposeBinding(String name, BindingCallback callback);
|
default void exposeBinding(String name, BindingCallback callback) {
|
||||||
|
exposeBinding(name, callback, null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The method adds a function called {@code name} on the {@code window} object of every frame in this page. When called,
|
||||||
|
* the function executes {@code callback} and returns a <a
|
||||||
|
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a> which
|
||||||
|
* resolves to the return value of {@code callback}. If the {@code callback} returns a <a
|
||||||
|
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, it will be
|
||||||
|
* awaited.
|
||||||
|
*
|
||||||
|
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
|
||||||
|
* BrowserContext, page: Page, frame: Frame }}.
|
||||||
|
*
|
||||||
|
* <p> See {@link com.microsoft.playwright.BrowserContext#exposeBinding BrowserContext.exposeBinding()} for the context-wide
|
||||||
|
* version.
|
||||||
|
*
|
||||||
|
* <p> <strong>NOTE:</strong> Functions installed via {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} survive navigations.
|
||||||
|
*
|
||||||
|
* <p> <strong>Usage</strong>
|
||||||
|
*
|
||||||
|
* <p> An example of exposing page URL to all frames in a page:
|
||||||
|
* <pre>{@code
|
||||||
|
* import com.microsoft.playwright.*;
|
||||||
|
*
|
||||||
|
* public class Example {
|
||||||
|
* public static void main(String[] args) {
|
||||||
|
* try (Playwright playwright = Playwright.create()) {
|
||||||
|
* BrowserType webkit = playwright.webkit();
|
||||||
|
* Browser browser = webkit.launch(new BrowserType.LaunchOptions().setHeadless(false));
|
||||||
|
* BrowserContext context = browser.newContext();
|
||||||
|
* Page page = context.newPage();
|
||||||
|
* page.exposeBinding("pageURL", (source, args) -> source.page().url());
|
||||||
|
* page.setContent("<script>\n" +
|
||||||
|
* " async function onClick() {\n" +
|
||||||
|
* " document.querySelector('div').textContent = await window.pageURL();\n" +
|
||||||
|
* " }\n" +
|
||||||
|
* "</script>\n" +
|
||||||
|
* "<button onclick=\"onClick()\">Click me</button>\n" +
|
||||||
|
* "<div></div>");
|
||||||
|
* page.click("button");
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @param name Name of the function on the window object.
|
||||||
|
* @param callback Callback function that will be called in the Playwright's context.
|
||||||
|
* @since v1.8
|
||||||
|
*/
|
||||||
|
void exposeBinding(String name, BindingCallback callback, ExposeBindingOptions options);
|
||||||
/**
|
/**
|
||||||
* The method adds a function called {@code name} on the {@code window} object of every frame in the page. When called, the
|
* The method adds a function called {@code name} on the {@code window} object of every frame in the page. When called, the
|
||||||
* function executes {@code callback} and returns a <a
|
* function executes {@code callback} and returns a <a
|
||||||
@@ -4908,7 +4723,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param callback Callback function which will be called in Playwright's context.
|
* @param callback Callback function which will be called in Playwright's context.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable exposeFunction(String name, FunctionCallback callback);
|
void exposeFunction(String name, FunctionCallback callback);
|
||||||
/**
|
/**
|
||||||
* This method waits for an element matching {@code selector}, waits for <a
|
* This method waits for an element matching {@code selector}, waits for <a
|
||||||
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, fills it and
|
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, fills it and
|
||||||
@@ -5247,7 +5062,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -5290,7 +5105,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate each element by its implicit role:
|
* <p> You can locate each element by it's implicit role:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page
|
* assertThat(page
|
||||||
* .getByRole(AriaRole.HEADING,
|
* .getByRole(AriaRole.HEADING,
|
||||||
@@ -5329,7 +5144,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -5351,7 +5166,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Consider the following DOM structure.
|
* <p> Consider the following DOM structure.
|
||||||
*
|
*
|
||||||
* <p> You can locate the element by its test id:
|
* <p> You can locate the element by it's test id:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* page.getByTestId("directions").click();
|
* page.getByTestId("directions").click();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -5604,11 +5419,6 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Navigate to the previous page in history.
|
* <p> Navigate to the previous page in history.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache
|
|
||||||
* across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events.
|
|
||||||
* Because BFCache restores unfreeze the DOM without firing these events, using {@code page.goBack()} or {@code
|
|
||||||
* page.goForward()} to trigger a BFCache restore will result in timeouts and a desynchronized {@code Page} state.
|
|
||||||
*
|
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default Response goBack() {
|
default Response goBack() {
|
||||||
@@ -5620,11 +5430,6 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Navigate to the previous page in history.
|
* <p> Navigate to the previous page in history.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache
|
|
||||||
* across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events.
|
|
||||||
* Because BFCache restores unfreeze the DOM without firing these events, using {@code page.goBack()} or {@code
|
|
||||||
* page.goForward()} to trigger a BFCache restore will result in timeouts and a desynchronized {@code Page} state.
|
|
||||||
*
|
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Response goBack(GoBackOptions options);
|
Response goBack(GoBackOptions options);
|
||||||
@@ -5634,11 +5439,6 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Navigate to the next page in history.
|
* <p> Navigate to the next page in history.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache
|
|
||||||
* across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events.
|
|
||||||
* Because BFCache restores unfreeze the DOM without firing these events, using {@code page.goBack()} or {@code
|
|
||||||
* page.goForward()} to trigger a BFCache restore will result in timeouts and a desynchronized {@code Page} state.
|
|
||||||
*
|
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default Response goForward() {
|
default Response goForward() {
|
||||||
@@ -5650,11 +5450,6 @@ public interface Page extends AutoCloseable {
|
|||||||
*
|
*
|
||||||
* <p> Navigate to the next page in history.
|
* <p> Navigate to the next page in history.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache
|
|
||||||
* across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events.
|
|
||||||
* Because BFCache restores unfreeze the DOM without firing these events, using {@code page.goBack()} or {@code
|
|
||||||
* page.goForward()} to trigger a BFCache restore will result in timeouts and a desynchronized {@code Page} state.
|
|
||||||
*
|
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Response goForward(GoForwardOptions options);
|
Response goForward(GoForwardOptions options);
|
||||||
@@ -5737,13 +5532,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Response navigate(String url, NavigateOptions options);
|
Response navigate(String url, NavigateOptions options);
|
||||||
/**
|
|
||||||
* Hide all locator highlight overlays previously added by {@link com.microsoft.playwright.Locator#highlight
|
|
||||||
* Locator.highlight()} on this page.
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
void hideHighlight();
|
|
||||||
/**
|
/**
|
||||||
* This method hovers over an element matching {@code selector} by performing the following steps:
|
* This method hovers over an element matching {@code selector} by performing the following steps:
|
||||||
* <ol>
|
* <ol>
|
||||||
@@ -5954,48 +5742,13 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Keyboard keyboard();
|
Keyboard keyboard();
|
||||||
/**
|
|
||||||
* Clears all stored console messages from this page. Subsequent calls to {@link
|
|
||||||
* com.microsoft.playwright.Page#consoleMessages Page.consoleMessages()} will only return messages logged after the clear.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void clearConsoleMessages();
|
|
||||||
/**
|
|
||||||
* Clears all stored page errors from this page. Subsequent calls to {@link com.microsoft.playwright.Page#pageErrors
|
|
||||||
* Page.pageErrors()} will only return errors thrown after the clear.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void clearPageErrors();
|
|
||||||
/**
|
|
||||||
* Provides access to the page's {@code localStorage} for the current origin. See {@code WebStorage}.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
WebStorage localStorage();
|
|
||||||
/**
|
|
||||||
* Provides access to the page's {@code sessionStorage} for the current origin. See {@code WebStorage}.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
WebStorage sessionStorage();
|
|
||||||
/**
|
/**
|
||||||
* Returns up to (currently) 200 last console messages from this page. See {@link
|
* Returns up to (currently) 200 last console messages from this page. See {@link
|
||||||
* com.microsoft.playwright.Page#onConsoleMessage Page.onConsoleMessage()} for more details.
|
* com.microsoft.playwright.Page#onConsoleMessage Page.onConsoleMessage()} for more details.
|
||||||
*
|
*
|
||||||
* @since v1.56
|
* @since v1.56
|
||||||
*/
|
*/
|
||||||
default List<ConsoleMessage> consoleMessages() {
|
List<ConsoleMessage> consoleMessages();
|
||||||
return consoleMessages(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns up to (currently) 200 last console messages from this page. See {@link
|
|
||||||
* com.microsoft.playwright.Page#onConsoleMessage Page.onConsoleMessage()} for more details.
|
|
||||||
*
|
|
||||||
* @since v1.56
|
|
||||||
*/
|
|
||||||
List<ConsoleMessage> consoleMessages(ConsoleMessagesOptions options);
|
|
||||||
/**
|
/**
|
||||||
* Returns up to (currently) 200 last page errors from this page. See {@link com.microsoft.playwright.Page#onPageError
|
* Returns up to (currently) 200 last page errors from this page. See {@link com.microsoft.playwright.Page#onPageError
|
||||||
* Page.onPageError()} for more details.
|
* Page.onPageError()} for more details.
|
||||||
@@ -6211,19 +5964,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
byte[] pdf(PdfOptions options);
|
byte[] pdf(PdfOptions options);
|
||||||
/**
|
|
||||||
* Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator. Once the
|
|
||||||
* user clicks an element, the mode is deactivated and the {@code Locator} for the picked element is returned.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* Locator locator = page.pickLocator();
|
|
||||||
* System.out.println(locator);
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
Locator pickLocator();
|
|
||||||
/**
|
/**
|
||||||
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
||||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||||
@@ -6612,8 +6352,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6627,8 +6365,8 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(String url, Consumer<Route> handler) {
|
default void route(String url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by a page.
|
* Routing provides the capability to modify network requests that are made by a page.
|
||||||
@@ -6673,8 +6411,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6688,7 +6424,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(String url, Consumer<Route> handler, RouteOptions options);
|
void route(String url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by a page.
|
* Routing provides the capability to modify network requests that are made by a page.
|
||||||
*
|
*
|
||||||
@@ -6732,8 +6468,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6747,8 +6481,8 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(Pattern url, Consumer<Route> handler) {
|
default void route(Pattern url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by a page.
|
* Routing provides the capability to modify network requests that are made by a page.
|
||||||
@@ -6793,8 +6527,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6808,7 +6540,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(Pattern url, Consumer<Route> handler, RouteOptions options);
|
void route(Pattern url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by a page.
|
* Routing provides the capability to modify network requests that are made by a page.
|
||||||
*
|
*
|
||||||
@@ -6852,8 +6584,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6867,8 +6597,8 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default AutoCloseable route(Predicate<String> url, Consumer<Route> handler) {
|
default void route(Predicate<String> url, Consumer<Route> handler) {
|
||||||
return route(url, handler, null);
|
route(url, handler, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Routing provides the capability to modify network requests that are made by a page.
|
* Routing provides the capability to modify network requests that are made by a page.
|
||||||
@@ -6913,8 +6643,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* });
|
* });
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* <p> If a request matches multiple registered routes, the most recently registered route takes precedence.
|
|
||||||
*
|
|
||||||
* <p> Page routes take precedence over browser context routes (set up with {@link
|
* <p> Page routes take precedence over browser context routes (set up with {@link
|
||||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}) when request matches both handlers.
|
||||||
*
|
*
|
||||||
@@ -6928,7 +6656,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
AutoCloseable route(Predicate<String> url, Consumer<Route> handler, RouteOptions options);
|
void route(Predicate<String> url, Consumer<Route> handler, RouteOptions options);
|
||||||
/**
|
/**
|
||||||
* If specified the network requests that are made in the page will be served from the HAR file. Read more about <a
|
* If specified the network requests that are made in the page will be served from the HAR file. Read more about <a
|
||||||
* href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR</a>.
|
* href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR</a>.
|
||||||
@@ -7032,14 +6760,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.48
|
* @since v1.48
|
||||||
*/
|
*/
|
||||||
void routeWebSocket(Predicate<String> url, Consumer<WebSocketRoute> handler);
|
void routeWebSocket(Predicate<String> url, Consumer<WebSocketRoute> handler);
|
||||||
/**
|
|
||||||
* {@code Screencast} object associated with this page.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
Screencast screencast();
|
|
||||||
/**
|
/**
|
||||||
* Returns the buffer with the captured screenshot.
|
* Returns the buffer with the captured screenshot.
|
||||||
*
|
*
|
||||||
@@ -7694,22 +7414,6 @@ public interface Page extends AutoCloseable {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
void setViewportSize(int width, int height);
|
void setViewportSize(int width, int height);
|
||||||
/**
|
|
||||||
* Captures the aria snapshot of the page. Read more about <a href="https://playwright.dev/java/docs/aria-snapshots">aria
|
|
||||||
* snapshots</a>.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default String ariaSnapshot() {
|
|
||||||
return ariaSnapshot(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Captures the aria snapshot of the page. Read more about <a href="https://playwright.dev/java/docs/aria-snapshots">aria
|
|
||||||
* snapshots</a>.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
String ariaSnapshot(AriaSnapshotOptions options);
|
|
||||||
/**
|
/**
|
||||||
* This method taps an element matching {@code selector} by performing the following steps:
|
* This method taps an element matching {@code selector} by performing the following steps:
|
||||||
* <ol>
|
* <ol>
|
||||||
@@ -7724,8 +7428,8 @@ public interface Page extends AutoCloseable {
|
|||||||
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
|
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
|
||||||
* TimeoutError}. Passing zero timeout disables this.
|
* TimeoutError}. Passing zero timeout disables this.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} will throw if the {@code hasTouch} option of the browser context is
|
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser
|
||||||
* false.
|
* context is false.
|
||||||
*
|
*
|
||||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
|
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
@@ -7747,8 +7451,8 @@ public interface Page extends AutoCloseable {
|
|||||||
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
|
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
|
||||||
* TimeoutError}. Passing zero timeout disables this.
|
* TimeoutError}. Passing zero timeout disables this.
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} will throw if the {@code hasTouch} option of the browser context is
|
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser
|
||||||
* false.
|
* context is false.
|
||||||
*
|
*
|
||||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
|
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
@@ -7857,7 +7561,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default void unroute(String url) {
|
default void unroute(String url) {
|
||||||
@@ -7867,7 +7571,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @param handler Optional handler function to route the request.
|
* @param handler Optional handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -7876,7 +7580,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default void unroute(Pattern url) {
|
default void unroute(Pattern url) {
|
||||||
@@ -7886,7 +7590,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @param handler Optional handler function to route the request.
|
* @param handler Optional handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -7895,7 +7599,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
default void unroute(Predicate<String> url) {
|
default void unroute(Predicate<String> url) {
|
||||||
@@ -7905,7 +7609,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
* Removes a route created with {@link com.microsoft.playwright.Page#route Page.route()}. When {@code handler} is not
|
||||||
* specified, removes all routes for the {@code url}.
|
* specified, removes all routes for the {@code url}.
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while routing.
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||||
* @param handler Optional handler function to route the request.
|
* @param handler Optional handler function to route the request.
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -7917,8 +7621,7 @@ public interface Page extends AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
String url();
|
String url();
|
||||||
/**
|
/**
|
||||||
* Video object associated with this page. Can be used to access the video file when using the {@code recordVideo} context
|
* Video object associated with this page.
|
||||||
* option.
|
|
||||||
*
|
*
|
||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
@@ -8744,7 +8447,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -8761,7 +8464,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -8776,7 +8479,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -8793,7 +8496,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -8808,7 +8511,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
@@ -8825,7 +8528,7 @@ public interface Page extends AutoCloseable {
|
|||||||
* page.waitForURL("**\/target.html");
|
* page.waitForURL("**\/target.html");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param url A glob pattern, regex pattern, or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if the
|
||||||
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
* parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly equal to
|
||||||
* the string.
|
* the string.
|
||||||
* @since v1.11
|
* @since v1.11
|
||||||
|
|||||||
@@ -183,16 +183,6 @@ public interface Request {
|
|||||||
* @since v1.8
|
* @since v1.8
|
||||||
*/
|
*/
|
||||||
Response response();
|
Response response();
|
||||||
/**
|
|
||||||
* Returns the {@code Response} object if the response has already been received, {@code null} otherwise.
|
|
||||||
*
|
|
||||||
* <p> Unlike {@link com.microsoft.playwright.Request#response Request.response()}, this method does not wait for the response
|
|
||||||
* to arrive. It returns immediately with the response object if the response has been received, or {@code null} if the
|
|
||||||
* response has not been received yet.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
Response existingResponse();
|
|
||||||
/**
|
/**
|
||||||
* Returns resource size information for given request.
|
* Returns resource size information for given request.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -86,12 +86,6 @@ public interface Response {
|
|||||||
* @since v1.15
|
* @since v1.15
|
||||||
*/
|
*/
|
||||||
List<String> headerValues(String name);
|
List<String> headerValues(String name);
|
||||||
/**
|
|
||||||
* Returns the http version used by the response.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
String httpVersion();
|
|
||||||
/**
|
/**
|
||||||
* Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
* Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,276 +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 com.microsoft.playwright.options.*;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for capturing screencast frames from a page.
|
|
||||||
*/
|
|
||||||
public interface Screencast {
|
|
||||||
class StartOptions {
|
|
||||||
/**
|
|
||||||
* Callback that receives JPEG-encoded frame data along with the page viewport size at the time of capture.
|
|
||||||
*/
|
|
||||||
public Consumer<ScreencastFrame> onFrame;
|
|
||||||
/**
|
|
||||||
* Path where the video should be saved when the screencast is stopped. When provided, video recording is started.
|
|
||||||
*/
|
|
||||||
public Path path;
|
|
||||||
/**
|
|
||||||
* The quality of the image, between 0-100.
|
|
||||||
*/
|
|
||||||
public Integer quality;
|
|
||||||
/**
|
|
||||||
* Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be
|
|
||||||
* smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing
|
|
||||||
* configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not
|
|
||||||
* specified the size will be equal to page viewport scaled down to fit into 800×800.
|
|
||||||
*/
|
|
||||||
public Size size;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback that receives JPEG-encoded frame data along with the page viewport size at the time of capture.
|
|
||||||
*/
|
|
||||||
public StartOptions setOnFrame(Consumer<ScreencastFrame> onFrame) {
|
|
||||||
this.onFrame = onFrame;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Path where the video should be saved when the screencast is stopped. When provided, video recording is started.
|
|
||||||
*/
|
|
||||||
public StartOptions setPath(Path path) {
|
|
||||||
this.path = path;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The quality of the image, between 0-100.
|
|
||||||
*/
|
|
||||||
public StartOptions setQuality(int quality) {
|
|
||||||
this.quality = quality;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be
|
|
||||||
* smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing
|
|
||||||
* configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not
|
|
||||||
* specified the size will be equal to page viewport scaled down to fit into 800×800.
|
|
||||||
*/
|
|
||||||
public StartOptions setSize(int width, int height) {
|
|
||||||
return setSize(new Size(width, height));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Specifies the dimensions of screencast frames. The actual frame is scaled to preserve the page's aspect ratio and may be
|
|
||||||
* smaller than these bounds. If a screencast is already active (e.g. started by tracing or video recording), the existing
|
|
||||||
* configuration takes precedence and the frame size may exceed these bounds or this option may be ignored. If not
|
|
||||||
* specified the size will be equal to page viewport scaled down to fit into 800×800.
|
|
||||||
*/
|
|
||||||
public StartOptions setSize(Size size) {
|
|
||||||
this.size = size;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ShowOverlayOptions {
|
|
||||||
/**
|
|
||||||
* Duration in milliseconds after which the overlay is automatically removed. Overlay stays until dismissed if not
|
|
||||||
* provided.
|
|
||||||
*/
|
|
||||||
public Double duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Duration in milliseconds after which the overlay is automatically removed. Overlay stays until dismissed if not
|
|
||||||
* provided.
|
|
||||||
*/
|
|
||||||
public ShowOverlayOptions setDuration(double duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ShowChapterOptions {
|
|
||||||
/**
|
|
||||||
* Optional description text displayed below the title.
|
|
||||||
*/
|
|
||||||
public String description;
|
|
||||||
/**
|
|
||||||
* Duration in milliseconds after which the overlay is automatically removed. Defaults to {@code 2000}.
|
|
||||||
*/
|
|
||||||
public Double duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional description text displayed below the title.
|
|
||||||
*/
|
|
||||||
public ShowChapterOptions setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Duration in milliseconds after which the overlay is automatically removed. Defaults to {@code 2000}.
|
|
||||||
*/
|
|
||||||
public ShowChapterOptions setDuration(double duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class ShowActionsOptions {
|
|
||||||
/**
|
|
||||||
* Cursor decoration shown for pointer actions. {@code "pointer"} (the default) renders a mouse pointer that animates from
|
|
||||||
* the previous action point to the next one. {@code "none"} disables the cursor decoration.
|
|
||||||
*/
|
|
||||||
public ScreencastCursor cursor;
|
|
||||||
/**
|
|
||||||
* How long each annotation is displayed in milliseconds. Defaults to {@code 500}.
|
|
||||||
*/
|
|
||||||
public Double duration;
|
|
||||||
/**
|
|
||||||
* Font size of the action title in pixels. Defaults to {@code 24}.
|
|
||||||
*/
|
|
||||||
public Integer fontSize;
|
|
||||||
/**
|
|
||||||
* Position of the action title overlay. Defaults to {@code "top-right"}.
|
|
||||||
*/
|
|
||||||
public AnnotatePosition position;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cursor decoration shown for pointer actions. {@code "pointer"} (the default) renders a mouse pointer that animates from
|
|
||||||
* the previous action point to the next one. {@code "none"} disables the cursor decoration.
|
|
||||||
*/
|
|
||||||
public ShowActionsOptions setCursor(ScreencastCursor cursor) {
|
|
||||||
this.cursor = cursor;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* How long each annotation is displayed in milliseconds. Defaults to {@code 500}.
|
|
||||||
*/
|
|
||||||
public ShowActionsOptions setDuration(double duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Font size of the action title in pixels. Defaults to {@code 24}.
|
|
||||||
*/
|
|
||||||
public ShowActionsOptions setFontSize(int fontSize) {
|
|
||||||
this.fontSize = fontSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Position of the action title overlay. Defaults to {@code "top-right"}.
|
|
||||||
*/
|
|
||||||
public ShowActionsOptions setPosition(AnnotatePosition position) {
|
|
||||||
this.position = position;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Starts the screencast. When {@code path} is provided, it saves video recording to the specified file. When {@code
|
|
||||||
* onFrame} is provided, delivers JPEG-encoded frames to the callback. Both can be used together.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default AutoCloseable start() {
|
|
||||||
return start(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Starts the screencast. When {@code path} is provided, it saves video recording to the specified file. When {@code
|
|
||||||
* onFrame} is provided, delivers JPEG-encoded frames to the callback. Both can be used together.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
AutoCloseable start(StartOptions options);
|
|
||||||
/**
|
|
||||||
* Stops the screencast and video recording if active. If a video was being recorded, saves it to the path specified in
|
|
||||||
* {@link com.microsoft.playwright.Screencast#start Screencast.start()}.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void stop();
|
|
||||||
/**
|
|
||||||
* Adds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a
|
|
||||||
* disposable that removes the overlay when disposed.
|
|
||||||
*
|
|
||||||
* @param html HTML content for the overlay.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default AutoCloseable showOverlay(String html) {
|
|
||||||
return showOverlay(html, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a
|
|
||||||
* disposable that removes the overlay when disposed.
|
|
||||||
*
|
|
||||||
* @param html HTML content for the overlay.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
AutoCloseable showOverlay(String html, ShowOverlayOptions options);
|
|
||||||
/**
|
|
||||||
* Shows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for
|
|
||||||
* narrating video recordings. The overlay is removed after the specified duration, or 2000ms.
|
|
||||||
*
|
|
||||||
* @param title Title text displayed prominently in the overlay.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default void showChapter(String title) {
|
|
||||||
showChapter(title, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Shows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for
|
|
||||||
* narrating video recordings. The overlay is removed after the specified duration, or 2000ms.
|
|
||||||
*
|
|
||||||
* @param title Title text displayed prominently in the overlay.
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void showChapter(String title, ShowChapterOptions options);
|
|
||||||
/**
|
|
||||||
* Enables visual annotations on interacted elements. Returns a disposable that stops showing actions when disposed.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
default AutoCloseable showActions() {
|
|
||||||
return showActions(null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Enables visual annotations on interacted elements. Returns a disposable that stops showing actions when disposed.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
AutoCloseable showActions(ShowActionsOptions options);
|
|
||||||
/**
|
|
||||||
* Shows overlays.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void showOverlays();
|
|
||||||
/**
|
|
||||||
* Removes action decorations.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void hideActions();
|
|
||||||
/**
|
|
||||||
* Hides overlays without removing them.
|
|
||||||
*
|
|
||||||
* @since v1.59
|
|
||||||
*/
|
|
||||||
void hideOverlays();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,39 +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;
|
|
||||||
|
|
||||||
public interface ScreencastFrame {
|
|
||||||
/**
|
|
||||||
* JPEG-encoded frame data.
|
|
||||||
*/
|
|
||||||
byte[] data();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The timestamp of when the frame was presented by the browser, in milliseconds since the Unix epoch.
|
|
||||||
*/
|
|
||||||
double timestamp();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Width of the page viewport at the time the frame was captured.
|
|
||||||
*/
|
|
||||||
int viewportWidth();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Height of the page viewport at the time the frame was captured.
|
|
||||||
*/
|
|
||||||
int viewportHeight();
|
|
||||||
}
|
|
||||||
@@ -201,8 +201,7 @@ public interface Selectors {
|
|||||||
* Defines custom attribute name to be used in {@link com.microsoft.playwright.Page#getByTestId Page.getByTestId()}. {@code
|
* Defines custom attribute name to be used in {@link com.microsoft.playwright.Page#getByTestId Page.getByTestId()}. {@code
|
||||||
* data-testid} is used by default.
|
* data-testid} is used by default.
|
||||||
*
|
*
|
||||||
* @param attributeName Test id attribute name. To match elements with any of several attributes, pass them as a comma-separated list, e.g.
|
* @param attributeName Test id attribute name.
|
||||||
* {@code "data-pw,data-ti"}.
|
|
||||||
* @since v1.27
|
* @since v1.27
|
||||||
*/
|
*/
|
||||||
void setTestIdAttribute(String attributeName);
|
void setTestIdAttribute(String attributeName);
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ public interface Touchscreen {
|
|||||||
/**
|
/**
|
||||||
* Dispatches a {@code touchstart} and {@code touchend} event with a single touch at the position ({@code x},{@code y}).
|
* Dispatches a {@code touchstart} and {@code touchend} event with a single touch at the position ({@code x},{@code y}).
|
||||||
*
|
*
|
||||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Touchscreen#tap Touchscreen.tap()} will throw if the {@code hasTouch} option of the
|
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser
|
||||||
* browser context is false.
|
* context is false.
|
||||||
*
|
*
|
||||||
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
|
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
|
||||||
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
|
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.microsoft.playwright;
|
|||||||
|
|
||||||
import com.microsoft.playwright.options.*;
|
import com.microsoft.playwright.options.*;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API for collecting and saving Playwright traces. Playwright traces can be opened in <a
|
* API for collecting and saving Playwright traces. Playwright traces can be opened in <a
|
||||||
@@ -45,12 +44,6 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public interface Tracing {
|
public interface Tracing {
|
||||||
class StartOptions {
|
class StartOptions {
|
||||||
/**
|
|
||||||
* When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of
|
|
||||||
* caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test
|
|
||||||
* execution.
|
|
||||||
*/
|
|
||||||
public Boolean live;
|
|
||||||
/**
|
/**
|
||||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||||
* tracesDir} directory specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify
|
* tracesDir} directory specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify
|
||||||
@@ -81,15 +74,6 @@ public interface Tracing {
|
|||||||
*/
|
*/
|
||||||
public String title;
|
public String title;
|
||||||
|
|
||||||
/**
|
|
||||||
* When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of
|
|
||||||
* caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test
|
|
||||||
* execution.
|
|
||||||
*/
|
|
||||||
public StartOptions setLive(boolean live) {
|
|
||||||
this.live = live;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||||
* tracesDir} directory specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify
|
* tracesDir} directory specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify
|
||||||
@@ -166,59 +150,6 @@ public interface Tracing {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class StartHarOptions {
|
|
||||||
/**
|
|
||||||
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If
|
|
||||||
* {@code attach} is specified, resources are persisted as separate files or entries in the ZIP archive. If {@code embed}
|
|
||||||
* is specified, content is stored inline the HAR file as per HAR specification. Defaults to {@code attach} for {@code
|
|
||||||
* .zip} output files and to {@code embed} for all other file extensions.
|
|
||||||
*/
|
|
||||||
public HarContentPolicy content;
|
|
||||||
/**
|
|
||||||
* When set to {@code minimal}, only record information necessary for routing from HAR. This omits sizes, timing, page,
|
|
||||||
* cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to {@code
|
|
||||||
* full}.
|
|
||||||
*/
|
|
||||||
public HarMode mode;
|
|
||||||
/**
|
|
||||||
* A glob or regex pattern to filter requests that are stored in the HAR. Defaults to none.
|
|
||||||
*/
|
|
||||||
public Object urlFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If
|
|
||||||
* {@code attach} is specified, resources are persisted as separate files or entries in the ZIP archive. If {@code embed}
|
|
||||||
* is specified, content is stored inline the HAR file as per HAR specification. Defaults to {@code attach} for {@code
|
|
||||||
* .zip} output files and to {@code embed} for all other file extensions.
|
|
||||||
*/
|
|
||||||
public StartHarOptions setContent(HarContentPolicy content) {
|
|
||||||
this.content = content;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* When set to {@code minimal}, only record information necessary for routing from HAR. This omits sizes, timing, page,
|
|
||||||
* cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to {@code
|
|
||||||
* full}.
|
|
||||||
*/
|
|
||||||
public StartHarOptions setMode(HarMode mode) {
|
|
||||||
this.mode = mode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A glob or regex pattern to filter requests that are stored in the HAR. Defaults to none.
|
|
||||||
*/
|
|
||||||
public StartHarOptions setUrlFilter(String urlFilter) {
|
|
||||||
this.urlFilter = urlFilter;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A glob or regex pattern to filter requests that are stored in the HAR. Defaults to none.
|
|
||||||
*/
|
|
||||||
public StartHarOptions setUrlFilter(Pattern urlFilter) {
|
|
||||||
this.urlFilter = urlFilter;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class GroupOptions {
|
class GroupOptions {
|
||||||
/**
|
/**
|
||||||
* Specifies a custom location for the group to be shown in the trace viewer. Defaults to the location of the {@link
|
* Specifies a custom location for the group to be shown in the trace viewer. Defaults to the location of the {@link
|
||||||
@@ -382,48 +313,6 @@ public interface Tracing {
|
|||||||
* @since v1.15
|
* @since v1.15
|
||||||
*/
|
*/
|
||||||
void startChunk(StartChunkOptions options);
|
void startChunk(StartChunkOptions options);
|
||||||
/**
|
|
||||||
* Start recording a HAR (HTTP Archive) of network activity in this context. The HAR file is written to disk when {@link
|
|
||||||
* com.microsoft.playwright.Tracing#stopHar Tracing.stopHar()} is called, or when the returned {@code Disposable} is
|
|
||||||
* disposed.
|
|
||||||
*
|
|
||||||
* <p> Only one HAR recording can be active at a time per {@code BrowserContext}.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* context.tracing().startHar(Paths.get("trace.har"));
|
|
||||||
* Page page = context.newPage();
|
|
||||||
* page.navigate("https://playwright.dev");
|
|
||||||
* context.tracing().stopHar();
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @param path Path on the filesystem to write the HAR file to. If the file name ends with {@code .zip}, the HAR is saved as a zip
|
|
||||||
* archive with response bodies attached as separate files.
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
default AutoCloseable startHar(Path path) {
|
|
||||||
return startHar(path, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Start recording a HAR (HTTP Archive) of network activity in this context. The HAR file is written to disk when {@link
|
|
||||||
* com.microsoft.playwright.Tracing#stopHar Tracing.stopHar()} is called, or when the returned {@code Disposable} is
|
|
||||||
* disposed.
|
|
||||||
*
|
|
||||||
* <p> Only one HAR recording can be active at a time per {@code BrowserContext}.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* context.tracing().startHar(Paths.get("trace.har"));
|
|
||||||
* Page page = context.newPage();
|
|
||||||
* page.navigate("https://playwright.dev");
|
|
||||||
* context.tracing().stopHar();
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @param path Path on the filesystem to write the HAR file to. If the file name ends with {@code .zip}, the HAR is saved as a zip
|
|
||||||
* archive with response bodies attached as separate files.
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
AutoCloseable startHar(Path path, StartHarOptions options);
|
|
||||||
/**
|
/**
|
||||||
* <strong>NOTE:</strong> Use {@code test.step} instead when available.
|
* <strong>NOTE:</strong> Use {@code test.step} instead when available.
|
||||||
*
|
*
|
||||||
@@ -444,8 +333,8 @@ public interface Tracing {
|
|||||||
* @param name Group name shown in the trace viewer.
|
* @param name Group name shown in the trace viewer.
|
||||||
* @since v1.49
|
* @since v1.49
|
||||||
*/
|
*/
|
||||||
default AutoCloseable group(String name) {
|
default void group(String name) {
|
||||||
return group(name, null);
|
group(name, null);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* <strong>NOTE:</strong> Use {@code test.step} instead when available.
|
* <strong>NOTE:</strong> Use {@code test.step} instead when available.
|
||||||
@@ -467,7 +356,7 @@ public interface Tracing {
|
|||||||
* @param name Group name shown in the trace viewer.
|
* @param name Group name shown in the trace viewer.
|
||||||
* @since v1.49
|
* @since v1.49
|
||||||
*/
|
*/
|
||||||
AutoCloseable group(String name, GroupOptions options);
|
void group(String name, GroupOptions options);
|
||||||
/**
|
/**
|
||||||
* Closes the last group created by {@link com.microsoft.playwright.Tracing#group Tracing.group()}.
|
* Closes the last group created by {@link com.microsoft.playwright.Tracing#group Tracing.group()}.
|
||||||
*
|
*
|
||||||
@@ -504,12 +393,5 @@ public interface Tracing {
|
|||||||
* @since v1.15
|
* @since v1.15
|
||||||
*/
|
*/
|
||||||
void stopChunk(StopChunkOptions options);
|
void stopChunk(StopChunkOptions options);
|
||||||
/**
|
|
||||||
* Stop HAR recording and save the HAR file to the path given to {@link com.microsoft.playwright.Tracing#startHar
|
|
||||||
* Tracing.startHar()}.
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
void stopHar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import com.microsoft.playwright.options.*;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import com.microsoft.playwright.options.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code WebError} class represents an unhandled exception thrown in the page. It is dispatched via the {@link
|
* {@code WebError} class represents an unhandled exception thrown in the page. It is dispatched via the {@link
|
||||||
@@ -44,11 +43,5 @@ public interface WebError {
|
|||||||
* @since v1.38
|
* @since v1.38
|
||||||
*/
|
*/
|
||||||
String error();
|
String error();
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
WebErrorLocation location();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@@ -214,27 +213,6 @@ public interface WebSocketRoute {
|
|||||||
* @since v1.48
|
* @since v1.48
|
||||||
*/
|
*/
|
||||||
void send(byte[] message);
|
void send(byte[] message);
|
||||||
/**
|
|
||||||
* The list of WebSocket subprotocols requested by the page, as passed via the second argument to the <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket">{@code WebSocket} constructor</a>.
|
|
||||||
* Corresponds to the {@code Sec-WebSocket-Protocol} request header.
|
|
||||||
*
|
|
||||||
* <p> Returns an empty array if no protocols were specified.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* page.routeWebSocket("wss://example.com/ws", ws -> {
|
|
||||||
* if (ws.protocols().contains("chat.v2")) {
|
|
||||||
* ws.onMessage(frame -> ws.send("v2:" + frame.text()));
|
|
||||||
* } else {
|
|
||||||
* ws.close(1002, "Unsupported protocol");
|
|
||||||
* }
|
|
||||||
* });
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
List<String> protocols();
|
|
||||||
/**
|
/**
|
||||||
* URL of the WebSocket created in the page.
|
* URL of the WebSocket created in the page.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,73 +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 com.microsoft.playwright.options.*;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WebStorage exposes the page's {@code localStorage} or {@code sessionStorage} for the current origin via an async, <a
|
|
||||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Storage">browser-consistent</a> API.
|
|
||||||
*
|
|
||||||
* <p> Instances are accessed through {@link com.microsoft.playwright.Page#localStorage Page.localStorage()} and {@link
|
|
||||||
* com.microsoft.playwright.Page#sessionStorage Page.sessionStorage()}.
|
|
||||||
* <pre>{@code
|
|
||||||
* page.navigate("https://example.com");
|
|
||||||
* page.localStorage().setItem("token", "abc");
|
|
||||||
* String token = page.localStorage().getItem("token");
|
|
||||||
* List<WebStorageItem> all = page.localStorage().items();
|
|
||||||
* page.localStorage().removeItem("token");
|
|
||||||
* page.localStorage().clear();
|
|
||||||
* }</pre>
|
|
||||||
*/
|
|
||||||
public interface WebStorage {
|
|
||||||
/**
|
|
||||||
* Returns all items in the storage as name/value pairs.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
List<WebStorageItem> items();
|
|
||||||
/**
|
|
||||||
* Returns the value for the given {@code name} if present.
|
|
||||||
*
|
|
||||||
* @param name Name of the item to retrieve.
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
String getItem(String name);
|
|
||||||
/**
|
|
||||||
* Sets the value for the given {@code name}. Overwrites any existing value for that name.
|
|
||||||
*
|
|
||||||
* @param name Name of the item to set.
|
|
||||||
* @param value New value for the item.
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
void setItem(String name, String value);
|
|
||||||
/**
|
|
||||||
* Removes the item with the given {@code name}. No-op if the item is absent.
|
|
||||||
*
|
|
||||||
* @param name Name of the item to remove.
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
void removeItem(String name);
|
|
||||||
/**
|
|
||||||
* Removes all items from the storage.
|
|
||||||
*
|
|
||||||
* @since v1.61
|
|
||||||
*/
|
|
||||||
void clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
+2
-5
@@ -37,11 +37,8 @@ package com.microsoft.playwright.assertions;
|
|||||||
*/
|
*/
|
||||||
public interface APIResponseAssertions {
|
public interface APIResponseAssertions {
|
||||||
/**
|
/**
|
||||||
* Makes the assertion check for the opposite condition.
|
* Makes the assertion check for the opposite condition. For example, this code tests that the response status is not
|
||||||
*
|
* successful:
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> For example, this code tests that the response status is not successful:
|
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(response).not().isOK();
|
* assertThat(response).not().isOK();
|
||||||
* }</pre>
|
* }</pre>
|
||||||
|
|||||||
+6
-21
@@ -19,7 +19,6 @@ package com.microsoft.playwright.assertions;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import com.microsoft.playwright.options.AriaRole;
|
import com.microsoft.playwright.options.AriaRole;
|
||||||
import com.microsoft.playwright.options.PseudoElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code LocatorAssertions} class provides assertion methods that can be used to make assertions about the {@code
|
* The {@code LocatorAssertions} class provides assertion methods that can be used to make assertions about the {@code
|
||||||
@@ -428,22 +427,11 @@ public interface LocatorAssertions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
class HasCSSOptions {
|
class HasCSSOptions {
|
||||||
/**
|
|
||||||
* Pseudo-element to read computed styles from.
|
|
||||||
*/
|
|
||||||
public PseudoElement pseudo;
|
|
||||||
/**
|
/**
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
||||||
*/
|
*/
|
||||||
public Double timeout;
|
public Double timeout;
|
||||||
|
|
||||||
/**
|
|
||||||
* Pseudo-element to read computed styles from.
|
|
||||||
*/
|
|
||||||
public HasCSSOptions setPseudo(PseudoElement pseudo) {
|
|
||||||
this.pseudo = pseudo;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
||||||
*/
|
*/
|
||||||
@@ -575,11 +563,8 @@ public interface LocatorAssertions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Makes the assertion check for the opposite condition.
|
* Makes the assertion check for the opposite condition. For example, this code tests that the Locator doesn't contain text
|
||||||
*
|
* {@code "error"}:
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> For example, this code tests that the Locator doesn't contain text {@code "error"}:
|
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(locator).not().containsText("error");
|
* assertThat(locator).not().containsText("error");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -900,7 +885,7 @@ public interface LocatorAssertions {
|
|||||||
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
||||||
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page.locator(".list > .component")).containsClass(Arrays.asList("inactive", "active", "inactive"));
|
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
||||||
@@ -924,7 +909,7 @@ public interface LocatorAssertions {
|
|||||||
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
||||||
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page.locator(".list > .component")).containsClass(Arrays.asList("inactive", "active", "inactive"));
|
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
||||||
@@ -946,7 +931,7 @@ public interface LocatorAssertions {
|
|||||||
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
||||||
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page.locator(".list > .component")).containsClass(Arrays.asList("inactive", "active", "inactive"));
|
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
||||||
@@ -970,7 +955,7 @@ public interface LocatorAssertions {
|
|||||||
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
|
||||||
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
* class lists. Each element's class attribute is matched against the corresponding class in the array:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page.locator(".list > .component")).containsClass(Arrays.asList("inactive", "active", "inactive"));
|
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
|
||||||
|
|||||||
@@ -37,20 +37,6 @@ import java.util.regex.Pattern;
|
|||||||
* }</pre>
|
* }</pre>
|
||||||
*/
|
*/
|
||||||
public interface PageAssertions {
|
public interface PageAssertions {
|
||||||
class MatchesAriaSnapshotOptions {
|
|
||||||
/**
|
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
|
||||||
*/
|
|
||||||
public Double timeout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
|
||||||
*/
|
|
||||||
public MatchesAriaSnapshotOptions setTimeout(double timeout) {
|
|
||||||
this.timeout = timeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class HasTitleOptions {
|
class HasTitleOptions {
|
||||||
/**
|
/**
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
|
||||||
@@ -93,11 +79,8 @@ public interface PageAssertions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Makes the assertion check for the opposite condition.
|
* Makes the assertion check for the opposite condition. For example, this code tests that the page URL doesn't contain
|
||||||
*
|
* {@code "error"}:
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
*
|
|
||||||
* <p> For example, this code tests that the page URL doesn't contain {@code "error"}:
|
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* assertThat(page).not().hasURL("error");
|
* assertThat(page).not().hasURL("error");
|
||||||
* }</pre>
|
* }</pre>
|
||||||
@@ -105,40 +88,6 @@ public interface PageAssertions {
|
|||||||
* @since v1.20
|
* @since v1.20
|
||||||
*/
|
*/
|
||||||
PageAssertions not();
|
PageAssertions not();
|
||||||
/**
|
|
||||||
* Asserts that the page body matches the given <a href="https://playwright.dev/java/docs/aria-snapshots">accessibility
|
|
||||||
* snapshot</a>.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* page.navigate("https://demo.playwright.dev/todomvc/");
|
|
||||||
* assertThat(page).matchesAriaSnapshot("""
|
|
||||||
* - heading "todos"
|
|
||||||
* - textbox "What needs to be done?"
|
|
||||||
* """);
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
default void matchesAriaSnapshot(String expected) {
|
|
||||||
matchesAriaSnapshot(expected, null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Asserts that the page body matches the given <a href="https://playwright.dev/java/docs/aria-snapshots">accessibility
|
|
||||||
* snapshot</a>.
|
|
||||||
*
|
|
||||||
* <p> <strong>Usage</strong>
|
|
||||||
* <pre>{@code
|
|
||||||
* page.navigate("https://demo.playwright.dev/todomvc/");
|
|
||||||
* assertThat(page).matchesAriaSnapshot("""
|
|
||||||
* - heading "todos"
|
|
||||||
* - textbox "What needs to be done?"
|
|
||||||
* """);
|
|
||||||
* }</pre>
|
|
||||||
*
|
|
||||||
* @since v1.60
|
|
||||||
*/
|
|
||||||
void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions options);
|
|
||||||
/**
|
/**
|
||||||
* Ensures the page has the given title.
|
* Ensures the page has the given title.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -46,11 +46,6 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
|
|||||||
this.tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
|
this.tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public com.microsoft.playwright.Tracing tracing() {
|
|
||||||
return tracing;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public APIResponse delete(String url, RequestOptions options) {
|
public APIResponse delete(String url, RequestOptions options) {
|
||||||
return fetch(url, ensureOptions(options, "DELETE"));
|
return fetch(url, ensureOptions(options, "DELETE"));
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
import com.microsoft.playwright.APIResponse;
|
import com.microsoft.playwright.APIResponse;
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
import com.microsoft.playwright.PlaywrightException;
|
||||||
import com.microsoft.playwright.options.HttpHeader;
|
import com.microsoft.playwright.options.HttpHeader;
|
||||||
import com.microsoft.playwright.options.SecurityDetails;
|
|
||||||
import com.microsoft.playwright.options.ServerAddr;
|
|
||||||
import com.microsoft.playwright.options.Timing;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -88,22 +85,6 @@ class APIResponseImpl implements APIResponse {
|
|||||||
return status == 0 || (status >= 200 && status <= 299);
|
return status == 0 || (status >= 200 && status <= 299);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SecurityDetails securityDetails() {
|
|
||||||
if (!initializer.has("securityDetails")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return gson().fromJson(initializer.get("securityDetails"), SecurityDetails.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServerAddr serverAddr() {
|
|
||||||
if (!initializer.has("serverAddr")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return gson().fromJson(initializer.get("serverAddr"), ServerAddr.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int status() {
|
public int status() {
|
||||||
return initializer.get("status").getAsInt();
|
return initializer.get("status").getAsInt();
|
||||||
@@ -119,26 +100,6 @@ class APIResponseImpl implements APIResponse {
|
|||||||
return new String(body(), StandardCharsets.UTF_8);
|
return new String(body(), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Timing timing() {
|
|
||||||
Timing timing;
|
|
||||||
if (initializer.has("timing")) {
|
|
||||||
timing = gson().fromJson(initializer.get("timing"), Timing.class);
|
|
||||||
} else {
|
|
||||||
timing = new Timing();
|
|
||||||
timing.startTime = -1;
|
|
||||||
timing.domainLookupStart = -1;
|
|
||||||
timing.domainLookupEnd = -1;
|
|
||||||
timing.connectStart = -1;
|
|
||||||
timing.secureConnectionStart = -1;
|
|
||||||
timing.connectEnd = -1;
|
|
||||||
timing.requestStart = -1;
|
|
||||||
timing.responseStart = -1;
|
|
||||||
}
|
|
||||||
timing.responseEnd = initializer.has("responseEndTiming") ? initializer.get("responseEndTiming").getAsDouble() : -1;
|
|
||||||
return timing;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String url() {
|
public String url() {
|
||||||
return initializer.get("url").getAsString();
|
return initializer.get("url").getAsString();
|
||||||
|
|||||||
@@ -57,14 +57,7 @@ abstract class AssertionsBase {
|
|||||||
}
|
}
|
||||||
FrameExpectResult result = doExpect(expression, expectOptions, title);
|
FrameExpectResult result = doExpect(expression, expectOptions, title);
|
||||||
if (result.matches == isNot) {
|
if (result.matches == isNot) {
|
||||||
Object actual;
|
Object actual = result.received == null ? null : Serialization.deserialize(result.received);
|
||||||
if (result.received == null) {
|
|
||||||
actual = null;
|
|
||||||
} else if (result.received.value != null) {
|
|
||||||
actual = Serialization.deserialize(result.received.value);
|
|
||||||
} else {
|
|
||||||
actual = result.received.ariaSnapshot;
|
|
||||||
}
|
|
||||||
String log = (result.log == null) ? "" : String.join("\n", result.log);
|
String log = (result.log == null) ? "" : String.join("\n", result.log);
|
||||||
if (!log.isEmpty()) {
|
if (!log.isEmpty()) {
|
||||||
log = "\nCall log:\n" + log;
|
log = "\nCall log:\n" + log;
|
||||||
|
|||||||
@@ -43,10 +43,8 @@ import static java.util.Arrays.asList;
|
|||||||
class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||||
protected BrowserImpl browser;
|
protected BrowserImpl browser;
|
||||||
private final TracingImpl tracing;
|
private final TracingImpl tracing;
|
||||||
private final DebuggerImpl debugger;
|
|
||||||
private final APIRequestContextImpl request;
|
private final APIRequestContextImpl request;
|
||||||
private final ClockImpl clock;
|
private final ClockImpl clock;
|
||||||
private final CredentialsImpl credentials;
|
|
||||||
final List<PageImpl> pages = new ArrayList<>();
|
final List<PageImpl> pages = new ArrayList<>();
|
||||||
|
|
||||||
final Router routes = new Router();
|
final Router routes = new Router();
|
||||||
@@ -69,18 +67,23 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
private final ListenerCollection<EventType> listeners = new ListenerCollection<>(eventSubscriptions(), this);
|
private final ListenerCollection<EventType> listeners = new ListenerCollection<>(eventSubscriptions(), this);
|
||||||
final TimeoutSettings timeoutSettings = new TimeoutSettings();
|
final TimeoutSettings timeoutSettings = new TimeoutSettings();
|
||||||
|
final Map<String, HarRecorder> harRecorders = new HashMap<>();
|
||||||
|
|
||||||
|
static class HarRecorder {
|
||||||
|
final Path path;
|
||||||
|
final HarContentPolicy contentPolicy;
|
||||||
|
|
||||||
|
HarRecorder(Path har, HarContentPolicy policy) {
|
||||||
|
path = har;
|
||||||
|
contentPolicy = policy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
CLOSE,
|
CLOSE,
|
||||||
CONSOLE,
|
CONSOLE,
|
||||||
DIALOG,
|
DIALOG,
|
||||||
DOWNLOAD,
|
|
||||||
FRAMEATTACHED,
|
|
||||||
FRAMEDETACHED,
|
|
||||||
FRAMENAVIGATED,
|
|
||||||
PAGE,
|
PAGE,
|
||||||
PAGECLOSE,
|
|
||||||
PAGELOAD,
|
|
||||||
WEBERROR,
|
WEBERROR,
|
||||||
REQUEST,
|
REQUEST,
|
||||||
REQUESTFAILED,
|
REQUESTFAILED,
|
||||||
@@ -91,11 +94,9 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
BrowserContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
BrowserContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||||
super(parent, type, guid, initializer);
|
super(parent, type, guid, initializer);
|
||||||
tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
|
tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
|
||||||
debugger = connection.getExistingObject(initializer.getAsJsonObject("debugger").get("guid").getAsString());
|
|
||||||
request = connection.getExistingObject(initializer.getAsJsonObject("requestContext").get("guid").getAsString());
|
request = connection.getExistingObject(initializer.getAsJsonObject("requestContext").get("guid").getAsString());
|
||||||
request.timeoutSettings = timeoutSettings;
|
request.timeoutSettings = timeoutSettings;
|
||||||
clock = new ClockImpl(this);
|
clock = new ClockImpl(this);
|
||||||
credentials = new CredentialsImpl(this);
|
|
||||||
closePromise = new WaitableEvent<>(listeners, EventType.CLOSE);
|
closePromise = new WaitableEvent<>(listeners, EventType.CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,20 +137,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
public void offBackgroundPage(Consumer<Page> handler) {
|
public void offBackgroundPage(Consumer<Page> handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDownload(Consumer<Download> handler) {
|
|
||||||
listeners.add(EventType.DOWNLOAD, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offDownload(Consumer<Download> handler) {
|
|
||||||
listeners.remove(EventType.DOWNLOAD, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyDownload(Download download) {
|
|
||||||
listeners.notify(EventType.DOWNLOAD, download);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(Consumer<BrowserContext> handler) {
|
public void onClose(Consumer<BrowserContext> handler) {
|
||||||
listeners.add(EventType.CLOSE, handler);
|
listeners.add(EventType.CLOSE, handler);
|
||||||
@@ -190,76 +177,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
listeners.remove(EventType.PAGE, handler);
|
listeners.remove(EventType.PAGE, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameAttached(Consumer<Frame> handler) {
|
|
||||||
listeners.add(EventType.FRAMEATTACHED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offFrameAttached(Consumer<Frame> handler) {
|
|
||||||
listeners.remove(EventType.FRAMEATTACHED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyFrameAttached(FrameImpl frame) {
|
|
||||||
listeners.notify(EventType.FRAMEATTACHED, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameDetached(Consumer<Frame> handler) {
|
|
||||||
listeners.add(EventType.FRAMEDETACHED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offFrameDetached(Consumer<Frame> handler) {
|
|
||||||
listeners.remove(EventType.FRAMEDETACHED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyFrameDetached(FrameImpl frame) {
|
|
||||||
listeners.notify(EventType.FRAMEDETACHED, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFrameNavigated(Consumer<Frame> handler) {
|
|
||||||
listeners.add(EventType.FRAMENAVIGATED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offFrameNavigated(Consumer<Frame> handler) {
|
|
||||||
listeners.remove(EventType.FRAMENAVIGATED, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyFrameNavigated(FrameImpl frame) {
|
|
||||||
listeners.notify(EventType.FRAMENAVIGATED, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageClose(Consumer<Page> handler) {
|
|
||||||
listeners.add(EventType.PAGECLOSE, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offPageClose(Consumer<Page> handler) {
|
|
||||||
listeners.remove(EventType.PAGECLOSE, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyPageClose(PageImpl page) {
|
|
||||||
listeners.notify(EventType.PAGECLOSE, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageLoad(Consumer<Page> handler) {
|
|
||||||
listeners.add(EventType.PAGELOAD, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offPageLoad(Consumer<Page> handler) {
|
|
||||||
listeners.remove(EventType.PAGELOAD, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyPageLoad(PageImpl page) {
|
|
||||||
listeners.notify(EventType.PAGELOAD, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWebError(Consumer<WebError> handler) {
|
public void onWebError(Consumer<WebError> handler) {
|
||||||
listeners.add(EventType.WEBERROR, handler);
|
listeners.add(EventType.WEBERROR, handler);
|
||||||
@@ -315,11 +232,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Credentials credentials() {
|
|
||||||
return credentials;
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T waitForEventWithTimeout(EventType eventType, Runnable code, Predicate<T> predicate, Double timeout) {
|
private <T> T waitForEventWithTimeout(EventType eventType, Runnable code, Predicate<T> predicate, Double timeout) {
|
||||||
List<Waitable<T>> waitables = new ArrayList<>();
|
List<Waitable<T>> waitables = new ArrayList<>();
|
||||||
waitables.add(new WaitableEvent<>(listeners, eventType, predicate));
|
waitables.add(new WaitableEvent<>(listeners, eventType, predicate));
|
||||||
@@ -356,11 +268,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
return connection.getExistingObject(result.getAsJsonObject("session").get("guid").getAsString());
|
return connection.getExistingObject(result.getAsJsonObject("session").get("guid").getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClosed() {
|
|
||||||
return closingOrClosed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close(CloseOptions options) {
|
public void close(CloseOptions options) {
|
||||||
if (!closingOrClosed) {
|
if (!closingOrClosed) {
|
||||||
@@ -370,7 +277,27 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
closeReason = options.reason;
|
closeReason = options.reason;
|
||||||
request.dispose(convertType(options, APIRequestContext.DisposeOptions.class));
|
request.dispose(convertType(options, APIRequestContext.DisposeOptions.class));
|
||||||
tracing.exportAllHars();
|
for (Map.Entry<String, HarRecorder> entry : harRecorders.entrySet()) {
|
||||||
|
JsonObject params = new JsonObject();
|
||||||
|
params.addProperty("harId", entry.getKey());
|
||||||
|
JsonObject json = sendMessage("harExport", params, NO_TIMEOUT).getAsJsonObject();
|
||||||
|
ArtifactImpl artifact = connection.getExistingObject(json.getAsJsonObject("artifact").get("guid").getAsString());
|
||||||
|
// Server side will compress artifact if content is attach or if file is .zip.
|
||||||
|
HarRecorder harParams = entry.getValue();
|
||||||
|
boolean isCompressed = harParams.contentPolicy == HarContentPolicy.ATTACH || harParams.path.toString().endsWith(".zip");
|
||||||
|
boolean needCompressed = harParams.path.toString().endsWith(".zip");
|
||||||
|
if (isCompressed && !needCompressed) {
|
||||||
|
String tmpPath = harParams.path + ".tmp";
|
||||||
|
artifact.saveAs(Paths.get(tmpPath));
|
||||||
|
JsonObject unzipParams = new JsonObject();
|
||||||
|
unzipParams.addProperty("zipFile", tmpPath);
|
||||||
|
unzipParams.addProperty("harFile", harParams.path.toString());
|
||||||
|
connection.localUtils.sendMessage("harUnzip", unzipParams, NO_TIMEOUT);
|
||||||
|
} else {
|
||||||
|
artifact.saveAs(harParams.path);
|
||||||
|
}
|
||||||
|
artifact.delete();
|
||||||
|
}
|
||||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||||
sendMessage("close", params, NO_TIMEOUT);
|
sendMessage("close", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
@@ -391,18 +318,17 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable addInitScript(String script) {
|
public void addInitScript(String script) {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("source", script);
|
params.addProperty("source", script);
|
||||||
JsonObject result = sendMessage("addInitScript", params, NO_TIMEOUT).getAsJsonObject();
|
sendMessage("addInitScript", params, NO_TIMEOUT);
|
||||||
return connection.getExistingObject(result.getAsJsonObject("disposable").get("guid").getAsString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable addInitScript(Path path) {
|
public void addInitScript(Path path) {
|
||||||
try {
|
try {
|
||||||
byte[] bytes = readAllBytes(path);
|
byte[] bytes = readAllBytes(path);
|
||||||
return addInitScript(new String(bytes, UTF_8));
|
addInitScript(new String(bytes, UTF_8));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PlaywrightException("Failed to read script from file", e);
|
throw new PlaywrightException("Failed to read script from file", e);
|
||||||
}
|
}
|
||||||
@@ -458,11 +384,11 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable exposeBinding(String name, BindingCallback playwrightBinding) {
|
public void exposeBinding(String name, BindingCallback playwrightBinding, ExposeBindingOptions options) {
|
||||||
return exposeBindingImpl(name, playwrightBinding);
|
exposeBindingImpl(name, playwrightBinding, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoCloseable exposeBindingImpl(String name, BindingCallback playwrightBinding) {
|
private void exposeBindingImpl(String name, BindingCallback playwrightBinding, ExposeBindingOptions options) {
|
||||||
if (bindings.containsKey(name)) {
|
if (bindings.containsKey(name)) {
|
||||||
throw new PlaywrightException("Function \"" + name + "\" has been already registered");
|
throw new PlaywrightException("Function \"" + name + "\" has been already registered");
|
||||||
}
|
}
|
||||||
@@ -475,13 +401,15 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("name", name);
|
params.addProperty("name", name);
|
||||||
JsonObject result = sendMessage("exposeBinding", params, NO_TIMEOUT).getAsJsonObject();
|
if (options != null && options.handle != null && options.handle) {
|
||||||
return connection.getExistingObject(result.getAsJsonObject("disposable").get("guid").getAsString());
|
params.addProperty("needsHandle", true);
|
||||||
|
}
|
||||||
|
sendMessage("exposeBinding", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable exposeFunction(String name, FunctionCallback playwrightFunction) {
|
public void exposeFunction(String name, FunctionCallback playwrightFunction) {
|
||||||
return exposeBindingImpl(name, (BindingCallback.Source source, Object... args) -> playwrightFunction.call(args));
|
exposeBindingImpl(name, (BindingCallback.Source source, Object... args) -> playwrightFunction.call(args), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -517,21 +445,18 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(String url, Consumer<Route> handler, RouteOptions options) {
|
public void route(String url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(UrlMatcher.forGlob(baseUrl(), url, this.connection.localUtils, false), handler, options);
|
route(UrlMatcher.forGlob(baseUrl(), url, this.connection.localUtils, false), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(Pattern url, Consumer<Route> handler, RouteOptions options) {
|
public void route(Pattern url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(new UrlMatcher(url), handler, options);
|
route(new UrlMatcher(url), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(Predicate<String> url, Consumer<Route> handler, RouteOptions options) {
|
public void route(Predicate<String> url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(new UrlMatcher(url), handler, options);
|
route(new UrlMatcher(url), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -578,7 +503,24 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
if (contentPolicy == null) {
|
if (contentPolicy == null) {
|
||||||
contentPolicy = Utils.convertType(options.updateContent, HarContentPolicy.class);
|
contentPolicy = Utils.convertType(options.updateContent, HarContentPolicy.class);
|
||||||
}
|
}
|
||||||
tracing.recordIntoHar(page, har, options.url, contentPolicy, options.updateMode, null);
|
if (contentPolicy == null) {
|
||||||
|
contentPolicy = HarContentPolicy.ATTACH;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject params = new JsonObject();
|
||||||
|
if (page != null) {
|
||||||
|
params.add("page", page.toProtocolRef());
|
||||||
|
}
|
||||||
|
JsonObject recordHarArgs = new JsonObject();
|
||||||
|
recordHarArgs.addProperty("zip", har.toString().endsWith(".zip"));
|
||||||
|
recordHarArgs.addProperty("content", contentPolicy.name().toLowerCase());
|
||||||
|
recordHarArgs.addProperty("mode", (options.updateMode == null ? HarMode.MINIMAL : options.updateMode).name().toLowerCase());
|
||||||
|
addHarUrlFilter(recordHarArgs, options.url);
|
||||||
|
|
||||||
|
params.add("options", recordHarArgs);
|
||||||
|
JsonObject json = sendMessage("harStart", params, NO_TIMEOUT).getAsJsonObject();
|
||||||
|
String harId = json.get("harId").getAsString();
|
||||||
|
harRecorders.put(harId, new HarRecorder(har, contentPolicy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -621,18 +563,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
sendMessage("setOffline", params, NO_TIMEOUT);
|
sendMessage("setOffline", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStorageState(Path storageState) {
|
|
||||||
try {
|
|
||||||
String state = new String(readAllBytes(storageState), UTF_8);
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("storageState", state);
|
|
||||||
sendMessage("setStorageState", params, NO_TIMEOUT);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new PlaywrightException("Failed to read storage state from file", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String storageState(StorageStateOptions options) {
|
public String storageState(StorageStateOptions options) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
@@ -649,11 +579,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
return storageState;
|
return storageState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public DebuggerImpl debugger() {
|
|
||||||
return debugger;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TracingImpl tracing() {
|
public TracingImpl tracing() {
|
||||||
return tracing;
|
return tracing;
|
||||||
@@ -850,7 +775,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
}
|
}
|
||||||
} else if ("response".equals(event)) {
|
} else if ("response".equals(event)) {
|
||||||
String guid = params.getAsJsonObject("response").get("guid").getAsString();
|
String guid = params.getAsJsonObject("response").get("guid").getAsString();
|
||||||
ResponseImpl response = connection.getExistingObject(guid);
|
Response response = connection.getExistingObject(guid);
|
||||||
listeners.notify(EventType.RESPONSE, response);
|
listeners.notify(EventType.RESPONSE, response);
|
||||||
if (params.has("page")) {
|
if (params.has("page")) {
|
||||||
PageImpl page = connection.getExistingObject(params.getAsJsonObject("page").get("guid").getAsString());
|
PageImpl page = connection.getExistingObject(params.getAsJsonObject("page").get("guid").getAsString());
|
||||||
@@ -864,11 +789,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
|||||||
} catch (PlaywrightException e) {
|
} catch (PlaywrightException e) {
|
||||||
page = null;
|
page = null;
|
||||||
}
|
}
|
||||||
WebErrorLocation location = null;
|
listeners.notify(BrowserContextImpl.EventType.WEBERROR, new WebErrorImpl(page, errorStr));
|
||||||
if (params.has("location")) {
|
|
||||||
location = gson().fromJson(params.getAsJsonObject("location"), WebErrorLocation.class);
|
|
||||||
}
|
|
||||||
listeners.notify(BrowserContextImpl.EventType.WEBERROR, new WebErrorImpl(page, errorStr, location));
|
|
||||||
if (page != null) {
|
if (page != null) {
|
||||||
page.listeners.notify(PageImpl.EventType.PAGEERROR, errorStr);
|
page.listeners.notify(PageImpl.EventType.PAGEERROR, errorStr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.microsoft.playwright.*;
|
import com.microsoft.playwright.*;
|
||||||
import com.microsoft.playwright.options.BindResult;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -43,7 +42,6 @@ class BrowserImpl extends ChannelOwner implements Browser {
|
|||||||
String closeReason;
|
String closeReason;
|
||||||
|
|
||||||
enum EventType {
|
enum EventType {
|
||||||
CONTEXT,
|
|
||||||
DISCONNECTED,
|
DISCONNECTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,16 +49,6 @@ class BrowserImpl extends ChannelOwner implements Browser {
|
|||||||
super(parent, type, guid, initializer);
|
super(parent, type, guid, initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContext(Consumer<BrowserContext> handler) {
|
|
||||||
listeners.add(EventType.CONTEXT, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offContext(Consumer<BrowserContext> handler) {
|
|
||||||
listeners.remove(EventType.CONTEXT, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnected(Consumer<Browser> handler) {
|
public void onDisconnected(Consumer<Browser> handler) {
|
||||||
listeners.add(EventType.DISCONNECTED, handler);
|
listeners.add(EventType.DISCONNECTED, handler);
|
||||||
@@ -207,32 +195,6 @@ class BrowserImpl extends ChannelOwner implements Browser {
|
|||||||
sendMessage("startTracing", params, NO_TIMEOUT);
|
sendMessage("startTracing", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BindResult bind(String title, BindOptions options) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("title", title);
|
|
||||||
if (options != null) {
|
|
||||||
if (options.host != null) {
|
|
||||||
params.addProperty("host", options.host);
|
|
||||||
}
|
|
||||||
if (options.port != null) {
|
|
||||||
params.addProperty("port", options.port);
|
|
||||||
}
|
|
||||||
if (options.workspaceDir != null) {
|
|
||||||
params.addProperty("workspaceDir", options.workspaceDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JsonObject result = sendMessage("startServer", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
BindResult bindResult = new BindResult();
|
|
||||||
bindResult.endpoint = result.get("endpoint").getAsString();
|
|
||||||
return bindResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unbind() {
|
|
||||||
sendMessage("stopServer", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] stopTracing() {
|
public byte[] stopTracing() {
|
||||||
JsonObject json = sendMessage("stopTracing").getAsJsonObject();
|
JsonObject json = sendMessage("stopTracing").getAsJsonObject();
|
||||||
@@ -313,7 +275,6 @@ class BrowserImpl extends ChannelOwner implements Browser {
|
|||||||
context.tracing().setTracesDir(tracePath);
|
context.tracing().setTracesDir(tracePath);
|
||||||
browserType.playwright.selectors.contextsForSelectors.add(context);
|
browserType.playwright.selectors.contextsForSelectors.add(context);
|
||||||
}
|
}
|
||||||
listeners.notify(EventType.CONTEXT, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void didClose() {
|
private void didClose() {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType {
|
|||||||
}
|
}
|
||||||
// We don't use gson() here as the headers map should be serialized to a json object.
|
// We don't use gson() here as the headers map should be serialized to a json object.
|
||||||
JsonObject params = new Gson().toJsonTree(options).getAsJsonObject();
|
JsonObject params = new Gson().toJsonTree(options).getAsJsonObject();
|
||||||
params.addProperty("endpoint", wsEndpoint);
|
params.addProperty("wsEndpoint", wsEndpoint);
|
||||||
|
|
||||||
if (!params.has("headers")) {
|
if (!params.has("headers")) {
|
||||||
params.add("headers", new JsonObject());
|
params.add("headers", new JsonObject());
|
||||||
@@ -112,8 +112,8 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Browser connectOverCDP(String endpointURL, ConnectOverCDPOptions options) {
|
public Browser connectOverCDP(String endpointURL, ConnectOverCDPOptions options) {
|
||||||
if (!"chromium".equals(name()) && !"webkit".equals(name())) {
|
if (!"chromium".equals(name())) {
|
||||||
throw new PlaywrightException("Connecting over CDP is only supported in Chromium and WebKit.");
|
throw new PlaywrightException("Connecting over CDP is only supported in Chromium.");
|
||||||
}
|
}
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = new ConnectOverCDPOptions();
|
options = new ConnectOverCDPOptions();
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public class CDPSessionImpl extends ChannelOwner implements CDPSession {
|
public class CDPSessionImpl extends ChannelOwner implements CDPSession {
|
||||||
private final ListenerCollection<String> listeners = new ListenerCollection<>(new HashMap<>(), this);
|
private final ListenerCollection<String> listeners = new ListenerCollection<>(new HashMap<>(), this);
|
||||||
private final ListenerCollection<EventType> typedListeners = new ListenerCollection<>(new HashMap<>(), this);
|
|
||||||
|
|
||||||
enum EventType {
|
|
||||||
CLOSE,
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CDPSessionImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
protected CDPSessionImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||||
super(parent, type, guid, initializer);
|
super(parent, type, guid, initializer);
|
||||||
@@ -45,22 +40,9 @@ public class CDPSessionImpl extends ChannelOwner implements CDPSession {
|
|||||||
params = parameters.get("params").getAsJsonObject();
|
params = parameters.get("params").getAsJsonObject();
|
||||||
}
|
}
|
||||||
listeners.notify(method, params);
|
listeners.notify(method, params);
|
||||||
listeners.notify("event", parameters);
|
|
||||||
} else if ("close".equals(event)) {
|
|
||||||
typedListeners.notify(EventType.CLOSE, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose(Consumer<CDPSession> handler) {
|
|
||||||
typedListeners.add(EventType.CLOSE, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offClose(Consumer<CDPSession> handler) {
|
|
||||||
typedListeners.remove(EventType.CLOSE, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonObject send(String method) {
|
public JsonObject send(String method) {
|
||||||
return send(method, null);
|
return send(method, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,14 +110,6 @@ class ChannelOwner extends LoggingSupport {
|
|||||||
return connection.sendMessageAsync(guid, method, params);
|
return connection.sendMessageAsync(guid, method, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire-and-forget: silently drop if the object was collected.
|
|
||||||
void sendMessageNoReply(String method, JsonObject params) {
|
|
||||||
if (wasCollected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.sendMessageNoReply(guid, method, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonElement sendMessage(String method) {
|
JsonElement sendMessage(String method) {
|
||||||
return sendMessage(method, new JsonObject(), NO_TIMEOUT);
|
return sendMessage(method, new JsonObject(), NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
@@ -125,12 +117,11 @@ class ChannelOwner extends LoggingSupport {
|
|||||||
JsonElement sendMessage(String method, JsonObject params, Double timeout) {
|
JsonElement sendMessage(String method, JsonObject params, Double timeout) {
|
||||||
checkNotCollected();
|
checkNotCollected();
|
||||||
if (timeout != null) {
|
if (timeout != null) {
|
||||||
// Timeout is passed in the message metadata, remove potential leftover from serialized options.
|
params.addProperty("timeout", timeout);
|
||||||
params.remove("timeout");
|
|
||||||
} else if (params.has("timeout")) {
|
} else if (params.has("timeout")) {
|
||||||
throw new PlaywrightException("Internal error: timeout must be passed explicitly.");
|
throw new PlaywrightException("Internal error: timeout must be passed explicitly.");
|
||||||
}
|
}
|
||||||
return connection.sendMessage(guid, method, params, timeout);
|
return connection.sendMessage(guid, method, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNotCollected() {
|
private void checkNotCollected() {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class Message {
|
|||||||
JsonObject params;
|
JsonObject params;
|
||||||
JsonElement result;
|
JsonElement result;
|
||||||
SerializedError error;
|
SerializedError error;
|
||||||
JsonObject errorDetails;
|
|
||||||
JsonArray log;
|
JsonArray log;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,28 +128,17 @@ public class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JsonElement sendMessage(String guid, String method, JsonObject params) {
|
public JsonElement sendMessage(String guid, String method, JsonObject params) {
|
||||||
return sendMessage(guid, method, params, null);
|
return root.runUntil(() -> {}, sendMessageAsync(guid, method, params));
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement sendMessage(String guid, String method, JsonObject params, Double timeout) {
|
|
||||||
return root.runUntil(() -> {}, internalSendMessage(guid, method, params, timeout, true, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaitableResult<JsonElement> sendMessageAsync(String guid, String method, JsonObject params) {
|
public WaitableResult<JsonElement> sendMessageAsync(String guid, String method, JsonObject params) {
|
||||||
return internalSendMessage(guid, method, params, null, true, true);
|
return internalSendMessage(guid, method, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire-and-forget: the server never replies.
|
private WaitableResult<JsonElement> internalSendMessage(String guid, String method, JsonObject params, boolean sendStack) {
|
||||||
public void sendMessageNoReply(String guid, String method, JsonObject params) {
|
|
||||||
internalSendMessage(guid, method, params, null, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private WaitableResult<JsonElement> internalSendMessage(String guid, String method, JsonObject params, Double timeout, boolean sendStack, boolean expectsReply) {
|
|
||||||
int id = ++lastId;
|
int id = ++lastId;
|
||||||
WaitableResult<JsonElement> result = new WaitableResult<>();
|
WaitableResult<JsonElement> result = new WaitableResult<>();
|
||||||
if (expectsReply) {
|
callbacks.put(id, result);
|
||||||
callbacks.put(id, result);
|
|
||||||
}
|
|
||||||
JsonObject message = new JsonObject();
|
JsonObject message = new JsonObject();
|
||||||
message.addProperty("id", id);
|
message.addProperty("id", id);
|
||||||
message.addProperty("guid", guid);
|
message.addProperty("guid", guid);
|
||||||
@@ -158,9 +146,6 @@ public class Connection {
|
|||||||
message.add("params", params);
|
message.add("params", params);
|
||||||
JsonObject metadata = new JsonObject();
|
JsonObject metadata = new JsonObject();
|
||||||
metadata.addProperty("wallTime", currentTimeMillis());
|
metadata.addProperty("wallTime", currentTimeMillis());
|
||||||
if (timeout != null) {
|
|
||||||
metadata.addProperty("timeout", timeout);
|
|
||||||
}
|
|
||||||
JsonArray stack = null;
|
JsonArray stack = null;
|
||||||
if (titleReported) {
|
if (titleReported) {
|
||||||
metadata.addProperty("internal", true);
|
metadata.addProperty("internal", true);
|
||||||
@@ -190,7 +175,7 @@ public class Connection {
|
|||||||
callData.add("stack", stack);
|
callData.add("stack", stack);
|
||||||
JsonObject stackParams = new JsonObject();
|
JsonObject stackParams = new JsonObject();
|
||||||
stackParams.add("callData", callData);
|
stackParams.add("callData", callData);
|
||||||
internalSendMessage(localUtils.guid,"addStackToTracingNoReply", stackParams, null, false, true);
|
internalSendMessage(localUtils.guid,"addStackToTracingNoReply", stackParams, false);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -266,20 +251,16 @@ public class Connection {
|
|||||||
callback.complete(message.result);
|
callback.complete(message.result);
|
||||||
} else {
|
} else {
|
||||||
String callLog = formatCallLog(message.log);
|
String callLog = formatCallLog(message.log);
|
||||||
PlaywrightException exception;
|
|
||||||
if (message.error.error == null) {
|
if (message.error.error == null) {
|
||||||
exception = new PlaywrightException(message.error + callLog);
|
callback.completeExceptionally(new PlaywrightException(message.error + callLog));
|
||||||
} else if ("TimeoutError".equals(message.error.error.name)) {
|
} else if ("TimeoutError".equals(message.error.error.name)) {
|
||||||
exception = new TimeoutError(message.error.error + callLog);
|
callback.completeExceptionally(new TimeoutError(message.error.error + callLog));
|
||||||
} else if ("TargetClosedError".equals(message.error.error.name)) {
|
} else if ("TargetClosedError".equals(message.error.error.name)) {
|
||||||
exception = new TargetClosedError(message.error.error + callLog);
|
callback.completeExceptionally(new TargetClosedError(message.error.error + callLog));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
exception = new DriverException(message.error.error + callLog);
|
callback.completeExceptionally(new DriverException(message.error.error + callLog));
|
||||||
}
|
}
|
||||||
if (message.errorDetails != null) {
|
|
||||||
exception = new ServerErrorWithDetails(exception, message.errorDetails, message.log);
|
|
||||||
}
|
|
||||||
callback.completeExceptionally(exception);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -352,9 +333,6 @@ public class Connection {
|
|||||||
case "Dialog":
|
case "Dialog":
|
||||||
result = new DialogImpl(parent, type, guid, initializer);
|
result = new DialogImpl(parent, type, guid, initializer);
|
||||||
break;
|
break;
|
||||||
case "Disposable":
|
|
||||||
result = new DisposableObject(parent, type, guid, initializer);
|
|
||||||
break;
|
|
||||||
case "Electron":
|
case "Electron":
|
||||||
// result = new Playwright(parent, type, guid, initializer);
|
// result = new Playwright(parent, type, guid, initializer);
|
||||||
break;
|
break;
|
||||||
@@ -400,9 +378,6 @@ public class Connection {
|
|||||||
break;
|
break;
|
||||||
case "SocksSupport":
|
case "SocksSupport":
|
||||||
break;
|
break;
|
||||||
case "Debugger":
|
|
||||||
result = new DebuggerImpl(parent, type, guid, initializer);
|
|
||||||
break;
|
|
||||||
case "Tracing":
|
case "Tracing":
|
||||||
result = new TracingImpl(parent, type, guid, initializer);
|
result = new TracingImpl(parent, type, guid, initializer);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ public class ConsoleMessageImpl implements ConsoleMessage {
|
|||||||
this.initializer = initializer;
|
this.initializer = initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double timestamp() {
|
|
||||||
return initializer.get("timestamp").getAsDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String type() {
|
public String type() {
|
||||||
return initializer.get("type").getAsString();
|
return initializer.get("type").getAsString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.microsoft.playwright.Credentials;
|
|
||||||
import com.microsoft.playwright.options.VirtualCredential;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.impl.ChannelOwner.NO_TIMEOUT;
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
class CredentialsImpl implements Credentials {
|
|
||||||
private final BrowserContextImpl context;
|
|
||||||
|
|
||||||
CredentialsImpl(BrowserContextImpl context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void install() {
|
|
||||||
context.sendMessage("credentialsInstall", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VirtualCredential create(String rpId, CreateOptions options) {
|
|
||||||
JsonObject params = options == null ? new JsonObject() : gson().toJsonTree(options).getAsJsonObject();
|
|
||||||
params.addProperty("rpId", rpId);
|
|
||||||
JsonObject json = context.sendMessage("credentialsCreate", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return gson().fromJson(json.get("credential"), VirtualCredential.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String id) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("id", id);
|
|
||||||
context.sendMessage("credentialsDelete", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<VirtualCredential> get(GetOptions options) {
|
|
||||||
JsonObject params = options == null ? new JsonObject() : gson().toJsonTree(options).getAsJsonObject();
|
|
||||||
JsonObject json = context.sendMessage("credentialsGet", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return asList(gson().fromJson(json.getAsJsonArray("credentials"), VirtualCredential[].class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.microsoft.playwright.Debugger;
|
|
||||||
import com.microsoft.playwright.options.Location;
|
|
||||||
import com.microsoft.playwright.options.DebuggerPausedDetails;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
|
||||||
|
|
||||||
class DebuggerImpl extends ChannelOwner implements Debugger {
|
|
||||||
private final List<Runnable> pausedStateChangedHandlers = new ArrayList<>();
|
|
||||||
private DebuggerPausedDetails pausedDetails;
|
|
||||||
|
|
||||||
DebuggerImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
|
||||||
super(parent, type, guid, initializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handleEvent(String event, JsonObject params) {
|
|
||||||
if ("pausedStateChanged".equals(event)) {
|
|
||||||
if (params.has("pausedDetails") && !params.get("pausedDetails").isJsonNull()) {
|
|
||||||
pausedDetails = gson().fromJson(params.get("pausedDetails"), DebuggerPausedDetails.class);
|
|
||||||
} else {
|
|
||||||
pausedDetails = null;
|
|
||||||
}
|
|
||||||
for (Runnable handler : new ArrayList<>(pausedStateChangedHandlers)) {
|
|
||||||
handler.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPausedStateChanged(Runnable handler) {
|
|
||||||
pausedStateChangedHandlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offPausedStateChanged(Runnable handler) {
|
|
||||||
pausedStateChangedHandlers.remove(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DebuggerPausedDetails pausedDetails() {
|
|
||||||
return pausedDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestPause() {
|
|
||||||
sendMessage("requestPause", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resume() {
|
|
||||||
sendMessage("resume", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void next() {
|
|
||||||
sendMessage("next", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runTo(Location location) {
|
|
||||||
JsonObject params = gson().toJsonTree(location).getAsJsonObject();
|
|
||||||
sendMessage("runTo", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -43,11 +43,7 @@ class DialogImpl extends ChannelOwner implements Dialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
try {
|
sendMessage("dismiss");
|
||||||
sendMessage("dismiss");
|
|
||||||
} catch (TargetClosedError e) {
|
|
||||||
// Swallow TargetClosedErrors for beforeunload dialogs.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,30 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
class DisposableObject extends ChannelOwner implements AutoCloseable {
|
|
||||||
DisposableObject(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
|
||||||
super(parent, type, guid, initializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
sendMessage("dispose", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +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.impl;
|
|
||||||
|
|
||||||
class DisposableStub implements AutoCloseable {
|
|
||||||
private Runnable dispose;
|
|
||||||
|
|
||||||
DisposableStub(Runnable dispose) {
|
|
||||||
this.dispose = dispose;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
if (dispose == null)
|
|
||||||
return;
|
|
||||||
Runnable d = dispose;
|
|
||||||
dispose = null;
|
|
||||||
d.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,7 +38,6 @@ import static com.microsoft.playwright.impl.Utils.*;
|
|||||||
import static com.microsoft.playwright.impl.Utils.addFilePathUploadParams;
|
import static com.microsoft.playwright.impl.Utils.addFilePathUploadParams;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
|
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.PNG;
|
import static com.microsoft.playwright.options.ScreenshotType.PNG;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.WEBP;
|
|
||||||
|
|
||||||
public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
||||||
private final FrameImpl frame;
|
private final FrameImpl frame;
|
||||||
@@ -279,8 +278,6 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
|||||||
String extension = fileName.substring(extStart).toLowerCase();
|
String extension = fileName.substring(extStart).toLowerCase();
|
||||||
if (".jpeg".equals(extension) || ".jpg".equals(extension)) {
|
if (".jpeg".equals(extension) || ".jpg".equals(extension)) {
|
||||||
options.type = JPEG;
|
options.type = JPEG;
|
||||||
} else if (".webp".equals(extension)) {
|
|
||||||
options.type = WEBP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1051,58 +1051,12 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
|||||||
return result.get("value").getAsInt();
|
return result.get("value").getAsInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dropImpl(String selector, DropPayload payload, com.microsoft.playwright.Locator.DropOptions options) {
|
void highlightImpl(String selector) {
|
||||||
if (options == null) {
|
|
||||||
options = new com.microsoft.playwright.Locator.DropOptions();
|
|
||||||
}
|
|
||||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
|
||||||
params.addProperty("selector", selector);
|
|
||||||
params.addProperty("strict", true);
|
|
||||||
if (payload != null) {
|
|
||||||
if (payload.files != null) {
|
|
||||||
if (payload.files instanceof Path) {
|
|
||||||
addFilePathUploadParams(new Path[] { (Path) payload.files }, params, page.context());
|
|
||||||
} else if (payload.files instanceof Path[]) {
|
|
||||||
addFilePathUploadParams((Path[]) payload.files, params, page.context());
|
|
||||||
} else if (payload.files instanceof com.microsoft.playwright.options.FilePayload) {
|
|
||||||
checkFilePayloadSize(new com.microsoft.playwright.options.FilePayload[] { (com.microsoft.playwright.options.FilePayload) payload.files });
|
|
||||||
params.add("payloads", toJsonArray(new com.microsoft.playwright.options.FilePayload[] { (com.microsoft.playwright.options.FilePayload) payload.files }));
|
|
||||||
} else if (payload.files instanceof com.microsoft.playwright.options.FilePayload[]) {
|
|
||||||
checkFilePayloadSize((com.microsoft.playwright.options.FilePayload[]) payload.files);
|
|
||||||
params.add("payloads", toJsonArray((com.microsoft.playwright.options.FilePayload[]) payload.files));
|
|
||||||
} else {
|
|
||||||
throw new com.microsoft.playwright.PlaywrightException("Unsupported files type: " + payload.files.getClass());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (payload.data != null) {
|
|
||||||
com.google.gson.JsonArray dataArray = new com.google.gson.JsonArray();
|
|
||||||
for (java.util.Map.Entry<String, String> entry : payload.data.entrySet()) {
|
|
||||||
JsonObject e = new JsonObject();
|
|
||||||
e.addProperty("mimeType", entry.getKey());
|
|
||||||
e.addProperty("value", entry.getValue());
|
|
||||||
dataArray.add(e);
|
|
||||||
}
|
|
||||||
params.add("data", dataArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendMessage("drop", params, timeout(options.timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
void highlightImpl(String selector, String style) {
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("selector", selector);
|
params.addProperty("selector", selector);
|
||||||
if (style != null) {
|
|
||||||
params.addProperty("style", style);
|
|
||||||
}
|
|
||||||
sendMessage("highlight", params, NO_TIMEOUT);
|
sendMessage("highlight", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hideHighlightImpl(String selector) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("selector", selector);
|
|
||||||
sendMessage("hideHighlight", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleEvent(String event, JsonObject params) {
|
protected void handleEvent(String event, JsonObject params) {
|
||||||
if ("loadstate".equals(event)) {
|
if ("loadstate".equals(event)) {
|
||||||
JsonElement add = params.get("add");
|
JsonElement add = params.get("add");
|
||||||
@@ -1112,7 +1066,6 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
|||||||
if (parentFrame == null && page != null) {
|
if (parentFrame == null && page != null) {
|
||||||
if (state == LOAD) {
|
if (state == LOAD) {
|
||||||
page.listeners.notify(PageImpl.EventType.LOAD, page);
|
page.listeners.notify(PageImpl.EventType.LOAD, page);
|
||||||
page.browserContext.notifyPageLoad(page);
|
|
||||||
} else if (state == DOMCONTENTLOADED) {
|
} else if (state == DOMCONTENTLOADED) {
|
||||||
page.listeners.notify(PageImpl.EventType.DOMCONTENTLOADED, page);
|
page.listeners.notify(PageImpl.EventType.DOMCONTENTLOADED, page);
|
||||||
}
|
}
|
||||||
@@ -1154,17 +1107,8 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
|||||||
FrameExpectResult expect(String expression, FrameExpectOptions options) {
|
FrameExpectResult expect(String expression, FrameExpectOptions options) {
|
||||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||||
params.addProperty("expression", expression);
|
params.addProperty("expression", expression);
|
||||||
FrameExpectResult result = new FrameExpectResult();
|
JsonElement json = sendMessage("expect", params, options.timeout);
|
||||||
try {
|
FrameExpectResult result = gson().fromJson(json, FrameExpectResult.class);
|
||||||
sendMessage("expect", params, options.timeout);
|
|
||||||
result.matches = !options.isNot;
|
|
||||||
} catch (ServerErrorWithDetails e) {
|
|
||||||
FrameExpectErrorDetails details = gson().fromJson(e.errorDetails(), FrameExpectErrorDetails.class);
|
|
||||||
result.matches = options.isNot;
|
|
||||||
result.received = details.received;
|
|
||||||
result.errorMessage = details.customErrorMessage == null ? null : "Error: " + details.customErrorMessage;
|
|
||||||
result.log = e.log();
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright.impl;
|
package com.microsoft.playwright.impl;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
import com.microsoft.playwright.PlaywrightException;
|
||||||
import com.microsoft.playwright.Request;
|
import com.microsoft.playwright.Request;
|
||||||
@@ -84,7 +82,7 @@ public class HARRouter {
|
|||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, String> headers = mergeSetCookieHeaders(response.getAsJsonArray("headers"));
|
Map<String, String> headers = fromNameValues(response.getAsJsonArray("headers"));
|
||||||
byte[] buffer = Base64.getDecoder().decode(response.get("body").getAsString());
|
byte[] buffer = Base64.getDecoder().decode(response.get("body").getAsString());
|
||||||
route.fulfill(new Route.FulfillOptions()
|
route.fulfill(new Route.FulfillOptions()
|
||||||
.setStatus(status)
|
.setStatus(status)
|
||||||
@@ -107,25 +105,6 @@ public class HARRouter {
|
|||||||
route.abort();
|
route.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, String> mergeSetCookieHeaders(JsonArray headersArray) {
|
|
||||||
Map<String, String> result = new java.util.LinkedHashMap<>();
|
|
||||||
for (JsonElement element : headersArray) {
|
|
||||||
JsonObject pair = element.getAsJsonObject();
|
|
||||||
String name = pair.get("name").getAsString();
|
|
||||||
String value = pair.get("value").getAsString();
|
|
||||||
if ("set-cookie".equalsIgnoreCase(name)) {
|
|
||||||
if (!result.containsKey("set-cookie")) {
|
|
||||||
result.put("set-cookie", value);
|
|
||||||
} else {
|
|
||||||
result.put("set-cookie", result.get("set-cookie") + "\n" + value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.put(name, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("harId", harId);
|
params.addProperty("harId", harId);
|
||||||
|
|||||||
@@ -34,20 +34,13 @@ public class LocalUtils extends ChannelOwner {
|
|||||||
return initializer.getAsJsonArray("deviceDescriptors");
|
return initializer.getAsJsonArray("deviceDescriptors");
|
||||||
}
|
}
|
||||||
|
|
||||||
void zip(Path zipFile, JsonArray entries, String stacksId, boolean appendMode, boolean includeSources, List<String> additionalSources) {
|
void zip(Path zipFile, JsonArray entries, String stacksId, boolean appendMode, boolean includeSources) {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("zipFile", zipFile.toString());
|
params.addProperty("zipFile", zipFile.toString());
|
||||||
params.add("entries", entries);
|
params.add("entries", entries);
|
||||||
params.addProperty("mode", appendMode ? "append" : "write");
|
params.addProperty("mode", appendMode ? "append" : "write");
|
||||||
params.addProperty("stacksId", stacksId);
|
params.addProperty("stacksId", stacksId);
|
||||||
params.addProperty("includeSources", includeSources);
|
params.addProperty("includeSources", includeSources);
|
||||||
if (!additionalSources.isEmpty()) {
|
|
||||||
JsonArray sourcesArray = new JsonArray();
|
|
||||||
for (String source : additionalSources) {
|
|
||||||
sourcesArray.add(source);
|
|
||||||
}
|
|
||||||
params.add("additionalSources", sourcesArray);
|
|
||||||
}
|
|
||||||
sendMessage("zip", params, NO_TIMEOUT);
|
sendMessage("zip", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
import static com.microsoft.playwright.impl.LocatorUtils.*;
|
import static com.microsoft.playwright.impl.LocatorUtils.*;
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||||
import static com.microsoft.playwright.impl.Serialization.serializeArgument;
|
|
||||||
import static com.microsoft.playwright.impl.Utils.convertType;
|
import static com.microsoft.playwright.impl.Utils.convertType;
|
||||||
|
|
||||||
class LocatorImpl implements Locator {
|
class LocatorImpl implements Locator {
|
||||||
@@ -109,14 +108,6 @@ class LocatorImpl implements Locator {
|
|||||||
return (List<String>) frame.evalOnSelectorAll(selector, "ee => ee.map(e => e.textContent || '')");
|
return (List<String>) frame.evalOnSelectorAll(selector, "ee => ee.map(e => e.textContent || '')");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Locator normalize() {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("selector", selector);
|
|
||||||
JsonObject result = frame.sendMessage("resolveSelector", params, ChannelOwner.NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return new LocatorImpl(frame, result.get("resolvedSelector").getAsString(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Locator and(Locator locator) {
|
public Locator and(Locator locator) {
|
||||||
LocatorImpl other = (LocatorImpl) locator;
|
LocatorImpl other = (LocatorImpl) locator;
|
||||||
@@ -372,20 +363,8 @@ class LocatorImpl implements Locator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(DropPayload payload, DropOptions options) {
|
public void highlight() {
|
||||||
frame.dropImpl(selector, payload, options);
|
frame.highlightImpl(selector);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCloseable highlight(HighlightOptions options) {
|
|
||||||
String style = options == null ? null : options.style;
|
|
||||||
frame.highlightImpl(selector, style);
|
|
||||||
return new DisposableStub(this::hideHighlight);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideHighlight() {
|
|
||||||
frame.hideHighlightImpl(selector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -667,16 +646,6 @@ class LocatorImpl implements Locator {
|
|||||||
frame.waitForSelectorImpl(selector, convertType(options, Frame.WaitForSelectorOptions.class).setStrict(true), true);
|
frame.waitForSelectorImpl(selector, convertType(options, Frame.WaitForSelectorOptions.class).setStrict(true), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void waitForFunction(String expression, Object arg, WaitForFunctionOptions options) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("selector", selector);
|
|
||||||
params.addProperty("strict", true);
|
|
||||||
params.addProperty("expression", expression);
|
|
||||||
params.add("arg", gson().toJsonTree(serializeArgument(arg)));
|
|
||||||
frame.sendMessage("waitForFunction", params, frame.timeout(options == null ? null : options.timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String description = description();
|
String description = description();
|
||||||
|
|||||||
@@ -43,14 +43,8 @@ public class LocatorUtils {
|
|||||||
return "internal:describe=" + gson().toJson(description);
|
return "internal:describe=" + gson().toJson(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple test id attribute names can be joined with a comma. Attribute names cannot contain commas.
|
|
||||||
private static String encodeTestIdAttributeName(String testIdAttributeName) {
|
|
||||||
return testIdAttributeName.contains(",") ? gson().toJson(testIdAttributeName) : testIdAttributeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getByTestIdSelector(Object testId, PlaywrightImpl playwright) {
|
static String getByTestIdSelector(Object testId, PlaywrightImpl playwright) {
|
||||||
String attributeName = encodeTestIdAttributeName(playwright.selectors.testIdAttributeName);
|
return getByAttributeTextSelector(playwright.selectors.testIdAttributeName, testId, true);
|
||||||
return "internal:testid=[" + attributeName + "=" + escapeForAttributeSelector(testId, true) + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getByAltTextSelector(Object text, Locator.GetByAltTextOptions options) {
|
static String getByAltTextSelector(Object text, Locator.GetByAltTextOptions options) {
|
||||||
@@ -92,10 +86,6 @@ public class LocatorUtils {
|
|||||||
String name = escapeForAttributeSelector(options.name, options.exact != null && options.exact);
|
String name = escapeForAttributeSelector(options.name, options.exact != null && options.exact);
|
||||||
addAttr(result, "name", name);
|
addAttr(result, "name", name);
|
||||||
}
|
}
|
||||||
if (options.description != null) {
|
|
||||||
String description = escapeForAttributeSelector(options.description, options.exact != null && options.exact);
|
|
||||||
addAttr(result, "description", description);
|
|
||||||
}
|
|
||||||
if (options.pressed != null)
|
if (options.pressed != null)
|
||||||
addAttr(result, "pressed", options.pressed.toString());
|
addAttr(result, "pressed", options.pressed.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,16 +73,6 @@ public class PageAssertionsImpl extends AssertionsBase implements PageAssertions
|
|||||||
expectImpl("to.have.url", expected, pattern, "Page URL expected to match regex", convertType(options, FrameExpectOptions.class), "Assert \"hasURL\"");
|
expectImpl("to.have.url", expected, pattern, "Page URL expected to match regex", convertType(options, FrameExpectOptions.class), "Assert \"hasURL\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions snapshotOptions) {
|
|
||||||
if (snapshotOptions == null) {
|
|
||||||
snapshotOptions = new MatchesAriaSnapshotOptions();
|
|
||||||
}
|
|
||||||
FrameExpectOptions options = convertType(snapshotOptions, FrameExpectOptions.class);
|
|
||||||
options.expectedValue = Serialization.serializeArgument(expected);
|
|
||||||
expectImpl("to.match.aria", options, expected, "Page expected to match Aria snapshot", "Assert \"matchesAriaSnapshot\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageAssertions not() {
|
public PageAssertions not() {
|
||||||
return new PageAssertionsImpl(actualPage, !isNot);
|
return new PageAssertionsImpl(actualPage, !isNot);
|
||||||
|
|||||||
@@ -35,21 +35,17 @@ import static com.microsoft.playwright.impl.Serialization.parseError;
|
|||||||
import static com.microsoft.playwright.impl.Utils.*;
|
import static com.microsoft.playwright.impl.Utils.*;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
|
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.PNG;
|
import static com.microsoft.playwright.options.ScreenshotType.PNG;
|
||||||
import static com.microsoft.playwright.options.ScreenshotType.WEBP;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.nio.file.Files.readAllBytes;
|
import static java.nio.file.Files.readAllBytes;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
|
|
||||||
public class PageImpl extends ChannelOwner implements Page {
|
public class PageImpl extends ChannelOwner implements Page {
|
||||||
final BrowserContextImpl browserContext;
|
private final BrowserContextImpl browserContext;
|
||||||
private final FrameImpl mainFrame;
|
private final FrameImpl mainFrame;
|
||||||
private final KeyboardImpl keyboard;
|
private final KeyboardImpl keyboard;
|
||||||
private final MouseImpl mouse;
|
private final MouseImpl mouse;
|
||||||
private final TouchscreenImpl touchscreen;
|
private final TouchscreenImpl touchscreen;
|
||||||
private final ScreencastImpl screencast;
|
|
||||||
private final WebStorageImpl localStorage;
|
|
||||||
private final WebStorageImpl sessionStorage;
|
|
||||||
final Waitable<?> waitableClosedOrCrashed;
|
final Waitable<?> waitableClosedOrCrashed;
|
||||||
private ViewportSize viewport;
|
private ViewportSize viewport;
|
||||||
private final Router routes = new Router();
|
private final Router routes = new Router();
|
||||||
@@ -139,9 +135,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
keyboard = new KeyboardImpl(this);
|
keyboard = new KeyboardImpl(this);
|
||||||
mouse = new MouseImpl(this);
|
mouse = new MouseImpl(this);
|
||||||
touchscreen = new TouchscreenImpl(this);
|
touchscreen = new TouchscreenImpl(this);
|
||||||
screencast = new ScreencastImpl(this);
|
|
||||||
localStorage = new WebStorageImpl(this, "local");
|
|
||||||
sessionStorage = new WebStorageImpl(this, "session");
|
|
||||||
frames.add(mainFrame);
|
frames.add(mainFrame);
|
||||||
timeoutSettings = new TimeoutSettings(browserContext.timeoutSettings);
|
timeoutSettings = new TimeoutSettings(browserContext.timeoutSettings);
|
||||||
waitableClosedOrCrashed = createWaitForCloseHelper();
|
waitableClosedOrCrashed = createWaitForCloseHelper();
|
||||||
@@ -150,13 +143,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
} else {
|
} else {
|
||||||
opener = null;
|
opener = null;
|
||||||
}
|
}
|
||||||
if (initializer.has("video")) {
|
|
||||||
String artifactGuid = initializer.getAsJsonObject("video").get("guid").getAsString();
|
|
||||||
ArtifactImpl artifact = connection.getExistingObject(artifactGuid);
|
|
||||||
video = new VideoImpl(this, artifact);
|
|
||||||
} else {
|
|
||||||
video = new VideoImpl(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -176,7 +162,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
ArtifactImpl artifact = connection.getExistingObject(artifactGuid);
|
ArtifactImpl artifact = connection.getExistingObject(artifactGuid);
|
||||||
DownloadImpl download = new DownloadImpl(this, artifact, params);
|
DownloadImpl download = new DownloadImpl(this, artifact, params);
|
||||||
listeners.notify(EventType.DOWNLOAD, download);
|
listeners.notify(EventType.DOWNLOAD, download);
|
||||||
browserContext.notifyDownload(download);
|
|
||||||
} else if ("fileChooser".equals(event)) {
|
} else if ("fileChooser".equals(event)) {
|
||||||
String guid = params.getAsJsonObject("element").get("guid").getAsString();
|
String guid = params.getAsJsonObject("element").get("guid").getAsString();
|
||||||
ElementHandleImpl elementHandle = connection.getExistingObject(guid);
|
ElementHandleImpl elementHandle = connection.getExistingObject(guid);
|
||||||
@@ -207,7 +192,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
frame.parentFrame.childFrames.add(frame);
|
frame.parentFrame.childFrames.add(frame);
|
||||||
}
|
}
|
||||||
listeners.notify(EventType.FRAMEATTACHED, frame);
|
listeners.notify(EventType.FRAMEATTACHED, frame);
|
||||||
browserContext.notifyFrameAttached(frame);
|
|
||||||
} else if ("frameDetached".equals(event)) {
|
} else if ("frameDetached".equals(event)) {
|
||||||
String guid = params.getAsJsonObject("frame").get("guid").getAsString();
|
String guid = params.getAsJsonObject("frame").get("guid").getAsString();
|
||||||
FrameImpl frame = connection.getExistingObject(guid);
|
FrameImpl frame = connection.getExistingObject(guid);
|
||||||
@@ -217,7 +201,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
frame.parentFrame.childFrames.remove(frame);
|
frame.parentFrame.childFrames.remove(frame);
|
||||||
}
|
}
|
||||||
listeners.notify(EventType.FRAMEDETACHED, frame);
|
listeners.notify(EventType.FRAMEDETACHED, frame);
|
||||||
browserContext.notifyFrameDetached(frame);
|
|
||||||
} else if ("locatorHandlerTriggered".equals(event)) {
|
} else if ("locatorHandlerTriggered".equals(event)) {
|
||||||
int uid = params.get("uid").getAsInt();
|
int uid = params.get("uid").getAsInt();
|
||||||
onLocatorHandlerTriggered(uid);
|
onLocatorHandlerTriggered(uid);
|
||||||
@@ -236,12 +219,14 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
if (!webSocketRoutes.handle(route)) {
|
if (!webSocketRoutes.handle(route)) {
|
||||||
browserContext.handleWebSocketRoute(route);
|
browserContext.handleWebSocketRoute(route);
|
||||||
}
|
}
|
||||||
|
} else if ("video".equals(event)) {
|
||||||
|
String artifactGuid = params.getAsJsonObject("artifact").get("guid").getAsString();
|
||||||
|
ArtifactImpl artifact = connection.getExistingObject(artifactGuid);
|
||||||
|
forceVideo().setArtifact(artifact);
|
||||||
} else if ("crash".equals(event)) {
|
} else if ("crash".equals(event)) {
|
||||||
listeners.notify(EventType.CRASH, this);
|
listeners.notify(EventType.CRASH, this);
|
||||||
} else if ("close".equals(event)) {
|
} else if ("close".equals(event)) {
|
||||||
didClose();
|
didClose();
|
||||||
} else if ("screencastFrame".equals(event)) {
|
|
||||||
screencast.handleScreencastFrame(params);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +238,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
isClosed = true;
|
isClosed = true;
|
||||||
browserContext.pages.remove(this);
|
browserContext.pages.remove(this);
|
||||||
listeners.notify(EventType.CLOSE, this);
|
listeners.notify(EventType.CLOSE, this);
|
||||||
browserContext.notifyPageClose(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String effectiveCloseReason() {
|
private String effectiveCloseReason() {
|
||||||
@@ -560,13 +544,8 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
try {
|
try {
|
||||||
if (ownedContext != null) {
|
if (ownedContext != null) {
|
||||||
ownedContext.close();
|
ownedContext.close();
|
||||||
} else if (options.runBeforeUnload != null && options.runBeforeUnload) {
|
|
||||||
sendMessage("runBeforeUnload", new JsonObject(), NO_TIMEOUT);
|
|
||||||
} else {
|
} else {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||||
if (options.reason != null) {
|
|
||||||
params.addProperty("reason", options.reason);
|
|
||||||
}
|
|
||||||
sendMessage("close", params, NO_TIMEOUT);
|
sendMessage("close", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
} catch (PlaywrightException exception) {
|
} catch (PlaywrightException exception) {
|
||||||
@@ -654,16 +633,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String ariaSnapshot(AriaSnapshotOptions options) {
|
|
||||||
if (options == null) {
|
|
||||||
options = new AriaSnapshotOptions();
|
|
||||||
}
|
|
||||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
|
||||||
JsonObject result = mainFrame.sendMessage("ariaSnapshot", params, mainFrame.timeout(options.timeout)).getAsJsonObject();
|
|
||||||
return result.get("snapshot").getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object evalOnSelector(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
public Object evalOnSelector(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
||||||
return mainFrame.evalOnSelectorImpl(
|
return mainFrame.evalOnSelectorImpl(
|
||||||
@@ -676,26 +645,25 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable addInitScript(String script) {
|
public void addInitScript(String script) {
|
||||||
return addInitScriptImpl(script);
|
addInitScriptImpl(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable addInitScript(Path path) {
|
public void addInitScript(Path path) {
|
||||||
try {
|
try {
|
||||||
byte[] bytes = readAllBytes(path);
|
byte[] bytes = readAllBytes(path);
|
||||||
String script = addSourceUrlToScript(new String(bytes, UTF_8), path);
|
String script = addSourceUrlToScript(new String(bytes, UTF_8), path);
|
||||||
return addInitScriptImpl(script);
|
addInitScriptImpl(script);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PlaywrightException("Failed to read script from file", e);
|
throw new PlaywrightException("Failed to read script from file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoCloseable addInitScriptImpl(String script) {
|
private void addInitScriptImpl(String script) {
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("source", script);
|
params.addProperty("source", script);
|
||||||
JsonObject result = sendMessage("addInitScript", params, NO_TIMEOUT).getAsJsonObject();
|
sendMessage("addInitScript", params, NO_TIMEOUT);
|
||||||
return connection.getExistingObject(result.getAsJsonObject("disposable").get("guid").getAsString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -767,11 +735,11 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable exposeBinding(String name, BindingCallback playwrightBinding) {
|
public void exposeBinding(String name, BindingCallback playwrightBinding, ExposeBindingOptions options) {
|
||||||
return exposeBindingImpl(name, playwrightBinding);
|
exposeBindingImpl(name, playwrightBinding, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AutoCloseable exposeBindingImpl(String name, BindingCallback playwrightBinding) {
|
private void exposeBindingImpl(String name, BindingCallback playwrightBinding, ExposeBindingOptions options) {
|
||||||
if (bindings.containsKey(name)) {
|
if (bindings.containsKey(name)) {
|
||||||
throw new PlaywrightException("Function \"" + name + "\" has been already registered");
|
throw new PlaywrightException("Function \"" + name + "\" has been already registered");
|
||||||
}
|
}
|
||||||
@@ -782,13 +750,15 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
|
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
params.addProperty("name", name);
|
params.addProperty("name", name);
|
||||||
JsonObject result = sendMessage("exposeBinding", params, NO_TIMEOUT).getAsJsonObject();
|
if (options != null && options.handle != null && options.handle) {
|
||||||
return connection.getExistingObject(result.getAsJsonObject("disposable").get("guid").getAsString());
|
params.addProperty("needsHandle", true);
|
||||||
|
}
|
||||||
|
sendMessage("exposeBinding", params, NO_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable exposeFunction(String name, FunctionCallback playwrightFunction) {
|
public void exposeFunction(String name, FunctionCallback playwrightFunction) {
|
||||||
return exposeBindingImpl(name, (BindingCallback.Source source, Object... args) -> playwrightFunction.call(args));
|
exposeBindingImpl(name, (BindingCallback.Source source, Object... args) -> playwrightFunction.call(args), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1028,9 +998,8 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ConsoleMessage> consoleMessages(ConsoleMessagesOptions options) {
|
public List<ConsoleMessage> consoleMessages() {
|
||||||
JsonObject params = options != null ? gson().toJsonTree(options).getAsJsonObject() : new JsonObject();
|
JsonObject json = sendMessage("consoleMessages", new JsonObject(), NO_TIMEOUT).getAsJsonObject();
|
||||||
JsonObject json = sendMessage("consoleMessages", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
JsonArray messages = json.getAsJsonArray("messages");
|
JsonArray messages = json.getAsJsonArray("messages");
|
||||||
List<ConsoleMessage> result = new ArrayList<>();
|
List<ConsoleMessage> result = new ArrayList<>();
|
||||||
for (JsonElement item : messages) {
|
for (JsonElement item : messages) {
|
||||||
@@ -1039,16 +1008,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearConsoleMessages() {
|
|
||||||
sendMessage("clearConsoleMessages", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearPageErrors() {
|
|
||||||
sendMessage("clearPageErrors", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> pageErrors() {
|
public List<String> pageErrors() {
|
||||||
JsonObject json = sendMessage("pageErrors", new JsonObject(), NO_TIMEOUT).getAsJsonObject();
|
JsonObject json = sendMessage("pageErrors", new JsonObject(), NO_TIMEOUT).getAsJsonObject();
|
||||||
@@ -1071,11 +1030,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
return mainFrame;
|
return mainFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideHighlight() {
|
|
||||||
sendMessage("hideHighlight", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mouse mouse() {
|
public Mouse mouse() {
|
||||||
return mouse;
|
return mouse;
|
||||||
@@ -1089,17 +1043,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
return opener;
|
return opener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancelPickLocator() {
|
|
||||||
sendMessage("cancelPickLocator", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Locator pickLocator() {
|
|
||||||
JsonObject result = sendMessage("pickLocator", new JsonObject(), NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return new LocatorImpl(mainFrame, result.get("selector").getAsString(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
TimeoutSettings settings = browserContext.timeoutSettings;
|
TimeoutSettings settings = browserContext.timeoutSettings;
|
||||||
@@ -1162,21 +1105,18 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(String url, Consumer<Route> handler, RouteOptions options) {
|
public void route(String url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(UrlMatcher.forGlob(browserContext.baseUrl(), url, this.connection.localUtils, false), handler, options);
|
route(UrlMatcher.forGlob(browserContext.baseUrl(), url, this.connection.localUtils, false), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(Pattern url, Consumer<Route> handler, RouteOptions options) {
|
public void route(Pattern url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(new UrlMatcher(url), handler, options);
|
route(new UrlMatcher(url), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable route(Predicate<String> url, Consumer<Route> handler, RouteOptions options) {
|
public void route(Predicate<String> url, Consumer<Route> handler, RouteOptions options) {
|
||||||
route(new UrlMatcher(url), handler, options);
|
route(new UrlMatcher(url), handler, options);
|
||||||
return new DisposableStub(() -> unroute(url, handler));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1260,8 +1200,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
String extension = fileName.substring(extStart).toLowerCase();
|
String extension = fileName.substring(extStart).toLowerCase();
|
||||||
if (".jpeg".equals(extension) || ".jpg".equals(extension)) {
|
if (".jpeg".equals(extension) || ".jpg".equals(extension)) {
|
||||||
options.type = JPEG;
|
options.type = JPEG;
|
||||||
} else if (".webp".equals(extension)) {
|
|
||||||
options.type = WEBP;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1369,21 +1307,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
return touchscreen;
|
return touchscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Screencast screencast() {
|
|
||||||
return screencast;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WebStorage localStorage() {
|
|
||||||
return localStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WebStorage sessionStorage() {
|
|
||||||
return sessionStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void type(String selector, String text, TypeOptions options) {
|
public void type(String selector, String text, TypeOptions options) {
|
||||||
mainFrame.type(selector, text, convertType(options, Frame.TypeOptions.class));
|
mainFrame.type(selector, text, convertType(options, Frame.TypeOptions.class));
|
||||||
@@ -1434,9 +1357,22 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private VideoImpl forceVideo() {
|
||||||
|
if (video == null) {
|
||||||
|
video = new VideoImpl(this);
|
||||||
|
}
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VideoImpl video() {
|
public VideoImpl video() {
|
||||||
return video;
|
// Note: we are creating Video object lazily, because we do not know
|
||||||
|
// BrowserContextOptions when constructing the page - it is assigned
|
||||||
|
// too late during launchPersistentContext.
|
||||||
|
if (browserContext.videosDir() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return forceVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1485,7 +1421,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
|||||||
|
|
||||||
void frameNavigated(FrameImpl frame) {
|
void frameNavigated(FrameImpl frame) {
|
||||||
listeners.notify(EventType.FRAMENAVIGATED, frame);
|
listeners.notify(EventType.FRAMENAVIGATED, frame);
|
||||||
browserContext.notifyFrameNavigated(frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class WaitableFrameDetach extends WaitableEvent<EventType, Frame> {
|
private class WaitableFrameDetach extends WaitableEvent<EventType, Frame> {
|
||||||
|
|||||||
@@ -112,20 +112,10 @@ class FrameExpectOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FrameExpectResult {
|
class FrameExpectResult {
|
||||||
static class Received {
|
|
||||||
SerializedValue value;
|
|
||||||
String ariaSnapshot;
|
|
||||||
}
|
|
||||||
boolean matches;
|
boolean matches;
|
||||||
Received received;
|
SerializedValue received;
|
||||||
String errorMessage;
|
String errorMessage;
|
||||||
List<String> log;
|
List<String> log;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FrameExpectErrorDetails {
|
|
||||||
FrameExpectResult.Received received;
|
|
||||||
Boolean timedOut;
|
|
||||||
String customErrorMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class RequestImpl extends ChannelOwner implements Request {
|
|||||||
String failure;
|
String failure;
|
||||||
Timing timing;
|
Timing timing;
|
||||||
boolean didFailOrFinish;
|
boolean didFailOrFinish;
|
||||||
ResponseImpl existingResponse;
|
|
||||||
private FallbackOverrides fallbackOverrides;
|
private FallbackOverrides fallbackOverrides;
|
||||||
|
|
||||||
static class FallbackOverrides {
|
static class FallbackOverrides {
|
||||||
@@ -67,11 +66,6 @@ public class RequestImpl extends ChannelOwner implements Request {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseImpl existingResponse() {
|
|
||||||
return existingResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> allHeaders() {
|
public Map<String, String> allHeaders() {
|
||||||
return getRawHeaders().headers();
|
return getRawHeaders().headers();
|
||||||
|
|||||||
@@ -36,13 +36,12 @@ import static java.util.Arrays.asList;
|
|||||||
public class ResponseImpl extends ChannelOwner implements Response {
|
public class ResponseImpl extends ChannelOwner implements Response {
|
||||||
private final RawHeaders headers;
|
private final RawHeaders headers;
|
||||||
private RawHeaders rawHeaders;
|
private RawHeaders rawHeaders;
|
||||||
final RequestImpl request;
|
private final RequestImpl request;
|
||||||
|
|
||||||
ResponseImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
ResponseImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||||
super(parent, type, guid, initializer);
|
super(parent, type, guid, initializer);
|
||||||
headers = new RawHeaders(asList(gson().fromJson(initializer.getAsJsonArray("headers"), HttpHeader[].class)));
|
headers = new RawHeaders(asList(gson().fromJson(initializer.getAsJsonArray("headers"), HttpHeader[].class)));
|
||||||
request = connection.getExistingObject(initializer.getAsJsonObject("request").get("guid").getAsString());
|
request = connection.getExistingObject(initializer.getAsJsonObject("request").get("guid").getAsString());
|
||||||
request.existingResponse = this;
|
|
||||||
request.timing = gson().fromJson(initializer.get("timing"), Timing.class);
|
request.timing = gson().fromJson(initializer.get("timing"), Timing.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,12 +86,6 @@ public class ResponseImpl extends ChannelOwner implements Response {
|
|||||||
return initializer.get("fromServiceWorker").getAsBoolean();
|
return initializer.get("fromServiceWorker").getAsBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String httpVersion() {
|
|
||||||
JsonObject result = sendMessage("httpVersion").getAsJsonObject();
|
|
||||||
return result.get("value").getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> headers() {
|
public Map<String, String> headers() {
|
||||||
return headers.headers();
|
return headers.headers();
|
||||||
|
|||||||
@@ -1,53 +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.impl;
|
|
||||||
|
|
||||||
import com.microsoft.playwright.ScreencastFrame;
|
|
||||||
|
|
||||||
class ScreencastFrameImpl implements ScreencastFrame {
|
|
||||||
private final byte[] data;
|
|
||||||
private final double timestamp;
|
|
||||||
private final int viewportWidth;
|
|
||||||
private final int viewportHeight;
|
|
||||||
|
|
||||||
ScreencastFrameImpl(byte[] data, double timestamp, int viewportWidth, int viewportHeight) {
|
|
||||||
this.data = data;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.viewportWidth = viewportWidth;
|
|
||||||
this.viewportHeight = viewportHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] data() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double timestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int viewportWidth() {
|
|
||||||
return viewportWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int viewportHeight() {
|
|
||||||
return viewportHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
|
||||||
import com.microsoft.playwright.Screencast;
|
|
||||||
import com.microsoft.playwright.ScreencastFrame;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.impl.ChannelOwner.NO_TIMEOUT;
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
|
||||||
|
|
||||||
class ScreencastImpl implements Screencast {
|
|
||||||
private final PageImpl page;
|
|
||||||
private boolean started;
|
|
||||||
private Path savePath;
|
|
||||||
private Consumer<ScreencastFrame> onFrame;
|
|
||||||
private ArtifactImpl artifact;
|
|
||||||
|
|
||||||
ScreencastImpl(PageImpl page) {
|
|
||||||
this.page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleScreencastFrame(JsonObject params) {
|
|
||||||
try {
|
|
||||||
if (onFrame != null) {
|
|
||||||
String dataBase64 = params.get("data").getAsString();
|
|
||||||
byte[] data = java.util.Base64.getDecoder().decode(dataBase64);
|
|
||||||
double timestamp = params.get("timestamp").getAsDouble();
|
|
||||||
int viewportWidth = params.get("viewportWidth").getAsInt();
|
|
||||||
int viewportHeight = params.get("viewportHeight").getAsInt();
|
|
||||||
onFrame.accept(new ScreencastFrameImpl(data, timestamp, viewportWidth, viewportHeight));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
// The server sends the next frame only after the previous one is acknowledged.
|
|
||||||
JsonObject ackParams = new JsonObject();
|
|
||||||
ackParams.add("frameId", params.get("frameId"));
|
|
||||||
page.sendMessageAsync("screencastFrameAck", ackParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCloseable start(StartOptions options) {
|
|
||||||
if (started) {
|
|
||||||
throw new PlaywrightException("Screencast is already started");
|
|
||||||
}
|
|
||||||
started = true;
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
if (options != null) {
|
|
||||||
if (options.onFrame != null) {
|
|
||||||
onFrame = options.onFrame;
|
|
||||||
}
|
|
||||||
if (options.quality != null) {
|
|
||||||
params.addProperty("quality", options.quality);
|
|
||||||
}
|
|
||||||
params.addProperty("sendFrames", options.onFrame != null);
|
|
||||||
params.addProperty("record", options.path != null);
|
|
||||||
savePath = options.path;
|
|
||||||
} else {
|
|
||||||
params.addProperty("sendFrames", false);
|
|
||||||
params.addProperty("record", false);
|
|
||||||
}
|
|
||||||
JsonObject result = page.sendMessage("screencastStart", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
if (result.has("artifact")) {
|
|
||||||
String artifactGuid = result.getAsJsonObject("artifact").get("guid").getAsString();
|
|
||||||
artifact = page.connection.getExistingObject(artifactGuid);
|
|
||||||
}
|
|
||||||
return new DisposableStub(this::stop);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() {
|
|
||||||
started = false;
|
|
||||||
onFrame = null;
|
|
||||||
page.sendMessage("screencastStop", new JsonObject(), NO_TIMEOUT);
|
|
||||||
if (savePath != null && artifact != null) {
|
|
||||||
artifact.saveAs(savePath);
|
|
||||||
}
|
|
||||||
artifact = null;
|
|
||||||
savePath = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCloseable showOverlay(String html, ShowOverlayOptions options) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("html", html);
|
|
||||||
if (options != null && options.duration != null) {
|
|
||||||
params.addProperty("duration", options.duration);
|
|
||||||
}
|
|
||||||
JsonObject result = (JsonObject) page.sendMessage("screencastShowOverlay", params, NO_TIMEOUT);
|
|
||||||
String id = result.get("id").getAsString();
|
|
||||||
return () -> {
|
|
||||||
JsonObject removeParams = new JsonObject();
|
|
||||||
removeParams.addProperty("id", id);
|
|
||||||
page.sendMessage("screencastRemoveOverlay", removeParams, NO_TIMEOUT);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showChapter(String title, ShowChapterOptions options) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("title", title);
|
|
||||||
if (options != null) {
|
|
||||||
if (options.description != null) {
|
|
||||||
params.addProperty("description", options.description);
|
|
||||||
}
|
|
||||||
if (options.duration != null) {
|
|
||||||
params.addProperty("duration", options.duration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
page.sendMessage("screencastChapter", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCloseable showActions(ShowActionsOptions options) {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
if (options != null) {
|
|
||||||
if (options.duration != null) {
|
|
||||||
params.addProperty("duration", options.duration);
|
|
||||||
}
|
|
||||||
if (options.fontSize != null) {
|
|
||||||
params.addProperty("fontSize", options.fontSize);
|
|
||||||
}
|
|
||||||
if (options.position != null) {
|
|
||||||
params.add("position", gson().toJsonTree(options.position));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
page.sendMessage("screencastShowActions", params, NO_TIMEOUT);
|
|
||||||
return new DisposableStub(this::hideActions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showOverlays() {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("visible", true);
|
|
||||||
page.sendMessage("screencastSetOverlayVisible", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideActions() {
|
|
||||||
page.sendMessage("screencastHideActions", new JsonObject(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hideOverlays() {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("visible", false);
|
|
||||||
page.sendMessage("screencastSetOverlayVisible", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,9 +58,6 @@ class Serialization {
|
|||||||
.registerTypeAdapter(ScreenshotCaret.class, new ToLowerCaseSerializer<ScreenshotCaret>())
|
.registerTypeAdapter(ScreenshotCaret.class, new ToLowerCaseSerializer<ScreenshotCaret>())
|
||||||
.registerTypeAdapter(ServiceWorkerPolicy.class, new ToLowerCaseAndDashSerializer<ServiceWorkerPolicy>())
|
.registerTypeAdapter(ServiceWorkerPolicy.class, new ToLowerCaseAndDashSerializer<ServiceWorkerPolicy>())
|
||||||
.registerTypeAdapter(MouseButton.class, new ToLowerCaseSerializer<MouseButton>())
|
.registerTypeAdapter(MouseButton.class, new ToLowerCaseSerializer<MouseButton>())
|
||||||
.registerTypeAdapter(ScrollMode.class, new ToLowerCaseSerializer<ScrollMode>())
|
|
||||||
.registerTypeAdapter(ConsoleMessagesFilter.class, new ConsoleMessagesFilterSerializer())
|
|
||||||
.registerTypeAdapter(AriaSnapshotMode.class, new ToLowerCaseSerializer<AriaSnapshotMode>())
|
|
||||||
.registerTypeAdapter(LoadState.class, new ToLowerCaseSerializer<LoadState>())
|
.registerTypeAdapter(LoadState.class, new ToLowerCaseSerializer<LoadState>())
|
||||||
.registerTypeAdapter(WaitUntilState.class, new ToLowerCaseSerializer<WaitUntilState>())
|
.registerTypeAdapter(WaitUntilState.class, new ToLowerCaseSerializer<WaitUntilState>())
|
||||||
.registerTypeAdapter(WaitForSelectorState.class, new ToLowerCaseSerializer<WaitForSelectorState>())
|
.registerTypeAdapter(WaitForSelectorState.class, new ToLowerCaseSerializer<WaitForSelectorState>())
|
||||||
@@ -78,7 +75,6 @@ class Serialization {
|
|||||||
|
|
||||||
static final Gson jsonDataSerializer = new GsonBuilder().disableHtmlEscaping()
|
static final Gson jsonDataSerializer = new GsonBuilder().disableHtmlEscaping()
|
||||||
.registerTypeAdapter(Date.class, new DateSerializer())
|
.registerTypeAdapter(Date.class, new DateSerializer())
|
||||||
.registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
|
|
||||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
|
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
|
||||||
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeSerializer())
|
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeSerializer())
|
||||||
.serializeNulls().create();
|
.serializeNulls().create();
|
||||||
@@ -486,17 +482,6 @@ class Serialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConsoleMessagesFilterSerializer implements JsonSerializer<ConsoleMessagesFilter> {
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(ConsoleMessagesFilter src, Type typeOfSrc, JsonSerializationContext context) {
|
|
||||||
switch (src) {
|
|
||||||
case ALL: return new JsonPrimitive("all");
|
|
||||||
case SINCE_NAVIGATION: return new JsonPrimitive("since-navigation");
|
|
||||||
default: throw new PlaywrightException("Unknown ConsoleMessagesFilter: " + src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ToLowerCaseAndDashSerializer<E extends Enum<E>> implements JsonSerializer<E> {
|
private static class ToLowerCaseAndDashSerializer<E extends Enum<E>> implements JsonSerializer<E> {
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(E src, Type typeOfSrc, JsonSerializationContext context) {
|
public JsonElement serialize(E src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
@@ -573,15 +558,6 @@ class Serialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocalDateSerializer implements JsonSerializer<LocalDate> {
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(LocalDate src, Type typeOfSrc, JsonSerializationContext context) {
|
|
||||||
// LocalDate has no time or zone, so emit the ISO-8601 date (yyyy-MM-dd) as-is to
|
|
||||||
// avoid shifting the calendar date when converting through a time zone.
|
|
||||||
return new JsonPrimitive(src.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
|
private static class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
|
||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
|
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
|
|||||||
@@ -1,57 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
class ServerErrorWithDetails extends PlaywrightException {
|
|
||||||
private final JsonObject errorDetails;
|
|
||||||
private final JsonArray log;
|
|
||||||
|
|
||||||
ServerErrorWithDetails(PlaywrightException cause, JsonObject errorDetails, JsonArray log) {
|
|
||||||
super(cause.getMessage(), cause);
|
|
||||||
this.errorDetails = errorDetails;
|
|
||||||
this.log = log;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rethrown with the calling thread's stack trace, see WaitableResult.get().
|
|
||||||
ServerErrorWithDetails(ServerErrorWithDetails cause) {
|
|
||||||
super(cause.getMessage(), cause);
|
|
||||||
this.errorDetails = cause.errorDetails;
|
|
||||||
this.log = cause.log;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject errorDetails() {
|
|
||||||
return errorDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> log() {
|
|
||||||
List<String> result = new ArrayList<>();
|
|
||||||
if (log != null) {
|
|
||||||
for (JsonElement e : log) {
|
|
||||||
result.add(e.getAsString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,21 +18,10 @@ package com.microsoft.playwright.impl;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
|
||||||
import com.microsoft.playwright.Tracing;
|
import com.microsoft.playwright.Tracing;
|
||||||
import com.microsoft.playwright.options.HarContentPolicy;
|
|
||||||
import com.microsoft.playwright.options.HarMode;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||||
|
|
||||||
class TracingImpl extends ChannelOwner implements Tracing {
|
class TracingImpl extends ChannelOwner implements Tracing {
|
||||||
@@ -40,18 +29,6 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
private Path tracesDir;
|
private Path tracesDir;
|
||||||
private boolean isTracing;
|
private boolean isTracing;
|
||||||
private String stacksId;
|
private String stacksId;
|
||||||
private final Set<String> additionalSources = new HashSet<>();
|
|
||||||
final Map<String, HarRecorder> harRecorders = new HashMap<>();
|
|
||||||
|
|
||||||
static class HarRecorder {
|
|
||||||
final Path path;
|
|
||||||
final HarContentPolicy contentPolicy;
|
|
||||||
|
|
||||||
HarRecorder(Path har, HarContentPolicy policy) {
|
|
||||||
this.path = har;
|
|
||||||
this.contentPolicy = policy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TracingImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
TracingImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||||
@@ -65,9 +42,6 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
}
|
}
|
||||||
JsonObject params = new JsonObject();
|
JsonObject params = new JsonObject();
|
||||||
|
|
||||||
List<String> capturedAdditionalSources = new ArrayList<>(additionalSources);
|
|
||||||
additionalSources.clear();
|
|
||||||
|
|
||||||
// Not interested in artifacts.
|
// Not interested in artifacts.
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
params.addProperty("mode", "discard");
|
params.addProperty("mode", "discard");
|
||||||
@@ -83,7 +57,7 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
params.addProperty("mode", "entries");
|
params.addProperty("mode", "entries");
|
||||||
JsonObject json = sendMessage("tracingStopChunk", params, NO_TIMEOUT).getAsJsonObject();
|
JsonObject json = sendMessage("tracingStopChunk", params, NO_TIMEOUT).getAsJsonObject();
|
||||||
JsonArray entries = json.getAsJsonArray("entries");
|
JsonArray entries = json.getAsJsonArray("entries");
|
||||||
connection.localUtils.zip(path, entries, stacksId, false, includeSources, capturedAdditionalSources);
|
connection.localUtils.zip(path, entries, stacksId, false, includeSources);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +74,7 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
artifact.saveAs(path);
|
artifact.saveAs(path);
|
||||||
artifact.delete();
|
artifact.delete();
|
||||||
|
|
||||||
connection.localUtils.zip(path, new JsonArray(), stacksId, true, includeSources, capturedAdditionalSources);
|
connection.localUtils.zip(path, new JsonArray(), stacksId, true, includeSources);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -112,18 +86,14 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutoCloseable group(String name, GroupOptions options) {
|
public void group(String name, GroupOptions options) {
|
||||||
groupImpl(name, options);
|
groupImpl(name, options);
|
||||||
return new DisposableStub(this::groupEnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void groupImpl(String name, GroupOptions options) {
|
private void groupImpl(String name, GroupOptions options) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = new GroupOptions();
|
options = new GroupOptions();
|
||||||
}
|
}
|
||||||
if (options.location != null) {
|
|
||||||
additionalSources.add(options.location.file);
|
|
||||||
}
|
|
||||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||||
params.addProperty("name", name);
|
params.addProperty("name", name);
|
||||||
sendMessage("tracingGroup", params, NO_TIMEOUT);
|
sendMessage("tracingGroup", params, NO_TIMEOUT);
|
||||||
@@ -179,110 +149,6 @@ class TracingImpl extends ChannelOwner implements Tracing {
|
|||||||
stopChunkImpl(options == null ? null : options.path);
|
stopChunkImpl(options == null ? null : options.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String currentHarId;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AutoCloseable startHar(Path path, StartHarOptions options) {
|
|
||||||
if (currentHarId != null) {
|
|
||||||
throw new PlaywrightException("HAR recording has already been started");
|
|
||||||
}
|
|
||||||
if (options == null) {
|
|
||||||
options = new StartHarOptions();
|
|
||||||
}
|
|
||||||
boolean isZip = path.toString().endsWith(".zip");
|
|
||||||
HarContentPolicy contentPolicy = options.content != null
|
|
||||||
? options.content
|
|
||||||
: (isZip ? HarContentPolicy.ATTACH : HarContentPolicy.EMBED);
|
|
||||||
HarMode mode = options.mode != null ? options.mode : HarMode.FULL;
|
|
||||||
currentHarId = recordIntoHar(null, path, options.urlFilter, contentPolicy, mode, null);
|
|
||||||
return new DisposableStub(this::stopHar);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stopHar() {
|
|
||||||
if (currentHarId == null) {
|
|
||||||
throw new PlaywrightException("HAR recording has not been started");
|
|
||||||
}
|
|
||||||
String harId = currentHarId;
|
|
||||||
currentHarId = null;
|
|
||||||
exportHar(harId);
|
|
||||||
}
|
|
||||||
|
|
||||||
String recordIntoHar(PageImpl page, Path har, Object urlFilter, HarContentPolicy contentPolicy, HarMode mode, Path resourcesDir) {
|
|
||||||
if (contentPolicy == null) {
|
|
||||||
contentPolicy = HarContentPolicy.ATTACH;
|
|
||||||
}
|
|
||||||
if (mode == null) {
|
|
||||||
mode = HarMode.MINIMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
if (page != null) {
|
|
||||||
params.add("page", page.toProtocolRef());
|
|
||||||
}
|
|
||||||
JsonObject recordHarArgs = new JsonObject();
|
|
||||||
recordHarArgs.addProperty("zip", har.toString().endsWith(".zip"));
|
|
||||||
recordHarArgs.addProperty("content", contentPolicy.name().toLowerCase());
|
|
||||||
recordHarArgs.addProperty("mode", mode.name().toLowerCase());
|
|
||||||
addHarUrlFilter(recordHarArgs, urlFilter);
|
|
||||||
if (resourcesDir != null) {
|
|
||||||
recordHarArgs.addProperty("resourcesDir", resourcesDir.toString());
|
|
||||||
}
|
|
||||||
if (!har.toString().endsWith(".zip")) {
|
|
||||||
recordHarArgs.addProperty("harPath", har.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
params.add("options", recordHarArgs);
|
|
||||||
JsonObject json = sendMessage("harStart", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
String harId = json.get("harId").getAsString();
|
|
||||||
harRecorders.put(harId, new HarRecorder(har, contentPolicy));
|
|
||||||
return harId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void exportHar(String harId) {
|
|
||||||
HarRecorder harParams = harRecorders.remove(harId);
|
|
||||||
if (harParams == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean isLocal = !connection.isRemote;
|
|
||||||
boolean isZip = harParams.path.toString().endsWith(".zip");
|
|
||||||
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("harId", harId);
|
|
||||||
if (isLocal) {
|
|
||||||
params.addProperty("mode", "entries");
|
|
||||||
JsonObject json = sendMessage("harExport", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
if (!isZip) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JsonArray entries = json.getAsJsonArray("entries");
|
|
||||||
connection.localUtils.zip(harParams.path, entries, null, false, false, java.util.Collections.emptyList());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
params.addProperty("mode", "archive");
|
|
||||||
JsonObject json = sendMessage("harExport", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
ArtifactImpl artifact = connection.getExistingObject(json.getAsJsonObject("artifact").get("guid").getAsString());
|
|
||||||
if (isZip) {
|
|
||||||
artifact.saveAs(harParams.path);
|
|
||||||
artifact.delete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String tmpPath = harParams.path + ".tmp";
|
|
||||||
artifact.saveAs(Paths.get(tmpPath));
|
|
||||||
JsonObject unzipParams = new JsonObject();
|
|
||||||
unzipParams.addProperty("zipFile", tmpPath);
|
|
||||||
unzipParams.addProperty("harFile", harParams.path.toString());
|
|
||||||
connection.localUtils.sendMessage("harUnzip", unzipParams, NO_TIMEOUT);
|
|
||||||
artifact.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
void exportAllHars() {
|
|
||||||
for (String harId : new ArrayList<>(harRecorders.keySet())) {
|
|
||||||
exportHar(harId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTracesDir(Path tracesDir) {
|
void setTracesDir(Path tracesDir) {
|
||||||
this.tracesDir = tracesDir;
|
this.tracesDir = tracesDir;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,23 +22,31 @@ import com.microsoft.playwright.Video;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
class VideoImpl implements Video {
|
class VideoImpl implements Video {
|
||||||
private final PageImpl page;
|
private final PageImpl page;
|
||||||
ArtifactImpl artifact;
|
private final WaitableResult<ArtifactImpl> waitableArtifact = new WaitableResult<>();
|
||||||
|
|
||||||
VideoImpl(PageImpl page) {
|
VideoImpl(PageImpl page) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoImpl(PageImpl page, ArtifactImpl artifact) {
|
void setArtifact(ArtifactImpl artifact) {
|
||||||
this.page = page;
|
waitableArtifact.complete(artifact);
|
||||||
this.artifact = artifact;
|
}
|
||||||
|
|
||||||
|
private ArtifactImpl waitForArtifact() {
|
||||||
|
Waitable<ArtifactImpl> waitable = new WaitableRace<>(asList(waitableArtifact, (Waitable<ArtifactImpl>) page.waitableClosedOrCrashed));
|
||||||
|
return page.runUntil(() -> {}, waitable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete() {
|
public void delete() {
|
||||||
if (artifact != null)
|
try {
|
||||||
artifact.delete();
|
waitForArtifact().delete();
|
||||||
|
} catch (PlaywrightException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,15 +54,22 @@ class VideoImpl implements Video {
|
|||||||
if (page.connection.isRemote) {
|
if (page.connection.isRemote) {
|
||||||
throw new PlaywrightException("Path is not available when using browserType.connect(). Use saveAs() to save a local copy.");
|
throw new PlaywrightException("Path is not available when using browserType.connect(). Use saveAs() to save a local copy.");
|
||||||
}
|
}
|
||||||
if (artifact == null)
|
try {
|
||||||
throw new PlaywrightException("Video recording has not been started.");
|
return Paths.get(waitForArtifact().initializer.get("absolutePath").getAsString());
|
||||||
return Paths.get(artifact.initializer.get("absolutePath").getAsString());
|
} catch (PlaywrightException e) {
|
||||||
|
throw new PlaywrightException("Page did not produce any video frames", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAs(Path path) {
|
public void saveAs(Path path) {
|
||||||
if (artifact == null)
|
if (!page.isClosed()) {
|
||||||
throw new PlaywrightException("Video recording has not been started.");
|
throw new PlaywrightException("Page is not yet closed. Close the page prior to calling saveAs");
|
||||||
artifact.saveAs(path);
|
}
|
||||||
|
try {
|
||||||
|
waitForArtifact().saveAs(path);
|
||||||
|
} catch (PlaywrightException e) {
|
||||||
|
throw new PlaywrightException("Page did not produce any video frames", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ public class WaitForEventLogger<T> implements Supplier<T>, Logger {
|
|||||||
{
|
{
|
||||||
JsonObject info = new JsonObject();
|
JsonObject info = new JsonObject();
|
||||||
info.addProperty("phase", "before");
|
info.addProperty("phase", "before");
|
||||||
info.addProperty("event", "");
|
sendWaitForEventInfo(info);
|
||||||
sendWaitInfo(info);
|
|
||||||
}
|
}
|
||||||
JsonObject info = new JsonObject();
|
JsonObject info = new JsonObject();
|
||||||
info.addProperty("phase", "after");
|
info.addProperty("phase", "after");
|
||||||
@@ -52,7 +51,7 @@ public class WaitForEventLogger<T> implements Supplier<T>, Logger {
|
|||||||
info.addProperty("error", e.getMessage());
|
info.addProperty("error", e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
sendWaitInfo(info);
|
sendWaitForEventInfo(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,15 +61,14 @@ public class WaitForEventLogger<T> implements Supplier<T>, Logger {
|
|||||||
JsonObject info = new JsonObject();
|
JsonObject info = new JsonObject();
|
||||||
info.addProperty("phase", "log");
|
info.addProperty("phase", "log");
|
||||||
info.addProperty("message", message);
|
info.addProperty("message", message);
|
||||||
sendWaitInfo(info);
|
sendWaitForEventInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendWaitInfo(JsonObject info) {
|
private void sendWaitForEventInfo(JsonObject info) {
|
||||||
|
info.addProperty("event", "");
|
||||||
info.addProperty("waitId", waitId);
|
info.addProperty("waitId", waitId);
|
||||||
try {
|
JsonObject params = new JsonObject();
|
||||||
channel.sendMessageNoReply("__waitInfo__", info);
|
params.add("info", info);
|
||||||
} catch (RuntimeException e) {
|
channel.sendMessageAsync("waitForEventInfo", params);
|
||||||
// Fire-and-forget: never throw to the caller.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ class WaitableResult<T> implements Waitable<T> {
|
|||||||
throw new TimeoutError(exception.getMessage(), exception);
|
throw new TimeoutError(exception.getMessage(), exception);
|
||||||
} if (exception instanceof TargetClosedError) {
|
} if (exception instanceof TargetClosedError) {
|
||||||
throw new TargetClosedError(exception.getMessage(), exception);
|
throw new TargetClosedError(exception.getMessage(), exception);
|
||||||
} if (exception instanceof ServerErrorWithDetails) {
|
|
||||||
throw new ServerErrorWithDetails((ServerErrorWithDetails) exception);
|
|
||||||
}
|
}
|
||||||
throw new PlaywrightException(exception.getMessage(), exception);
|
throw new PlaywrightException(exception.getMessage(), exception);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,17 +17,14 @@
|
|||||||
package com.microsoft.playwright.impl;
|
package com.microsoft.playwright.impl;
|
||||||
|
|
||||||
import com.microsoft.playwright.WebError;
|
import com.microsoft.playwright.WebError;
|
||||||
import com.microsoft.playwright.options.WebErrorLocation;
|
|
||||||
|
|
||||||
public class WebErrorImpl implements WebError {
|
public class WebErrorImpl implements WebError {
|
||||||
private final PageImpl page;
|
private final PageImpl page;
|
||||||
private final String error;
|
private final String error;
|
||||||
private final WebErrorLocation location;
|
|
||||||
|
|
||||||
WebErrorImpl(PageImpl page, String error, WebErrorLocation location) {
|
WebErrorImpl(PageImpl page, String error) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.location = location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,9 +36,4 @@ public class WebErrorImpl implements WebError {
|
|||||||
public String error() {
|
public String error() {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WebErrorLocation location() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package com.microsoft.playwright.impl;
|
package com.microsoft.playwright.impl;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.microsoft.playwright.PlaywrightException;
|
import com.microsoft.playwright.PlaywrightException;
|
||||||
import com.microsoft.playwright.WebSocketFrame;
|
import com.microsoft.playwright.WebSocketFrame;
|
||||||
import com.microsoft.playwright.WebSocketRoute;
|
import com.microsoft.playwright.WebSocketRoute;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@@ -68,11 +65,6 @@ class WebSocketRouteImpl extends ChannelOwner implements WebSocketRoute {
|
|||||||
public String url() {
|
public String url() {
|
||||||
return initializer.get("url").getAsString();
|
return initializer.get("url").getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> protocols() {
|
|
||||||
return readProtocols();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketRouteImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
WebSocketRouteImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||||
@@ -131,22 +123,6 @@ class WebSocketRouteImpl extends ChannelOwner implements WebSocketRoute {
|
|||||||
return initializer.get("url").getAsString();
|
return initializer.get("url").getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> protocols() {
|
|
||||||
return readProtocols();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> readProtocols() {
|
|
||||||
List<String> result = new ArrayList<>();
|
|
||||||
if (!initializer.has("protocols")) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
for (JsonElement element : initializer.getAsJsonArray("protocols")) {
|
|
||||||
result.add(element.getAsString());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void afterHandle() {
|
void afterHandle() {
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
return;
|
return;
|
||||||
@@ -184,9 +160,9 @@ class WebSocketRouteImpl extends ChannelOwner implements WebSocketRoute {
|
|||||||
sendMessageAsync("sendToPage", messageParams);
|
sendMessageAsync("sendToPage", messageParams);
|
||||||
}
|
}
|
||||||
} else if ("closePage".equals(event)) {
|
} else if ("closePage".equals(event)) {
|
||||||
Integer code = params.has("code") ? params.get("code").getAsInt() : null;
|
int code = params.get("code").getAsInt();
|
||||||
String reason = params.has("reason") ? params.get("reason").getAsString() : null;
|
String reason = params.get("reason").getAsString();
|
||||||
boolean wasClean = params.has("wasClean") && params.get("wasClean").getAsBoolean();
|
boolean wasClean = params.get("wasClean").getAsBoolean();
|
||||||
if (onPageClose != null) {
|
if (onPageClose != null) {
|
||||||
onPageClose.accept(code, reason);
|
onPageClose.accept(code, reason);
|
||||||
} else {
|
} else {
|
||||||
@@ -197,9 +173,9 @@ class WebSocketRouteImpl extends ChannelOwner implements WebSocketRoute {
|
|||||||
sendMessageAsync("closeServer", closeParams);
|
sendMessageAsync("closeServer", closeParams);
|
||||||
}
|
}
|
||||||
} else if ("closeServer".equals(event)) {
|
} else if ("closeServer".equals(event)) {
|
||||||
Integer code = params.has("code") ? params.get("code").getAsInt() : null;
|
int code = params.get("code").getAsInt();
|
||||||
String reason = params.has("reason") ? params.get("reason").getAsString() : null;
|
String reason = params.get("reason").getAsString();
|
||||||
boolean wasClean = params.has("wasClean") && params.get("wasClean").getAsBoolean();
|
boolean wasClean = params.get("wasClean").getAsBoolean();
|
||||||
if (onServerClose != null) {
|
if (onServerClose != null) {
|
||||||
onServerClose.accept(code, reason);
|
onServerClose.accept(code, reason);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,77 +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.impl;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.microsoft.playwright.WebStorage;
|
|
||||||
import com.microsoft.playwright.options.WebStorageItem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.impl.ChannelOwner.NO_TIMEOUT;
|
|
||||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
class WebStorageImpl implements WebStorage {
|
|
||||||
private final PageImpl page;
|
|
||||||
private final String kind;
|
|
||||||
|
|
||||||
WebStorageImpl(PageImpl page, String kind) {
|
|
||||||
this.page = page;
|
|
||||||
this.kind = kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JsonObject createParams() {
|
|
||||||
JsonObject params = new JsonObject();
|
|
||||||
params.addProperty("kind", kind);
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<WebStorageItem> items() {
|
|
||||||
JsonObject json = page.sendMessage("webStorageItems", createParams(), NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return asList(gson().fromJson(json.getAsJsonArray("items"), WebStorageItem[].class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItem(String name) {
|
|
||||||
JsonObject params = createParams();
|
|
||||||
params.addProperty("name", name);
|
|
||||||
JsonObject json = page.sendMessage("webStorageGetItem", params, NO_TIMEOUT).getAsJsonObject();
|
|
||||||
return json.has("value") ? json.get("value").getAsString() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setItem(String name, String value) {
|
|
||||||
JsonObject params = createParams();
|
|
||||||
params.addProperty("name", name);
|
|
||||||
params.addProperty("value", value);
|
|
||||||
page.sendMessage("webStorageSetItem", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeItem(String name) {
|
|
||||||
JsonObject params = createParams();
|
|
||||||
params.addProperty("name", name);
|
|
||||||
page.sendMessage("webStorageRemoveItem", params, NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
page.sendMessage("webStorageClear", createParams(), NO_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +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.options;
|
|
||||||
|
|
||||||
public class Annotate {
|
|
||||||
/**
|
|
||||||
* How long each annotation is displayed in milliseconds. Defaults to {@code 500}.
|
|
||||||
*/
|
|
||||||
public Double duration;
|
|
||||||
/**
|
|
||||||
* Position of the action title overlay. Defaults to {@code "top-right"}.
|
|
||||||
*/
|
|
||||||
public AnnotatePosition position;
|
|
||||||
/**
|
|
||||||
* Font size of the action title in pixels. Defaults to {@code 24}.
|
|
||||||
*/
|
|
||||||
public Integer fontSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How long each annotation is displayed in milliseconds. Defaults to {@code 500}.
|
|
||||||
*/
|
|
||||||
public Annotate setDuration(double duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Position of the action title overlay. Defaults to {@code "top-right"}.
|
|
||||||
*/
|
|
||||||
public Annotate setPosition(AnnotatePosition position) {
|
|
||||||
this.position = position;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Font size of the action title in pixels. Defaults to {@code 24}.
|
|
||||||
*/
|
|
||||||
public Annotate setFontSize(int fontSize) {
|
|
||||||
this.fontSize = fontSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.options;
|
|
||||||
|
|
||||||
public enum AnnotatePosition {
|
|
||||||
TOP_LEFT,
|
|
||||||
TOP,
|
|
||||||
TOP_RIGHT,
|
|
||||||
BOTTOM_LEFT,
|
|
||||||
BOTTOM,
|
|
||||||
BOTTOM_RIGHT
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public enum AriaSnapshotMode {
|
|
||||||
AI,
|
|
||||||
DEFAULT
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public class BindResult {
|
|
||||||
public String endpoint;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public enum ConsoleMessagesFilter {
|
|
||||||
ALL,
|
|
||||||
SINCE_NAVIGATION
|
|
||||||
}
|
|
||||||
@@ -1,23 +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.options;
|
|
||||||
|
|
||||||
public class DebuggerPausedDetails {
|
|
||||||
public Location location;
|
|
||||||
public String title;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +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.options;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class DropPayload {
|
|
||||||
public Object files;
|
|
||||||
public Map<String, String> data;
|
|
||||||
|
|
||||||
public DropPayload setFiles(Object files) {
|
|
||||||
this.files = files;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public DropPayload setData(Map<String, String> data) {
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public enum PseudoElement {
|
|
||||||
BEFORE,
|
|
||||||
AFTER
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public enum ScreencastCursor {
|
|
||||||
NONE,
|
|
||||||
POINTER
|
|
||||||
}
|
|
||||||
@@ -18,6 +18,5 @@ package com.microsoft.playwright.options;
|
|||||||
|
|
||||||
public enum ScreenshotType {
|
public enum ScreenshotType {
|
||||||
PNG,
|
PNG,
|
||||||
JPEG,
|
JPEG
|
||||||
WEBP
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +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.options;
|
|
||||||
|
|
||||||
public enum ScrollMode {
|
|
||||||
AUTO,
|
|
||||||
NONE
|
|
||||||
}
|
|
||||||
@@ -1,33 +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.options;
|
|
||||||
|
|
||||||
public class Size {
|
|
||||||
/**
|
|
||||||
* Max frame width in pixels.
|
|
||||||
*/
|
|
||||||
public int width;
|
|
||||||
/**
|
|
||||||
* Max frame height in pixels.
|
|
||||||
*/
|
|
||||||
public int height;
|
|
||||||
|
|
||||||
public Size(int width, int height) {
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,42 +22,42 @@ public class Timing {
|
|||||||
*/
|
*/
|
||||||
public double startTime;
|
public double startTime;
|
||||||
/**
|
/**
|
||||||
* Time immediately before the client starts the domain name lookup for the resource. The value is given in milliseconds
|
* Time immediately before the browser starts the domain name lookup for the resource. The value is given in milliseconds
|
||||||
* relative to {@code startTime}, -1 if not available.
|
* relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double domainLookupStart;
|
public double domainLookupStart;
|
||||||
/**
|
/**
|
||||||
* Time immediately after the client ends the domain name lookup for the resource. The value is given in milliseconds
|
* Time immediately after the browser starts the domain name lookup for the resource. The value is given in milliseconds
|
||||||
* relative to {@code startTime}, -1 if not available.
|
* relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double domainLookupEnd;
|
public double domainLookupEnd;
|
||||||
/**
|
/**
|
||||||
* Time immediately before the client starts establishing the connection to the server to retrieve the resource. The value
|
* Time immediately before the user agent starts establishing the connection to the server to retrieve the resource. The
|
||||||
* is given in milliseconds relative to {@code startTime}, -1 if not available.
|
* value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double connectStart;
|
public double connectStart;
|
||||||
/**
|
/**
|
||||||
* Time immediately before the client starts the handshake process to secure the current connection. The value is given in
|
* Time immediately before the browser starts the handshake process to secure the current connection. The value is given in
|
||||||
* milliseconds relative to {@code startTime}, -1 if not available.
|
* milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double secureConnectionStart;
|
public double secureConnectionStart;
|
||||||
/**
|
/**
|
||||||
* Time immediately after the client establishes the connection to the server to retrieve the resource. The value is given
|
* Time immediately before the user agent starts establishing the connection to the server to retrieve the resource. The
|
||||||
* in milliseconds relative to {@code startTime}, -1 if not available.
|
* value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double connectEnd;
|
public double connectEnd;
|
||||||
/**
|
/**
|
||||||
* Time immediately before the client starts requesting the resource from the server, cache, or local resource. The value
|
* Time immediately before the browser starts requesting the resource from the server, cache, or local resource. The value
|
||||||
* is given in milliseconds relative to {@code startTime}, -1 if not available.
|
* is given in milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double requestStart;
|
public double requestStart;
|
||||||
/**
|
/**
|
||||||
* Time immediately after the client receives the first byte of the response from the server, cache, or local resource. The
|
* Time immediately after the browser receives the first byte of the response from the server, cache, or local resource.
|
||||||
* value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
* The value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double responseStart;
|
public double responseStart;
|
||||||
/**
|
/**
|
||||||
* Time immediately after the client receives the last byte of the resource or immediately before the transport connection
|
* Time immediately after the browser receives the last byte of the resource or immediately before the transport connection
|
||||||
* is closed, whichever comes first. The value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
* is closed, whichever comes first. The value is given in milliseconds relative to {@code startTime}, -1 if not available.
|
||||||
*/
|
*/
|
||||||
public double responseEnd;
|
public double responseEnd;
|
||||||
|
|||||||
@@ -1,41 +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.options;
|
|
||||||
|
|
||||||
public class VirtualCredential {
|
|
||||||
/**
|
|
||||||
* Base64url-encoded credential id.
|
|
||||||
*/
|
|
||||||
public String id;
|
|
||||||
/**
|
|
||||||
* Relying party id.
|
|
||||||
*/
|
|
||||||
public String rpId;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded user handle.
|
|
||||||
*/
|
|
||||||
public String userHandle;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded PKCS#8 (DER) private key.
|
|
||||||
*/
|
|
||||||
public String privateKey;
|
|
||||||
/**
|
|
||||||
* Base64url-encoded SPKI (DER) public key.
|
|
||||||
*/
|
|
||||||
public String publicKey;
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user