Compare commits
52 Commits
release-1.41
...
v1.43.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 26861a2f1e | |||
| 04e77b9c9a | |||
| ccf4575bc8 | |||
| 90aa4579c4 | |||
| 1a8f5f7746 | |||
| a917f2ef5c | |||
| 452effbe3f | |||
| f497bcc27d | |||
| 240f8d0873 | |||
| e7653ddde7 | |||
| a135675580 | |||
| 4b9a436d57 | |||
| f15147ba33 | |||
| 8cdfd183b8 | |||
| c37b13eafb | |||
| 53879c8405 | |||
| 91c3264c75 | |||
| 419c378e0f | |||
| 270bc99420 | |||
| 942a281f15 | |||
| 3417717c62 | |||
| f98ad20dcc | |||
| 8fb21af3ff | |||
| 049493c242 | |||
| be06d1e7db | |||
| b9b3552cc4 | |||
| 1b2ac3f2c3 | |||
| e8e076310a | |||
| 4a07105d8b | |||
| 7f2a5fe9af | |||
| 99ab89917f | |||
| bd97c96707 | |||
| d38bae17d3 | |||
| 23aa10690e | |||
| 72b36b46e2 | |||
| 70a8577f6f | |||
| de1d6a6b36 | |||
| 36705817bf | |||
| 8286f8a9d8 | |||
| 906d947c26 | |||
| e26a2710bd | |||
| dbe1d30feb | |||
| 4121a28299 | |||
| 0ad604f058 | |||
| d72000c793 | |||
| 9ef73b389b | |||
| da2501af49 | |||
| 7ce6c7f0a0 | |||
| 197ee801ad | |||
| 77e59999ab | |||
| c4e1f898e6 | |||
| ffe2bd4a96 |
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"hydrated": false,
|
||||
"properties": {
|
||||
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions",
|
||||
"hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance."
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"suppressionSets": {
|
||||
"default": {
|
||||
"name": "default",
|
||||
"createdDate": "2024-02-06 20:37:57Z",
|
||||
"lastUpdatedDate": "2024-02-06 20:37:57Z"
|
||||
}
|
||||
},
|
||||
"results": {
|
||||
"de854c6ab9b27b1ec642cec1a51059b92f88815a231c1c8f4b8e71d9e378f174": {
|
||||
"signature": "de854c6ab9b27b1ec642cec1a51059b92f88815a231c1c8f4b8e71d9e378f174",
|
||||
"alternativeSignatures": [
|
||||
"79827cf2e75a7f99eec716562fb9fa0d49014ac96b7afc76d29d79a33e8edd94"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"ebe0026db71ae4bb2d8e76b706198003079a5c095658de8dd49e67f7e572ea46": {
|
||||
"signature": "ebe0026db71ae4bb2d8e76b706198003079a5c095658de8dd49e67f7e572ea46",
|
||||
"alternativeSignatures": [],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"bb02ef965dce40b6c950b6d0cf8a9f41c08c5e33f17268fb208f3687b11ffa26": {
|
||||
"signature": "bb02ef965dce40b6c950b6d0cf8a9f41c08c5e33f17268fb208f3687b11ffa26",
|
||||
"alternativeSignatures": [
|
||||
"3a8630eaccc2c5c39ae78836bb115bf55557058bad206fdad7dbe4f0ae466ed1"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"dffa3e24f6dc7542d741b2fab22eec657aca441a51cee515ca9bb4932995a416": {
|
||||
"signature": "dffa3e24f6dc7542d741b2fab22eec657aca441a51cee515ca9bb4932995a416",
|
||||
"alternativeSignatures": [
|
||||
"56a4b454840e2c21d44a76d9ab09fde76fba682ce7508a3f6abf7b411d389e56"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"5dbcaaac8cdccc6df557cbde94e5d7e0f1c8a67546ba82a1b85b629030f3d311": {
|
||||
"signature": "5dbcaaac8cdccc6df557cbde94e5d7e0f1c8a67546ba82a1b85b629030f3d311",
|
||||
"alternativeSignatures": [
|
||||
"fdb8e8af8d5697f767d0e55194f91d4a089d981555e00d058ba866acb8602014"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"b7db026b2a60bdb63af1c0938ac16d9414bb4d38e9efdc51626e12aa55f6b72f": {
|
||||
"signature": "b7db026b2a60bdb63af1c0938ac16d9414bb4d38e9efdc51626e12aa55f6b72f",
|
||||
"alternativeSignatures": [
|
||||
"bf7bb897e644659827d8dc8d55f719296d3ab94dc750b666ce90d8057361d9d5"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"aa702d85554c352e3016e3ec3d790df489833dc97e3733c58b57915ec125f47b": {
|
||||
"signature": "aa702d85554c352e3016e3ec3d790df489833dc97e3733c58b57915ec125f47b",
|
||||
"alternativeSignatures": [
|
||||
"948787329d52a66b4691383c81af407b03e68344a6685bbab3cfa8eb8db34f81"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"38174b5c9b474c3c0278d4c4173c14022e03dec3dc4db5ced51d2ca8459e7f2a": {
|
||||
"signature": "38174b5c9b474c3c0278d4c4173c14022e03dec3dc4db5ced51d2ca8459e7f2a",
|
||||
"alternativeSignatures": [
|
||||
"a9efa99679f3966da96a8b89f1250576cfceda774556d43ea89ea84289967276"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"08a4e1be4662d897e5b2b7a7dc6d6901405462cd2d5f8ad433c13e12a8503fb6": {
|
||||
"signature": "08a4e1be4662d897e5b2b7a7dc6d6901405462cd2d5f8ad433c13e12a8503fb6",
|
||||
"alternativeSignatures": [
|
||||
"009132f89939956a3f4471bb13353394015c9a7e675d118aa427e75f05658e05"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
},
|
||||
"551d69737553150380e58bc9a8ae1e8f17da931561ea4e195781fb8cad225188": {
|
||||
"signature": "551d69737553150380e58bc9a8ae1e8f17da931561ea4e195781fb8cad225188",
|
||||
"alternativeSignatures": [
|
||||
"617ad56322c5fb82a162b0b583e676d66a8e76b0d444aaab487865e4bf89e83b"
|
||||
],
|
||||
"memberOf": [
|
||||
"default"
|
||||
],
|
||||
"createdDate": "2024-02-06 20:37:57Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +1,81 @@
|
||||
trigger:
|
||||
none
|
||||
|
||||
# don't trigger for Pull Requests
|
||||
trigger: none
|
||||
pr: none
|
||||
|
||||
pool:
|
||||
vmImage: ubuntu-22.04
|
||||
resources:
|
||||
repositories:
|
||||
- repository: 1esPipelines
|
||||
type: git
|
||||
name: 1ESPipelineTemplates/1ESPipelineTemplates
|
||||
ref: refs/tags/release
|
||||
|
||||
steps:
|
||||
- bash: |
|
||||
if [[ ! "$CURRENT_BRANCH" =~ ^release-.* ]]; then
|
||||
echo "Can only publish from a release branch."
|
||||
echo "Unexpected branch name: $CURRENT_BRANCH"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
CURRENT_BRANCH: ${{ variables['Build.SourceBranchName'] }}
|
||||
displayName: "Check the branch is a release branch"
|
||||
|
||||
- bash: |
|
||||
echo "importing GPG key:"
|
||||
# Pipeline variables do not preserve line ends so we use base64 instead of --armored as a workaround.
|
||||
echo $GPG_PRIVATE_KEY_BASE64 | base64 -d | gpg --batch --import
|
||||
echo "list keys after import:"
|
||||
gpg --list-keys
|
||||
env:
|
||||
GPG_PRIVATE_KEY_BASE64: $(GPG_PRIVATE_KEY_BASE64) # secret variable has to be mapped to an env variable
|
||||
displayName: "Import gpg key"
|
||||
|
||||
- bash: ./scripts/download_driver_for_all_platforms.sh
|
||||
displayName: 'Download driver'
|
||||
|
||||
- bash: mvn -B deploy -D skipTests --no-transfer-progress --activate-profiles release -D gpg.passphrase=$GPG_PASSPHRASE -DaltDeploymentRepository=snapshot-repo::default::file:$(pwd)/local-build
|
||||
displayName: 'Build and deploy to a local directory'
|
||||
env:
|
||||
GPG_PASSPHRASE: $(GPG_PASSPHRASE) # secret variable has to be mapped to an env variable
|
||||
|
||||
- bash: |
|
||||
for file in $(find snapshots -type f); do
|
||||
echo "processing: $file"
|
||||
if [[ $file =~ \.(md5|sha1|sha256)$ ]]; then
|
||||
continue
|
||||
fi
|
||||
sha256sum "$file" | cut -f1 -d \ > "$file.sha256"
|
||||
done
|
||||
displayName: 'Create .sha256 files'
|
||||
|
||||
- task: EsrpRelease@4
|
||||
inputs:
|
||||
ConnectedServiceName: 'Playwright-ESRP'
|
||||
Intent: 'PackageDistribution'
|
||||
ContentType: 'Maven'
|
||||
ContentSource: 'Folder'
|
||||
FolderLocation: './local-build'
|
||||
WaitForReleaseCompletion: true
|
||||
Owners: 'yurys@microsoft.com'
|
||||
Approvers: 'maxschmitt@microsoft.com'
|
||||
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
|
||||
MainPublisher: 'Playwright'
|
||||
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
|
||||
displayName: 'ESRP Release to Maven'
|
||||
extends:
|
||||
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
|
||||
parameters:
|
||||
pool:
|
||||
name: DevDivPlaywrightAzurePipelinesUbuntu2204
|
||||
os: linux
|
||||
sdl:
|
||||
sourceAnalysisPool:
|
||||
name: DevDivPlaywrightAzurePipelinesWindows2022
|
||||
# The image must be windows-based due to restrictions of the SDL tools. See: https://aka.ms/AAo6v8e
|
||||
# In the case of a windows build, this can be the same as the above pool image.
|
||||
os: windows
|
||||
suppression:
|
||||
suppressionFile: $(Build.SourcesDirectory)\.azure-pipelines\guardian\SDL\.gdnsuppress
|
||||
stages:
|
||||
- stage: Stage
|
||||
jobs:
|
||||
- job: HostJob
|
||||
steps:
|
||||
- bash: |
|
||||
if [[ ! "$CURRENT_BRANCH" =~ ^release-.* ]]; then
|
||||
echo "Can only publish from a release branch."
|
||||
echo "Unexpected branch name: $CURRENT_BRANCH"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
CURRENT_BRANCH: ${{ variables['Build.SourceBranchName'] }}
|
||||
displayName: "Check the branch is a release branch"
|
||||
|
||||
- bash: |
|
||||
echo "importing GPG key:"
|
||||
# Pipeline variables do not preserve line ends so we use base64 instead of --armored as a workaround.
|
||||
echo $GPG_PRIVATE_KEY_BASE64 | base64 -d | gpg --batch --import
|
||||
echo "list keys after import:"
|
||||
gpg --list-keys
|
||||
env:
|
||||
GPG_PRIVATE_KEY_BASE64: $(GPG_PRIVATE_KEY_BASE64) # secret variable has to be mapped to an env variable
|
||||
displayName: "Import gpg key"
|
||||
|
||||
- bash: ./scripts/download_driver_for_all_platforms.sh
|
||||
displayName: 'Download driver'
|
||||
|
||||
- bash: mvn -B deploy -D skipTests --no-transfer-progress --activate-profiles release -D gpg.passphrase=$GPG_PASSPHRASE -DaltDeploymentRepository=snapshot-repo::default::file:$(pwd)/local-build
|
||||
displayName: 'Build and deploy to a local directory'
|
||||
env:
|
||||
GPG_PASSPHRASE: $(GPG_PASSPHRASE) # secret variable has to be mapped to an env variable
|
||||
|
||||
- bash: |
|
||||
for file in $(find snapshots -type f); do
|
||||
echo "processing: $file"
|
||||
if [[ $file =~ \.(md5|sha1|sha256)$ ]]; then
|
||||
continue
|
||||
fi
|
||||
sha256sum "$file" | cut -f1 -d \ > "$file.sha256"
|
||||
done
|
||||
displayName: 'Create .sha256 files'
|
||||
|
||||
- task: EsrpRelease@4
|
||||
inputs:
|
||||
ConnectedServiceName: 'Playwright-ESRP'
|
||||
Intent: 'PackageDistribution'
|
||||
ContentType: 'Maven'
|
||||
ContentSource: 'Folder'
|
||||
FolderLocation: './local-build'
|
||||
WaitForReleaseCompletion: true
|
||||
Owners: 'yurys@microsoft.com'
|
||||
Approvers: 'maxschmitt@microsoft.com'
|
||||
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
|
||||
MainPublisher: 'Playwright'
|
||||
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
|
||||
displayName: 'ESRP Release to Maven'
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Something doesn't work like it should? Tell us!
|
||||
title: "[BUG]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- ⚠️⚠️ Do not delete this template ⚠️⚠️ -->
|
||||
|
||||
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
|
||||
<!-- 🧪 Test using the latest Playwright release to see if your issue has already been fixed -->
|
||||
<!-- 💡 Provide enough information for us to be able to reproduce your issue locally -->
|
||||
|
||||
### System info
|
||||
- Playwright Version: [v1.XX]
|
||||
- Operating System: [All, Windows 11, Ubuntu 20, macOS 13.2, etc.]
|
||||
- Browser: [All, Chromium, Firefox, WebKit]
|
||||
- Other info:
|
||||
|
||||
### Source code
|
||||
|
||||
- [ ] I provided exact source code that allows reproducing the issue locally.
|
||||
|
||||
<!-- For simple cases, please provide a self-contained test file along with the config file -->
|
||||
<!-- For larger cases, you can provide a GitHub repo you created for this issue -->
|
||||
<!-- If we can not reproduce the problem locally, we won't be able to act on it -->
|
||||
<!-- You can still file without the exact code and we will try to help, but if we can't repro, it will be closed -->
|
||||
|
||||
**Link to the GitHub repository with the repro**
|
||||
|
||||
[https://github.com/your_profile/playwright_issue_title]
|
||||
|
||||
or
|
||||
|
||||
**Test file (self-contained)**
|
||||
|
||||
```java
|
||||
import com.microsoft.playwright.*;
|
||||
|
||||
public class ExampleReproducible {
|
||||
public static void main(String[] args) {
|
||||
try (Playwright playwright = Playwright.create()) {
|
||||
Browser browser = playwright.chromium().launch();
|
||||
BrowserContext context = browser.newContext();
|
||||
Page page = context.newPage();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Steps**
|
||||
- [Run the test]
|
||||
- [...]
|
||||
|
||||
**Expected**
|
||||
|
||||
[Describe expected behavior]
|
||||
|
||||
**Actual**
|
||||
|
||||
[Describe actual behavior]
|
||||
@@ -0,0 +1,95 @@
|
||||
name: Bug Report 🪲
|
||||
description: Create a bug report to help us improve
|
||||
title: '[Bug]: '
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Please follow these steps first:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Troubleshoot
|
||||
If Playwright is not behaving the way you expect, we'd ask you to look at the [documentation](https://playwright.dev/java/docs/intro) and search the issue tracker for evidence supporting your expectation.
|
||||
Please make reasonable efforts to troubleshoot and rule out issues with your code, the configuration, or any 3rd party libraries you might be using.
|
||||
Playwright offers [several debugging tools](https://playwright.dev/java/docs/debug) that you can use to troubleshoot your issues.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Ask for help through appropriate channels
|
||||
If you feel unsure about the cause of the problem, consider asking for help on for example [StackOverflow](https://stackoverflow.com/questions/ask) or our [Discord channel](https://aka.ms/playwright/discord) before posting a bug report. The issue tracker is not a help forum.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Make a minimal reproduction
|
||||
To file the report, you will need a GitHub repository with a minimal (but complete) example and simple/clear steps on how to reproduce the bug.
|
||||
The simpler you can make it, the more likely we are to successfully verify and fix the bug.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
> [!IMPORTANT]
|
||||
> Bug reports without a minimal reproduction will be rejected.
|
||||
|
||||
---
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: |
|
||||
The version of Playwright you are using.
|
||||
Is it the [latest](https://github.com/microsoft/playwright-java/releases)? Test and see if the bug has already been fixed.
|
||||
placeholder: ex. 1.41.1
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Please link to a repository with a minimal reproduction and describe accurately how we can reproduce/verify the bug.
|
||||
placeholder: |
|
||||
Example steps (replace with your own):
|
||||
1. Clone my repo at https://github.com/<myuser>/example
|
||||
2. mvn test
|
||||
3. You should see the error come up
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A description of what you expect to happen.
|
||||
placeholder: I expect to see X or Y
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: Actual behavior
|
||||
description: |
|
||||
A clear and concise description of the unexpected behavior.
|
||||
Please include any relevant output here, especially any error messages.
|
||||
placeholder: A bug happened!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Anything else that might be relevant
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: envinfo
|
||||
attributes:
|
||||
label: Environment
|
||||
description: |
|
||||
Please provide information about the environment you are running in.
|
||||
placeholder: |
|
||||
- Operating System: [Ubuntu 22.04]
|
||||
- CPU: [arm64]
|
||||
- Browser: [All, Chromium, Firefox, WebKit]
|
||||
- Java Version: [20]
|
||||
- Maven Version: [3.8.6]
|
||||
- Other info:
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,3 +1,4 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Join our Discord Server
|
||||
url: https://aka.ms/playwright/discord
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Documentation 📖
|
||||
description: Submit a request to add or update documentation
|
||||
title: '[Docs]: '
|
||||
labels: ['Documentation :book:']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Thank you for helping us improve our documentation!
|
||||
Please be sure you are looking at [the Next version of the documentation](https://playwright.dev/java/docs/next/intro) before opening an issue here.
|
||||
- type: textarea
|
||||
id: links
|
||||
attributes:
|
||||
label: Page(s)
|
||||
description: |
|
||||
Links to one or more documentation pages that should be modified.
|
||||
If you are reporting an issue with a specific section of a page, try to link directly to the nearest anchor.
|
||||
If you are suggesting that a new page be created, link to the parent of the proposed page.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: |
|
||||
Describe the change you are requesting.
|
||||
If the issue pertains to a single function or matcher, be sure to specify the entire call signature.
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Feature Request 🚀
|
||||
description: Submit a proposal for a new feature
|
||||
title: '[Feature]: '
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Thank you for taking the time to suggest a new feature!
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: '🚀 Feature Request'
|
||||
description: A clear and concise description of what the feature is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: example
|
||||
attributes:
|
||||
label: Example
|
||||
description: Describe how this feature would be used.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: motivation
|
||||
attributes:
|
||||
label: Motivation
|
||||
description: |
|
||||
Outline your motivation for the proposal. How will it make Playwright better?
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Request new features to be added
|
||||
title: "[Feature]"
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
Let us know what functionality you'd like to see in Playwright and what your use case is.
|
||||
Do you think others might benefit from this as well?
|
||||
@@ -0,0 +1,27 @@
|
||||
name: 'Questions / Help 💬'
|
||||
description: If you have questions, please check StackOverflow or Discord
|
||||
title: '[Please read the message below]'
|
||||
labels: [':speech_balloon: Question']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Questions and Help 💬
|
||||
|
||||
This issue tracker is reserved for bug reports and feature requests.
|
||||
|
||||
For anything else, such as questions or getting help, please see:
|
||||
|
||||
- [The Playwright documentation](https://playwright.dev/java)
|
||||
- [Our Discord server](https://aka.ms/playwright/discord)
|
||||
- type: checkboxes
|
||||
id: no-post
|
||||
attributes:
|
||||
label: |
|
||||
Please do not submit this issue.
|
||||
description: |
|
||||
> [!IMPORTANT]
|
||||
> This issue will be closed.
|
||||
options:
|
||||
- label: I understand
|
||||
required: true
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
name: Report regression
|
||||
about: Functionality that used to work and does not any more
|
||||
title: "[REGRESSION]: "
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Context:**
|
||||
- GOOD Playwright Version: [what Playwright version worked nicely?]
|
||||
- BAD Playwright Version: [what Playwright version doesn't work any more?]
|
||||
- Operating System: [e.g. Windows, Linux or Mac]
|
||||
- Extra: [any specific details about your environment]
|
||||
|
||||
**Code Snippet**
|
||||
|
||||
Help us help you! Put down a short code snippet that illustrates your bug and
|
||||
that we can run and debug locally. For example:
|
||||
|
||||
```java
|
||||
import com.microsoft.playwright.*;
|
||||
|
||||
public class ExampleReproducible {
|
||||
public static void main(String[] args) {
|
||||
try (Playwright playwright = Playwright.create()) {
|
||||
Browser browser = playwright.chromium().launch();
|
||||
BrowserContext context = browser.newContext();
|
||||
Page page = context.newPage();
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Describe the bug**
|
||||
|
||||
Add any other details about the problem here.
|
||||
@@ -0,0 +1,90 @@
|
||||
name: Report regression
|
||||
description: Functionality that used to work and does not any more
|
||||
title: "[Regression]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# Please follow these steps first:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## Make a minimal reproduction
|
||||
To file the report, you will need a GitHub repository with a minimal (but complete) example and simple/clear steps on how to reproduce the regression.
|
||||
The simpler you can make it, the more likely we are to successfully verify and fix the regression.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
> [!IMPORTANT]
|
||||
> Regression reports without a minimal reproduction will be rejected.
|
||||
|
||||
---
|
||||
- type: input
|
||||
id: goodVersion
|
||||
attributes:
|
||||
label: Last Good Version
|
||||
description: |
|
||||
Last version of Playwright where the feature was working.
|
||||
placeholder: ex. 1.40.1
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: badVersion
|
||||
attributes:
|
||||
label: First Bad Version
|
||||
description: |
|
||||
First version of Playwright where the feature was broken.
|
||||
Is it the [latest](https://github.com/microsoft/playwright-java/releases)? Test and see if the regression has already been fixed.
|
||||
placeholder: ex. 1.41.1
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Please link to a repository with a minimal reproduction and describe accurately how we can reproduce/verify the bug.
|
||||
placeholder: |
|
||||
Example steps (replace with your own):
|
||||
1. Clone my repo at https://github.com/<myuser>/example
|
||||
2. mvn test
|
||||
3. You should see the error come up
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A description of what you expect to happen.
|
||||
placeholder: I expect to see X or Y
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: Actual behavior
|
||||
description: A clear and concise description of the unexpected behavior.
|
||||
placeholder: A bug happened!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Anything else that might be relevant
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: envinfo
|
||||
attributes:
|
||||
label: Environment
|
||||
description: |
|
||||
Please provide information about the environment you are running in.
|
||||
placeholder: |
|
||||
- Operating System: [Ubuntu 22.04]
|
||||
- CPU: [arm64]
|
||||
- Browser: [All, Chromium, Firefox, WebKit]
|
||||
- Java Version: [20]
|
||||
- Maven Version: [3.8.6]
|
||||
- Other info:
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven"
|
||||
directory: "/" # Location of the pom.xml file
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 10
|
||||
allow:
|
||||
- dependency-type: "direct" # Optional: Only update direct dependencies
|
||||
- dependency-type: "indirect" # Optional: Only update indirect (transitive) dependencies
|
||||
@@ -1,25 +0,0 @@
|
||||
name: "devrelease:docker"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
publish-canary-docker:
|
||||
name: "publish to DockerHub"
|
||||
runs-on: ubuntu-20.04
|
||||
if: github.repository == 'microsoft/playwright-java'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: azure/docker-login@v1
|
||||
with:
|
||||
login-server: playwright.azurecr.io
|
||||
username: playwright
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Docker QEMU for arm64 docker builds
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
platforms: arm64
|
||||
- name: publish docker canary
|
||||
run: ./utils/docker/publish_docker.sh canary
|
||||
@@ -8,25 +8,23 @@ on:
|
||||
required: true
|
||||
type: boolean
|
||||
description: "Is this a release image?"
|
||||
branches:
|
||||
- release-*
|
||||
jobs:
|
||||
publish-canary-docker:
|
||||
name: publish to DockerHub
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
if: github.repository == 'microsoft/playwright-java'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: azure/docker-login@v1
|
||||
with:
|
||||
login-server: playwright.azurecr.io
|
||||
username: playwright
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Set up Docker QEMU for arm64 docker builds
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: arm64
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- run: ./utils/docker/publish_docker.sh stable
|
||||
if: (github.event_name != 'workflow_dispatch' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_release == 'true')
|
||||
- run: ./utils/docker/publish_docker.sh canary
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
- name: Run tracing tests w/ sources
|
||||
run: mvn test --no-transfer-progress --fail-at-end -D test=*TestTracing* -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
|
||||
run: mvn test --no-transfer-progress --fail-at-end --projects=playwright -D test=*TestTracing* -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
|
||||
env:
|
||||
BROWSER: ${{ matrix.browser }}
|
||||
PLAYWRIGHT_JAVA_SRC: src/test/java
|
||||
|
||||
+2
-2
@@ -34,9 +34,9 @@ Names of published driver archives can be found at https://github.com/microsoft/
|
||||
mvn compile
|
||||
mvn test
|
||||
# Executing a single test
|
||||
BROWSER=chromium mvn test -Dtest=TestPageNetworkSizes#shouldHaveTheCorrectResponseBodySize
|
||||
BROWSER=chromium mvn test --projects=playwright -Dtest=TestPageNetworkSizes#shouldHaveTheCorrectResponseBodySize
|
||||
# Executing a single test class
|
||||
BROWSER=chromium mvn test -Dtest=TestPageNetworkSizes
|
||||
BROWSER=chromium mvn test --projects=playwright -Dtest=TestPageNetworkSizes
|
||||
```
|
||||
|
||||
### Generating API
|
||||
|
||||
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium <!-- GEN:chromium-version -->121.0.6167.57<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Chromium <!-- GEN:chromium-version -->124.0.6367.29<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||
| Firefox <!-- GEN:firefox-version -->121.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Firefox <!-- GEN:firefox-version -->124.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/intro#system-requirements) for details.
|
||||
|
||||
@@ -43,7 +43,7 @@ To run Playwright simply add following dependency to your Maven project:
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.28.1</version>
|
||||
<version>1.41.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ To run Playwright using Gradle add following dependency to your build.gradle fil
|
||||
|
||||
```gradle
|
||||
dependencies {
|
||||
implementation group: 'com.microsoft.playwright', name: 'playwright', version: '1.28.1'
|
||||
implementation group: 'com.microsoft.playwright', name: 'playwright', version: '1.41.0'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.41.0-SNAPSHOT</version>
|
||||
<version>1.43.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>driver-bundle</artifactId>
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.concurrent.TimeUnit;
|
||||
public class DriverJar extends Driver {
|
||||
private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
|
||||
private static final String SELENIUM_REMOTE_URL = "SELENIUM_REMOTE_URL";
|
||||
static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
|
||||
private final Path driverTempDir;
|
||||
private Path preinstalledNodePath;
|
||||
|
||||
@@ -64,7 +63,7 @@ public class DriverJar extends Driver {
|
||||
env.put(PLAYWRIGHT_NODEJS_PATH, preinstalledNodePath.toString());
|
||||
}
|
||||
extractDriverToTempDir();
|
||||
logMessage("extracted driver from jar to " + driverPath());
|
||||
logMessage("extracted driver from jar to " + driverDir());
|
||||
if (installBrowsers)
|
||||
installBrowsers(env);
|
||||
}
|
||||
@@ -82,7 +81,7 @@ public class DriverJar extends Driver {
|
||||
logMessage("Skipping browsers download because `SELENIUM_REMOTE_URL` env variable is set");
|
||||
return;
|
||||
}
|
||||
Path driver = driverPath();
|
||||
Path driver = driverDir();
|
||||
if (!Files.exists(driver)) {
|
||||
throw new RuntimeException("Failed to find driver: " + driver);
|
||||
}
|
||||
@@ -204,7 +203,7 @@ public class DriverJar extends Driver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Path driverDir() {
|
||||
public Path driverDir() {
|
||||
return driverTempDir;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -32,7 +32,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.microsoft.playwright.impl.driver.jar.DriverJar.PLAYWRIGHT_NODEJS_PATH;
|
||||
import static com.microsoft.playwright.impl.driver.Driver.PLAYWRIGHT_NODEJS_PATH;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TestInstall {
|
||||
@Test
|
||||
void playwrightCliInstalled() throws Exception {
|
||||
Driver driver = Driver.createAndInstall(Collections.emptyMap(), false);
|
||||
assertTrue(Files.exists(driver.driverPath()));
|
||||
assertTrue(Files.exists(driver.driverDir()));
|
||||
|
||||
ProcessBuilder pb = driver.createProcessBuilder();
|
||||
pb.command().add("install");
|
||||
@@ -98,7 +98,7 @@ public class TestInstall {
|
||||
void playwrightDriverInAlternativeTmpdir(@TempDir Path tmpdir) throws Exception {
|
||||
System.setProperty("playwright.driver.tmpdir", tmpdir.toString());
|
||||
DriverJar driver = new DriverJar();
|
||||
assertTrue(driver.driverPath().startsWith(tmpdir), "Driver path: " + driver.driverPath() + " tmp: " + tmpdir);
|
||||
assertTrue(driver.driverDir().startsWith(tmpdir), "Driver path: " + driver.driverDir() + " tmp: " + tmpdir);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,7 +135,7 @@ public class TestInstall {
|
||||
private static String extractNodeJsToTemp() throws URISyntaxException, IOException {
|
||||
DriverJar auxDriver = new DriverJar();
|
||||
auxDriver.extractDriverToTempDir();
|
||||
String nodePath = auxDriver.driverPath().getParent().resolve(isWindows() ? "node.exe" : "node").toString();
|
||||
String nodePath = auxDriver.driverDir().resolve(isWindows() ? "node.exe" : "node").toString();
|
||||
return nodePath;
|
||||
}
|
||||
|
||||
@@ -145,9 +145,9 @@ public class TestInstall {
|
||||
}
|
||||
|
||||
private static void canSpecifyPreinstalledNodeJsShared(Driver driver, Path tmpDir) throws IOException, URISyntaxException, InterruptedException {
|
||||
Path builtinNode = driver.driverPath().getParent().resolve("node");
|
||||
Path builtinNode = driver.driverDir().resolve("node");
|
||||
assertFalse(Files.exists(builtinNode), builtinNode.toString());
|
||||
Path builtinNodeExe = driver.driverPath().getParent().resolve("node.exe");
|
||||
Path builtinNodeExe = driver.driverDir().resolve("node.exe");
|
||||
assertFalse(Files.exists(builtinNodeExe), builtinNodeExe.toString());
|
||||
|
||||
ProcessBuilder pb = driver.createProcessBuilder();
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.41.0-SNAPSHOT</version>
|
||||
<version>1.43.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>driver</artifactId>
|
||||
|
||||
@@ -31,6 +31,7 @@ import static com.microsoft.playwright.impl.driver.DriverLogging.logWithTimestam
|
||||
*/
|
||||
public abstract class Driver {
|
||||
protected final Map<String, String> env = new LinkedHashMap<>();
|
||||
public static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
|
||||
|
||||
private static Driver instance;
|
||||
|
||||
@@ -47,7 +48,7 @@ public abstract class Driver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Path driverDir() {
|
||||
public Path driverDir() {
|
||||
return driverDir;
|
||||
}
|
||||
}
|
||||
@@ -65,14 +66,14 @@ public abstract class Driver {
|
||||
}
|
||||
protected abstract void initialize(Boolean installBrowsers) throws Exception;
|
||||
|
||||
public Path driverPath() {
|
||||
String cliFileName = System.getProperty("os.name").toLowerCase().contains("windows") ?
|
||||
"playwright.cmd" : "playwright.sh";
|
||||
return driverDir().resolve(cliFileName);
|
||||
}
|
||||
|
||||
public ProcessBuilder createProcessBuilder() {
|
||||
ProcessBuilder pb = new ProcessBuilder(driverPath().toString());
|
||||
String nodePath = env.get("PLAYWRIGHT_NODEJS_PATH");
|
||||
if (nodePath == null) {
|
||||
String node = System.getProperty("os.name").toLowerCase().contains("windows") ? "node.exe" : "node";
|
||||
nodePath = driverDir().resolve(node).toAbsolutePath().toString();
|
||||
}
|
||||
ProcessBuilder pb = new ProcessBuilder(nodePath);
|
||||
pb.command().add(driverDir().resolve("package").resolve("cli.js").toAbsolutePath().toString());
|
||||
pb.environment().putAll(env);
|
||||
pb.environment().put("PW_LANG_NAME", "java");
|
||||
pb.environment().put("PW_LANG_NAME_VERSION", getMajorJavaVersion());
|
||||
@@ -118,7 +119,7 @@ public abstract class Driver {
|
||||
return (Driver) jarDriver.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
protected abstract Path driverDir();
|
||||
public abstract Path driverDir();
|
||||
|
||||
protected static void logMessage(String message) {
|
||||
// This matches log format produced by the server.
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>examples</artifactId>
|
||||
<version>1.41.0-SNAPSHOT</version>
|
||||
<version>1.43.0</version>
|
||||
<name>Playwright Client Examples</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -15,7 +15,7 @@
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.30.0</version>
|
||||
<version>1.41.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
@@ -23,7 +23,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<version>3.12.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>parent-pom</artifactId>
|
||||
<version>1.41.0-SNAPSHOT</version>
|
||||
<version>1.43.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>playwright</artifactId>
|
||||
|
||||
@@ -23,14 +23,14 @@ import java.util.*;
|
||||
/**
|
||||
* Exposes API that can be used for the Web API testing. This class is used for creating {@code APIRequestContext} instance
|
||||
* which in turn can be used for sending web requests. An instance of this class can be obtained via {@link
|
||||
* Playwright#request Playwright.request()}. For more information see {@code APIRequestContext}.
|
||||
* com.microsoft.playwright.Playwright#request Playwright.request()}. For more information see {@code APIRequestContext}.
|
||||
*/
|
||||
public interface APIRequest {
|
||||
class NewContextOptions {
|
||||
/**
|
||||
* Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Examples:
|
||||
* Methods like {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} take the base URL into
|
||||
* consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
|
||||
* constructor for building the corresponding URL. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code
|
||||
* http://localhost:3000/bar.html}</li>
|
||||
@@ -60,16 +60,17 @@ public interface APIRequest {
|
||||
public Proxy proxy;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
|
||||
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
|
||||
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()} or {@link
|
||||
* com.microsoft.playwright.APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file
|
||||
* with saved storage, or the value returned by one of {@link com.microsoft.playwright.BrowserContext#storageState
|
||||
* BrowserContext.storageState()} or {@link com.microsoft.playwright.APIRequestContext#storageState
|
||||
* APIRequestContext.storageState()} methods.
|
||||
*/
|
||||
public String storageState;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public Path storageStatePath;
|
||||
/**
|
||||
@@ -83,9 +84,9 @@ public interface APIRequest {
|
||||
public String userAgent;
|
||||
|
||||
/**
|
||||
* Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Examples:
|
||||
* Methods like {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} take the base URL into
|
||||
* consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
|
||||
* constructor for building the corresponding URL. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code
|
||||
* http://localhost:3000/bar.html}</li>
|
||||
@@ -143,9 +144,10 @@ public interface APIRequest {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
|
||||
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
|
||||
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()} or {@link
|
||||
* com.microsoft.playwright.APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file
|
||||
* with saved storage, or the value returned by one of {@link com.microsoft.playwright.BrowserContext#storageState
|
||||
* BrowserContext.storageState()} or {@link com.microsoft.playwright.APIRequestContext#storageState
|
||||
* APIRequestContext.storageState()} methods.
|
||||
*/
|
||||
public NewContextOptions setStorageState(String storageState) {
|
||||
@@ -154,8 +156,8 @@ public interface APIRequest {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public NewContextOptions setStorageStatePath(Path storageStatePath) {
|
||||
this.storageStatePath = storageStatePath;
|
||||
|
||||
@@ -24,21 +24,23 @@ import java.nio.file.Path;
|
||||
* environment or the service to your e2e test.
|
||||
*
|
||||
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage
|
||||
* with the browser context and can be accessed via {@link BrowserContext#request BrowserContext.request()} or {@link
|
||||
* Page#request Page.request()}. It is also possible to create a new APIRequestContext instance manually by calling {@link
|
||||
* APIRequest#newContext APIRequest.newContext()}.
|
||||
* with the browser context and can be accessed via {@link com.microsoft.playwright.BrowserContext#request
|
||||
* 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
|
||||
* APIRequest.newContext()}.
|
||||
*
|
||||
* <p> **Cookie management**
|
||||
* <p> <strong>Cookie management</strong>
|
||||
*
|
||||
* <p> {@code APIRequestContext} returned by {@link BrowserContext#request BrowserContext.request()} and {@link 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> {@code APIRequestContext} returned by {@link com.microsoft.playwright.BrowserContext#request BrowserContext.request()}
|
||||
* 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> If you want API requests to not interfere with the browser cookies you should create a new {@code APIRequestContext} by
|
||||
* calling {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own
|
||||
* isolated cookie storage.
|
||||
* calling {@link com.microsoft.playwright.APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext}
|
||||
* object will have its own isolated cookie storage.
|
||||
*/
|
||||
public interface APIRequestContext {
|
||||
class StorageStateOptions {
|
||||
@@ -79,9 +81,10 @@ public interface APIRequestContext {
|
||||
*/
|
||||
APIResponse delete(String url, RequestOptions params);
|
||||
/**
|
||||
* All responses returned by {@link APIRequestContext#get APIRequestContext.get()} and similar methods are stored in the
|
||||
* memory, so that you can later call {@link APIResponse#body APIResponse.body()}.This method discards all its resources,
|
||||
* calling any method on disposed {@code APIRequestContext} will throw an exception.
|
||||
* All responses returned by {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} and similar
|
||||
* methods are stored in the memory, so that you can later call {@link com.microsoft.playwright.APIResponse#body
|
||||
* APIResponse.body()}.This method discards all its resources, calling any method on disposed {@code APIRequestContext}
|
||||
* will throw an exception.
|
||||
*
|
||||
* @since v1.16
|
||||
*/
|
||||
@@ -91,7 +94,7 @@ public interface APIRequestContext {
|
||||
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
|
||||
* to the request.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Map<String, Object> data = new HashMap();
|
||||
* data.put("title", "Book Title");
|
||||
@@ -127,7 +130,7 @@ public interface APIRequestContext {
|
||||
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
|
||||
* to the request.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Map<String, Object> data = new HashMap();
|
||||
* data.put("title", "Book Title");
|
||||
@@ -162,7 +165,7 @@ public interface APIRequestContext {
|
||||
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
|
||||
* to the request.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Map<String, Object> data = new HashMap();
|
||||
* data.put("title", "Book Title");
|
||||
@@ -198,7 +201,7 @@ public interface APIRequestContext {
|
||||
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
|
||||
* to the request.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Map<String, Object> data = new HashMap();
|
||||
* data.put("title", "Book Title");
|
||||
@@ -233,7 +236,7 @@ public interface APIRequestContext {
|
||||
* response. The method will populate request cookies from the context and update context cookies from the response. The
|
||||
* method will automatically follow redirects.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
|
||||
* <pre>{@code
|
||||
@@ -253,7 +256,7 @@ public interface APIRequestContext {
|
||||
* response. The method will populate request cookies from the context and update context cookies from the response. The
|
||||
* method will automatically follow redirects.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
|
||||
* <pre>{@code
|
||||
@@ -314,7 +317,7 @@ public interface APIRequestContext {
|
||||
* response. The method will populate request cookies from the context and update context cookies from the response. The
|
||||
* method will automatically follow redirects.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> JSON objects can be passed directly to the request:
|
||||
* <pre>{@code
|
||||
@@ -361,7 +364,7 @@ public interface APIRequestContext {
|
||||
* response. The method will populate request cookies from the context and update context cookies from the response. The
|
||||
* method will automatically follow redirects.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> JSON objects can be passed directly to the request:
|
||||
* <pre>{@code
|
||||
|
||||
@@ -20,8 +20,8 @@ import com.microsoft.playwright.options.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* {@code APIResponse} class represents responses returned by {@link APIRequestContext#get APIRequestContext.get()} and
|
||||
* similar methods.
|
||||
* {@code APIResponse} class represents responses returned by {@link com.microsoft.playwright.APIRequestContext#get
|
||||
* APIRequestContext.get()} and similar methods.
|
||||
*/
|
||||
public interface APIResponse {
|
||||
/**
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A Browser is created via {@link BrowserType#launch BrowserType.launch()}. An example of using a {@code Browser} to
|
||||
* create a {@code Page}:
|
||||
* A Browser is created via {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. An example of using a
|
||||
* {@code Browser} to create a {@code Page}:
|
||||
* <pre>{@code
|
||||
* import com.microsoft.playwright.*;
|
||||
*
|
||||
@@ -47,7 +47,7 @@ public interface Browser extends AutoCloseable {
|
||||
* Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
|
||||
* <ul>
|
||||
* <li> Browser application is closed or crashed.</li>
|
||||
* <li> The {@link Browser#close Browser.close()} method was called.</li>
|
||||
* <li> The {@link com.microsoft.playwright.Browser#close Browser.close()} method was called.</li>
|
||||
* </ul>
|
||||
*/
|
||||
void onDisconnected(Consumer<Browser> handler);
|
||||
@@ -76,10 +76,11 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean acceptDownloads;
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -97,8 +98,8 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean bypassCSP;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public Optional<ColorScheme> colorScheme;
|
||||
/**
|
||||
@@ -112,8 +113,8 @@ public interface Browser extends AutoCloseable {
|
||||
public Map<String, String> extraHTTPHeaders;
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public Optional<ForcedColors> forcedColors;
|
||||
public Geolocation geolocation;
|
||||
@@ -155,8 +156,9 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean offline;
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public List<String> permissions;
|
||||
/**
|
||||
@@ -185,14 +187,14 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
public Object recordHarUrlFilter;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
@@ -203,8 +205,8 @@ public interface Browser extends AutoCloseable {
|
||||
public RecordVideoSize recordVideoSize;
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public Optional<ReducedMotion> reducedMotion;
|
||||
/**
|
||||
@@ -223,13 +225,13 @@ public interface Browser extends AutoCloseable {
|
||||
public ServiceWorkerPolicy serviceWorkers;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
|
||||
*/
|
||||
public String storageState;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public Path storageStatePath;
|
||||
/**
|
||||
@@ -267,10 +269,11 @@ public interface Browser extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -294,8 +297,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public NewContextOptions setColorScheme(ColorScheme colorScheme) {
|
||||
this.colorScheme = Optional.ofNullable(colorScheme);
|
||||
@@ -318,8 +321,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public NewContextOptions setForcedColors(ForcedColors forcedColors) {
|
||||
this.forcedColors = Optional.ofNullable(forcedColors);
|
||||
@@ -398,8 +401,9 @@ public interface Browser extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public NewContextOptions setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
@@ -453,8 +457,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public NewContextOptions setRecordHarPath(Path recordHarPath) {
|
||||
this.recordHarPath = recordHarPath;
|
||||
@@ -470,7 +474,7 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public NewContextOptions setRecordVideoDir(Path recordVideoDir) {
|
||||
this.recordVideoDir = recordVideoDir;
|
||||
@@ -495,8 +499,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public NewContextOptions setReducedMotion(ReducedMotion reducedMotion) {
|
||||
this.reducedMotion = Optional.ofNullable(reducedMotion);
|
||||
@@ -531,7 +535,7 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
|
||||
*/
|
||||
public NewContextOptions setStorageState(String storageState) {
|
||||
this.storageState = storageState;
|
||||
@@ -539,8 +543,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public NewContextOptions setStorageStatePath(Path storageStatePath) {
|
||||
this.storageStatePath = storageStatePath;
|
||||
@@ -602,10 +606,11 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean acceptDownloads;
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -623,8 +628,8 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean bypassCSP;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public Optional<ColorScheme> colorScheme;
|
||||
/**
|
||||
@@ -638,8 +643,8 @@ public interface Browser extends AutoCloseable {
|
||||
public Map<String, String> extraHTTPHeaders;
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public Optional<ForcedColors> forcedColors;
|
||||
public Geolocation geolocation;
|
||||
@@ -681,8 +686,9 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
public Boolean offline;
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public List<String> permissions;
|
||||
/**
|
||||
@@ -711,14 +717,14 @@ public interface Browser extends AutoCloseable {
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
public Object recordHarUrlFilter;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
@@ -729,8 +735,8 @@ public interface Browser extends AutoCloseable {
|
||||
public RecordVideoSize recordVideoSize;
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public Optional<ReducedMotion> reducedMotion;
|
||||
/**
|
||||
@@ -749,13 +755,13 @@ public interface Browser extends AutoCloseable {
|
||||
public ServiceWorkerPolicy serviceWorkers;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
|
||||
*/
|
||||
public String storageState;
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public Path storageStatePath;
|
||||
/**
|
||||
@@ -793,10 +799,11 @@ public interface Browser extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -820,8 +827,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public NewPageOptions setColorScheme(ColorScheme colorScheme) {
|
||||
this.colorScheme = Optional.ofNullable(colorScheme);
|
||||
@@ -844,8 +851,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public NewPageOptions setForcedColors(ForcedColors forcedColors) {
|
||||
this.forcedColors = Optional.ofNullable(forcedColors);
|
||||
@@ -924,8 +931,9 @@ public interface Browser extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public NewPageOptions setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
@@ -979,8 +987,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public NewPageOptions setRecordHarPath(Path recordHarPath) {
|
||||
this.recordHarPath = recordHarPath;
|
||||
@@ -996,7 +1004,7 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public NewPageOptions setRecordVideoDir(Path recordVideoDir) {
|
||||
this.recordVideoDir = recordVideoDir;
|
||||
@@ -1021,8 +1029,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public NewPageOptions setReducedMotion(ReducedMotion reducedMotion) {
|
||||
this.reducedMotion = Optional.ofNullable(reducedMotion);
|
||||
@@ -1057,7 +1065,7 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
|
||||
*/
|
||||
public NewPageOptions setStorageState(String storageState) {
|
||||
this.storageState = storageState;
|
||||
@@ -1065,8 +1073,8 @@ public interface Browser extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Populates context with given storage state. This option can be used to initialize context with logged-in information
|
||||
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
|
||||
* state.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
|
||||
* file with saved storage state.
|
||||
*/
|
||||
public NewPageOptions setStorageStatePath(Path storageStatePath) {
|
||||
this.storageStatePath = storageStatePath;
|
||||
@@ -1165,15 +1173,16 @@ public interface Browser extends AutoCloseable {
|
||||
*/
|
||||
BrowserType browserType();
|
||||
/**
|
||||
* In case this browser is obtained using {@link BrowserType#launch BrowserType.launch()}, closes the browser and all of
|
||||
* its pages (if any were opened).
|
||||
* In case this browser is obtained using {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}, closes
|
||||
* the browser and all of its pages (if any were opened).
|
||||
*
|
||||
* <p> In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
||||
* browser server.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link BrowserContext#close
|
||||
* BrowserContext.close()} on any {@code BrowserContext}'s you explicitly created earlier with {@link Browser#newContext
|
||||
* Browser.newContext()} **before** calling {@link Browser#close Browser.close()}.
|
||||
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} on any {@code BrowserContext}'s you explicitly
|
||||
* created earlier with {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} **before** calling {@link
|
||||
* com.microsoft.playwright.Browser#close Browser.close()}.
|
||||
*
|
||||
* <p> The {@code Browser} object itself is considered to be disposed and cannot be used anymore.
|
||||
*
|
||||
@@ -1183,15 +1192,16 @@ public interface Browser extends AutoCloseable {
|
||||
close(null);
|
||||
}
|
||||
/**
|
||||
* In case this browser is obtained using {@link BrowserType#launch BrowserType.launch()}, closes the browser and all of
|
||||
* its pages (if any were opened).
|
||||
* In case this browser is obtained using {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}, closes
|
||||
* the browser and all of its pages (if any were opened).
|
||||
*
|
||||
* <p> In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
|
||||
* browser server.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link BrowserContext#close
|
||||
* BrowserContext.close()} on any {@code BrowserContext}'s you explicitly created earlier with {@link Browser#newContext
|
||||
* Browser.newContext()} **before** calling {@link Browser#close Browser.close()}.
|
||||
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} on any {@code BrowserContext}'s you explicitly
|
||||
* created earlier with {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} **before** calling {@link
|
||||
* com.microsoft.playwright.Browser#close Browser.close()}.
|
||||
*
|
||||
* <p> The {@code Browser} object itself is considered to be disposed and cannot be used anymore.
|
||||
*
|
||||
@@ -1201,7 +1211,7 @@ public interface Browser extends AutoCloseable {
|
||||
/**
|
||||
* Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Browser browser = pw.webkit().launch();
|
||||
* System.out.println(browser.contexts().size()); // prints "0"
|
||||
@@ -1230,11 +1240,11 @@ public interface Browser extends AutoCloseable {
|
||||
* Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> If directly using this method to create {@code BrowserContext}s, it is best practice to explicitly close the returned
|
||||
* context via {@link BrowserContext#close BrowserContext.close()} when your code is done with the {@code BrowserContext},
|
||||
* and before calling {@link Browser#close Browser.close()}. This will ensure the {@code context} is closed gracefully and
|
||||
* any artifacts—like HARs and videos—are fully flushed and saved.
|
||||
* context via {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} when your code is done with the
|
||||
* {@code BrowserContext}, and before calling {@link com.microsoft.playwright.Browser#close Browser.close()}. This will
|
||||
* ensure the {@code context} is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
|
||||
* // Create a new incognito browser context.
|
||||
@@ -1257,11 +1267,11 @@ public interface Browser extends AutoCloseable {
|
||||
* Creates a new browser context. It won't share cookies/cache with other browser contexts.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> If directly using this method to create {@code BrowserContext}s, it is best practice to explicitly close the returned
|
||||
* context via {@link BrowserContext#close BrowserContext.close()} when your code is done with the {@code BrowserContext},
|
||||
* and before calling {@link Browser#close Browser.close()}. This will ensure the {@code context} is closed gracefully and
|
||||
* any artifacts—like HARs and videos—are fully flushed and saved.
|
||||
* context via {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} when your code is done with the
|
||||
* {@code BrowserContext}, and before calling {@link com.microsoft.playwright.Browser#close Browser.close()}. This will
|
||||
* ensure the {@code context} is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
|
||||
* // Create a new incognito browser context.
|
||||
@@ -1282,8 +1292,9 @@ public interface Browser extends AutoCloseable {
|
||||
* Creates a new page in a new browser context. Closing this page will close the context as well.
|
||||
*
|
||||
* <p> This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
|
||||
* testing frameworks should explicitly create {@link Browser#newContext Browser.newContext()} followed by the {@link
|
||||
* BrowserContext#newPage BrowserContext.newPage()} to control their exact life times.
|
||||
* testing frameworks should explicitly create {@link com.microsoft.playwright.Browser#newContext Browser.newContext()}
|
||||
* followed by the {@link com.microsoft.playwright.BrowserContext#newPage BrowserContext.newPage()} to control their exact
|
||||
* life times.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -1294,8 +1305,9 @@ public interface Browser extends AutoCloseable {
|
||||
* Creates a new page in a new browser context. Closing this page will close the context as well.
|
||||
*
|
||||
* <p> This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
|
||||
* testing frameworks should explicitly create {@link Browser#newContext Browser.newContext()} followed by the {@link
|
||||
* BrowserContext#newPage BrowserContext.newPage()} to control their exact life times.
|
||||
* testing frameworks should explicitly create {@link com.microsoft.playwright.Browser#newContext Browser.newContext()}
|
||||
* followed by the {@link com.microsoft.playwright.BrowserContext#newPage BrowserContext.newPage()} to control their exact
|
||||
* life times.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -1306,10 +1318,11 @@ public interface Browser extends AutoCloseable {
|
||||
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
|
||||
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
|
||||
*
|
||||
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
|
||||
* create a trace file that can be opened in Chrome DevTools performance panel.
|
||||
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
|
||||
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
|
||||
* DevTools performance panel.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* browser.startTracing(page, new Browser.StartTracingOptions()
|
||||
* .setPath(Paths.get("trace.json")));
|
||||
@@ -1329,10 +1342,11 @@ public interface Browser extends AutoCloseable {
|
||||
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
|
||||
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
|
||||
*
|
||||
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
|
||||
* create a trace file that can be opened in Chrome DevTools performance panel.
|
||||
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
|
||||
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
|
||||
* DevTools performance panel.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* browser.startTracing(page, new Browser.StartTracingOptions()
|
||||
* .setPath(Paths.get("trace.json")));
|
||||
@@ -1351,10 +1365,11 @@ public interface Browser extends AutoCloseable {
|
||||
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
|
||||
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
|
||||
*
|
||||
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
|
||||
* create a trace file that can be opened in Chrome DevTools performance panel.
|
||||
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
|
||||
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
|
||||
* DevTools performance panel.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* browser.startTracing(page, new Browser.StartTracingOptions()
|
||||
* .setPath(Paths.get("trace.json")));
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.util.regex.Pattern;
|
||||
* <p> If a page opens another page, e.g. with a {@code window.open} call, the popup will belong to the parent page's browser
|
||||
* context.
|
||||
*
|
||||
* <p> Playwright allows creating "incognito" browser contexts with {@link Browser#newContext Browser.newContext()} method.
|
||||
* "Incognito" browser contexts don't write any browsing data to disk.
|
||||
* <p> Playwright allows creating "incognito" browser contexts with {@link com.microsoft.playwright.Browser#newContext
|
||||
* Browser.newContext()} method. "Incognito" browser contexts don't write any browsing data to disk.
|
||||
* <pre>{@code
|
||||
* // Create a new incognito browser context
|
||||
* BrowserContext context = browser.newContext();
|
||||
@@ -49,7 +49,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* <ul>
|
||||
* <li> Browser context is closed.</li>
|
||||
* <li> Browser application is closed or crashed.</li>
|
||||
* <li> The {@link Browser#close Browser.close()} method was called.</li>
|
||||
* <li> The {@link com.microsoft.playwright.Browser#close Browser.close()} method was called.</li>
|
||||
* </ul>
|
||||
*/
|
||||
void onClose(Consumer<BrowserContext> handler);
|
||||
@@ -60,12 +60,12 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Emitted when JavaScript within the page calls one of console API methods, e.g. {@code console.log} or {@code
|
||||
* console.dir}. Also emitted if the page throws an error or a warning.
|
||||
* console.dir}.
|
||||
*
|
||||
* <p> The arguments passed into {@code console.log} and the page are available on the {@code ConsoleMessage} event handler
|
||||
* argument.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.onConsoleMessage(msg -> {
|
||||
* for (int i = 0; i < msg.args().size(); ++i)
|
||||
@@ -82,20 +82,21 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Emitted when a JavaScript dialog appears, such as {@code alert}, {@code prompt}, {@code confirm} or {@code
|
||||
* beforeunload}. Listener **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss Dialog.dismiss()}
|
||||
* the dialog - otherwise the page will <a
|
||||
* beforeunload}. Listener **must** either {@link com.microsoft.playwright.Dialog#accept Dialog.accept()} or {@link
|
||||
* com.microsoft.playwright.Dialog#dismiss Dialog.dismiss()} the dialog - otherwise the page will <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
|
||||
* dialog, and actions like click will never finish.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.onDialog(dialog -> {
|
||||
* dialog.accept();
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> When no {@link Page#onDialog Page.onDialog()} or {@link BrowserContext#onDialog BrowserContext.onDialog()} listeners are
|
||||
* present, all dialogs are automatically dismissed.
|
||||
* <p> <strong>NOTE:</strong> When no {@link com.microsoft.playwright.Page#onDialog Page.onDialog()} or {@link
|
||||
* com.microsoft.playwright.BrowserContext#onDialog BrowserContext.onDialog()} listeners are present, all dialogs are
|
||||
* automatically dismissed.
|
||||
*/
|
||||
void onDialog(Consumer<Dialog> handler);
|
||||
/**
|
||||
@@ -105,8 +106,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* 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 Page#onPopup Page.onPopup()} to receive events about popups relevant to a
|
||||
* specific page.
|
||||
* also fire for popup pages. See also {@link com.microsoft.playwright.Page#onPopup Page.onPopup()} to receive events about
|
||||
* popups relevant to a specific page.
|
||||
*
|
||||
* <p> The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||
* popup with {@code window.open('http://example.com')}, this event will fire when the network request to
|
||||
@@ -118,8 +119,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* System.out.println(newPage.evaluate("location.href"));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Use {@link Page#waitForLoadState Page.waitForLoadState()} to wait until the page gets to a particular state (you should
|
||||
* not need it in most cases).
|
||||
* <p> <strong>NOTE:</strong> Use {@link com.microsoft.playwright.Page#waitForLoadState Page.waitForLoadState()} to wait until the page gets to a
|
||||
* particular state (you should not need it in most cases).
|
||||
*/
|
||||
void onPage(Consumer<Page> handler);
|
||||
/**
|
||||
@@ -129,7 +130,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular page,
|
||||
* use {@link Page#onPageError Page.onPageError()} instead.
|
||||
* use {@link com.microsoft.playwright.Page#onPageError Page.onPageError()} instead.
|
||||
*/
|
||||
void onWebError(Consumer<WebError> handler);
|
||||
/**
|
||||
@@ -139,10 +140,10 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To only
|
||||
* listen for requests from a particular page, use {@link Page#onRequest Page.onRequest()}.
|
||||
* listen for requests from a particular page, use {@link com.microsoft.playwright.Page#onRequest Page.onRequest()}.
|
||||
*
|
||||
* <p> In order to intercept and mutate requests, see {@link BrowserContext#route BrowserContext.route()} or {@link Page#route
|
||||
* Page.route()}.
|
||||
* <p> In order to intercept and mutate requests, see {@link com.microsoft.playwright.BrowserContext#route
|
||||
* BrowserContext.route()} or {@link com.microsoft.playwright.Page#route Page.route()}.
|
||||
*/
|
||||
void onRequest(Consumer<Request> handler);
|
||||
/**
|
||||
@@ -152,11 +153,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* Emitted when a request fails, for example by timing out. To only listen for failed requests from a particular page, use
|
||||
* {@link Page#onRequestFailed Page.onRequestFailed()}.
|
||||
* {@link com.microsoft.playwright.Page#onRequestFailed Page.onRequestFailed()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
|
||||
* with {@link BrowserContext#onRequestFinished BrowserContext.onRequestFinished()} event and not with {@link
|
||||
* BrowserContext#onRequestFailed BrowserContext.onRequestFailed()}.
|
||||
* with {@link com.microsoft.playwright.BrowserContext#onRequestFinished BrowserContext.onRequestFinished()} event and not
|
||||
* with {@link com.microsoft.playwright.BrowserContext#onRequestFailed BrowserContext.onRequestFailed()}.
|
||||
*/
|
||||
void onRequestFailed(Consumer<Request> handler);
|
||||
/**
|
||||
@@ -167,7 +168,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
/**
|
||||
* Emitted when a request finishes successfully after downloading the response body. For a successful response, the
|
||||
* sequence of events is {@code request}, {@code response} and {@code requestfinished}. To listen for successful requests
|
||||
* from a particular page, use {@link Page#onRequestFinished Page.onRequestFinished()}.
|
||||
* from a particular page, use {@link com.microsoft.playwright.Page#onRequestFinished Page.onRequestFinished()}.
|
||||
*/
|
||||
void onRequestFinished(Consumer<Request> handler);
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
/**
|
||||
* Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
|
||||
* is {@code request}, {@code response} and {@code requestfinished}. To listen for response events from a particular page,
|
||||
* use {@link Page#onResponse Page.onResponse()}.
|
||||
* use {@link com.microsoft.playwright.Page#onResponse Page.onResponse()}.
|
||||
*/
|
||||
void onResponse(Consumer<Response> handler);
|
||||
/**
|
||||
@@ -186,6 +187,63 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*/
|
||||
void offResponse(Consumer<Response> handler);
|
||||
|
||||
class ClearCookiesOptions {
|
||||
/**
|
||||
* Only removes cookies with the given domain.
|
||||
*/
|
||||
public Object domain;
|
||||
/**
|
||||
* Only removes cookies with the given name.
|
||||
*/
|
||||
public Object name;
|
||||
/**
|
||||
* Only removes cookies with the given path.
|
||||
*/
|
||||
public Object path;
|
||||
|
||||
/**
|
||||
* Only removes cookies with the given domain.
|
||||
*/
|
||||
public ClearCookiesOptions setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Only removes cookies with the given domain.
|
||||
*/
|
||||
public ClearCookiesOptions setDomain(Pattern domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Only removes cookies with the given name.
|
||||
*/
|
||||
public ClearCookiesOptions setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Only removes cookies with the given name.
|
||||
*/
|
||||
public ClearCookiesOptions setName(Pattern name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Only removes cookies with the given path.
|
||||
*/
|
||||
public ClearCookiesOptions setPath(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Only removes cookies with the given path.
|
||||
*/
|
||||
public ClearCookiesOptions setPath(Pattern path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class CloseOptions {
|
||||
/**
|
||||
* The reason to be reported to the operations interrupted by the context closure.
|
||||
@@ -256,7 +314,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
public HarNotFound notFound;
|
||||
/**
|
||||
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
|
||||
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
|
||||
* written to disk when {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} is called.
|
||||
*/
|
||||
public Boolean update;
|
||||
/**
|
||||
@@ -290,7 +348,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
|
||||
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
|
||||
* written to disk when {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} is called.
|
||||
*/
|
||||
public RouteFromHAROptions setUpdate(boolean update) {
|
||||
this.update = update;
|
||||
@@ -349,15 +407,17 @@ public interface BrowserContext extends AutoCloseable {
|
||||
class WaitForConditionOptions {
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or
|
||||
* {@link Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or
|
||||
* {@link Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 WaitForConditionOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -371,7 +431,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
public Predicate<ConsoleMessage> predicate;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
@@ -384,7 +445,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public WaitForConsoleMessageOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -398,7 +460,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
public Predicate<Page> predicate;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
@@ -411,7 +474,8 @@ public interface BrowserContext extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public WaitForPageOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -420,9 +484,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
}
|
||||
/**
|
||||
* Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
|
||||
* obtained via {@link BrowserContext#cookies BrowserContext.cookies()}.
|
||||
* obtained via {@link com.microsoft.playwright.BrowserContext#cookies BrowserContext.cookies()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
|
||||
* }</pre>
|
||||
@@ -444,7 +508,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* <p> The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
|
||||
* the JavaScript environment, e.g. to seed {@code Math.random}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of overriding {@code Math.random} before the page loads:
|
||||
* <pre>{@code
|
||||
@@ -452,8 +516,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* browserContext.addInitScript(Paths.get("preload.js"));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link BrowserContext#addInitScript
|
||||
* BrowserContext.addInitScript()} and {@link Page#addInitScript Page.addInitScript()} is not defined.
|
||||
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link com.microsoft.playwright.BrowserContext#addInitScript
|
||||
* BrowserContext.addInitScript()} and {@link com.microsoft.playwright.Page#addInitScript Page.addInitScript()} is not
|
||||
* defined.
|
||||
*
|
||||
* @param script Script to be evaluated in all pages in the browser context.
|
||||
* @since v1.8
|
||||
@@ -470,7 +535,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* <p> The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
|
||||
* the JavaScript environment, e.g. to seed {@code Math.random}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of overriding {@code Math.random} before the page loads:
|
||||
* <pre>{@code
|
||||
@@ -478,8 +543,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* browserContext.addInitScript(Paths.get("preload.js"));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link BrowserContext#addInitScript
|
||||
* BrowserContext.addInitScript()} and {@link Page#addInitScript Page.addInitScript()} is not defined.
|
||||
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link com.microsoft.playwright.BrowserContext#addInitScript
|
||||
* BrowserContext.addInitScript()} and {@link com.microsoft.playwright.Page#addInitScript Page.addInitScript()} is not
|
||||
* defined.
|
||||
*
|
||||
* @param script Script to be evaluated in all pages in the browser context.
|
||||
* @since v1.8
|
||||
@@ -492,15 +558,45 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*/
|
||||
Browser browser();
|
||||
/**
|
||||
* Clears context cookies.
|
||||
* Removes cookies from context. Accepts optional filter.
|
||||
*
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.clearCookies();
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("session-id"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain("my-origin.com"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setPath("/api/v1"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions()
|
||||
* .setName("session-id")
|
||||
* .setDomain("my-origin.com"));
|
||||
* }</pre>
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
void clearCookies();
|
||||
default void clearCookies() {
|
||||
clearCookies(null);
|
||||
}
|
||||
/**
|
||||
* Removes cookies from context. Accepts optional filter.
|
||||
*
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.clearCookies();
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("session-id"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain("my-origin.com"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setPath("/api/v1"));
|
||||
* context.clearCookies(new BrowserContext.ClearCookiesOptions()
|
||||
* .setName("session-id")
|
||||
* .setDomain("my-origin.com"));
|
||||
* }</pre>
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
void clearCookies(ClearCookiesOptions options);
|
||||
/**
|
||||
* Clears all permission overrides for the browser context.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* BrowserContext context = browser.newContext();
|
||||
* context.grantPermissions(Arrays.asList("clipboard-read"));
|
||||
@@ -565,9 +661,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
|
||||
* BrowserContext, page: Page, frame: Frame }}.
|
||||
*
|
||||
* <p> See {@link Page#exposeBinding Page.exposeBinding()} for page-only version.
|
||||
* <p> See {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} for page-only version.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of exposing page URL to all frames in all pages in the context:
|
||||
* <pre>{@code
|
||||
@@ -627,9 +723,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
|
||||
* BrowserContext, page: Page, frame: Frame }}.
|
||||
*
|
||||
* <p> See {@link Page#exposeBinding Page.exposeBinding()} for page-only version.
|
||||
* <p> See {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} for page-only version.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of exposing page URL to all frames in all pages in the context:
|
||||
* <pre>{@code
|
||||
@@ -686,9 +782,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, it will be
|
||||
* awaited.
|
||||
*
|
||||
* <p> See {@link Page#exposeFunction Page.exposeFunction()} for page-only version.
|
||||
* <p> See {@link com.microsoft.playwright.Page#exposeFunction Page.exposeFunction()} for page-only version.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of adding a {@code sha256} function to all pages in the context:
|
||||
* <pre>{@code
|
||||
@@ -828,11 +924,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -863,10 +959,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -883,11 +980,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -918,10 +1015,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -936,11 +1034,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -971,10 +1069,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -991,11 +1090,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -1026,10 +1125,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -1044,11 +1144,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -1079,10 +1179,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -1099,11 +1200,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* 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.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
|
||||
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
|
||||
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
|
||||
* Service Worker. See <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling
|
||||
* Service Workers when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of a naive handler that aborts all image requests:
|
||||
* <pre>{@code
|
||||
@@ -1134,10 +1235,11 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
|
||||
* matches both handlers.
|
||||
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
|
||||
* routes when request matches both handlers.
|
||||
*
|
||||
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
|
||||
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
|
||||
* BrowserContext.unroute()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
@@ -1179,17 +1281,17 @@ public interface BrowserContext extends AutoCloseable {
|
||||
/**
|
||||
* This setting will change the default maximum navigation time for the following methods and related shortcuts:
|
||||
* <ul>
|
||||
* <li> {@link Page#goBack Page.goBack()}</li>
|
||||
* <li> {@link Page#goForward Page.goForward()}</li>
|
||||
* <li> {@link Page#navigate Page.navigate()}</li>
|
||||
* <li> {@link Page#reload Page.reload()}</li>
|
||||
* <li> {@link Page#setContent Page.setContent()}</li>
|
||||
* <li> {@link Page#waitForNavigation Page.waitForNavigation()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#goBack Page.goBack()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#goForward Page.goForward()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#navigate Page.navigate()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#reload Page.reload()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#setContent Page.setContent()}</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#waitForNavigation Page.waitForNavigation()}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()} and {@link Page#setDefaultTimeout
|
||||
* Page.setDefaultTimeout()} take priority over {@link BrowserContext#setDefaultNavigationTimeout
|
||||
* BrowserContext.setDefaultNavigationTimeout()}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()} and {@link
|
||||
* com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()} take priority over {@link
|
||||
* com.microsoft.playwright.BrowserContext#setDefaultNavigationTimeout BrowserContext.setDefaultNavigationTimeout()}.
|
||||
*
|
||||
* @param timeout Maximum navigation time in milliseconds
|
||||
* @since v1.8
|
||||
@@ -1198,10 +1300,10 @@ public interface BrowserContext extends AutoCloseable {
|
||||
/**
|
||||
* This setting will change the default maximum time for all the methods accepting {@code timeout} option.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()}, {@link Page#setDefaultTimeout
|
||||
* Page.setDefaultTimeout()} and {@link BrowserContext#setDefaultNavigationTimeout
|
||||
* BrowserContext.setDefaultNavigationTimeout()} take priority over {@link BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()}, {@link
|
||||
* com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()} and {@link
|
||||
* com.microsoft.playwright.BrowserContext#setDefaultNavigationTimeout BrowserContext.setDefaultNavigationTimeout()} take
|
||||
* priority over {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
*
|
||||
* @param timeout Maximum time in milliseconds
|
||||
* @since v1.8
|
||||
@@ -1209,11 +1311,12 @@ public interface BrowserContext extends AutoCloseable {
|
||||
void setDefaultTimeout(double timeout);
|
||||
/**
|
||||
* The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
|
||||
* with page-specific extra HTTP headers set with {@link Page#setExtraHTTPHeaders Page.setExtraHTTPHeaders()}. If page
|
||||
* overrides a particular header, page-specific header value will be used instead of the browser context header value.
|
||||
* with page-specific extra HTTP headers set with {@link com.microsoft.playwright.Page#setExtraHTTPHeaders
|
||||
* Page.setExtraHTTPHeaders()}. If page overrides a particular header, page-specific header value will be used instead of
|
||||
* the browser context header value.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link BrowserContext#setExtraHTTPHeaders BrowserContext.setExtraHTTPHeaders()} does not guarantee the order of headers
|
||||
* in the outgoing requests.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#setExtraHTTPHeaders BrowserContext.setExtraHTTPHeaders()} does not
|
||||
* guarantee the order of headers in the outgoing requests.
|
||||
*
|
||||
* @param headers An object containing additional HTTP headers to be sent with every request. All header values must be strings.
|
||||
* @since v1.8
|
||||
@@ -1222,13 +1325,13 @@ public interface BrowserContext extends AutoCloseable {
|
||||
/**
|
||||
* Sets the context's geolocation. Passing {@code null} or {@code undefined} emulates position unavailable.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* browserContext.setGeolocation(new Geolocation(59.95, 30.31667));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Consider using {@link BrowserContext#grantPermissions BrowserContext.grantPermissions()} to grant permissions for the
|
||||
* browser context pages to read its geolocation.
|
||||
* <p> <strong>NOTE:</strong> Consider using {@link com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} to
|
||||
* grant permissions for the browser context pages to read its geolocation.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -1261,72 +1364,75 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*/
|
||||
Tracing tracing();
|
||||
/**
|
||||
* Removes all routes created with {@link BrowserContext#route BrowserContext.route()} and {@link
|
||||
* BrowserContext#routeFromHAR BrowserContext.routeFromHAR()}.
|
||||
* Removes all routes created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} and {@link
|
||||
* com.microsoft.playwright.BrowserContext#routeFromHAR BrowserContext.routeFromHAR()}.
|
||||
*
|
||||
* @since v1.41
|
||||
*/
|
||||
void unrouteAll();
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @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()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
default void unroute(String url) {
|
||||
unroute(url, null);
|
||||
}
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* @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()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
void unroute(String url, Consumer<Route> handler);
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @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()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
default void unroute(Pattern url) {
|
||||
unroute(url, null);
|
||||
}
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* @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()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
void unroute(Pattern url, Consumer<Route> handler);
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @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()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
default void unroute(Predicate<String> url) {
|
||||
unroute(url, null);
|
||||
}
|
||||
/**
|
||||
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
|
||||
* removes all routes for the {@code url}.
|
||||
* 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}.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
|
||||
* @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()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
|
||||
* BrowserContext.route()}.
|
||||
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
|
||||
* @since v1.8
|
||||
*/
|
||||
void unroute(Predicate<String> url, Consumer<Route> handler);
|
||||
@@ -1334,7 +1440,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* The method will block until the condition returns true. All Playwright events will be dispatched while the method is
|
||||
* waiting for the condition.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Use the method to wait for a condition that depends on page events:
|
||||
* <pre>{@code
|
||||
@@ -1359,7 +1465,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* The method will block until the condition returns true. All Playwright events will be dispatched while the method is
|
||||
* waiting for the condition.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Use the method to wait for a condition that depends on page events:
|
||||
* <pre>{@code
|
||||
@@ -1382,7 +1488,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
|
||||
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
|
||||
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
|
||||
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
|
||||
* com.microsoft.playwright.BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
|
||||
*
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
* @since v1.34
|
||||
@@ -1394,7 +1500,7 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
|
||||
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
|
||||
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
|
||||
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
|
||||
* com.microsoft.playwright.BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
|
||||
*
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
* @since v1.34
|
||||
|
||||
@@ -182,8 +182,7 @@ public interface BrowserType {
|
||||
*/
|
||||
public Boolean chromiumSandbox;
|
||||
/**
|
||||
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
|
||||
* headless} option will be set {@code false}.
|
||||
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
|
||||
*/
|
||||
public Boolean devtools;
|
||||
/**
|
||||
@@ -291,8 +290,7 @@ public interface BrowserType {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
|
||||
* headless} option will be set {@code false}.
|
||||
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
|
||||
*/
|
||||
public LaunchOptions setDevtools(boolean devtools) {
|
||||
this.devtools = devtools;
|
||||
@@ -427,10 +425,11 @@ public interface BrowserType {
|
||||
*/
|
||||
public List<String> args;
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -458,8 +457,8 @@ public interface BrowserType {
|
||||
public Boolean chromiumSandbox;
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public Optional<ColorScheme> colorScheme;
|
||||
/**
|
||||
@@ -468,8 +467,7 @@ public interface BrowserType {
|
||||
*/
|
||||
public Double deviceScaleFactor;
|
||||
/**
|
||||
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
|
||||
* headless} option will be set {@code false}.
|
||||
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
|
||||
*/
|
||||
public Boolean devtools;
|
||||
/**
|
||||
@@ -499,8 +497,8 @@ public interface BrowserType {
|
||||
public Map<String, Object> firefoxUserPrefs;
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public Optional<ForcedColors> forcedColors;
|
||||
public Geolocation geolocation;
|
||||
@@ -571,8 +569,9 @@ public interface BrowserType {
|
||||
*/
|
||||
public Boolean offline;
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public List<String> permissions;
|
||||
/**
|
||||
@@ -597,14 +596,14 @@ public interface BrowserType {
|
||||
public Boolean recordHarOmitContent;
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public Path recordHarPath;
|
||||
public Object recordHarUrlFilter;
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public Path recordVideoDir;
|
||||
/**
|
||||
@@ -615,8 +614,8 @@ public interface BrowserType {
|
||||
public RecordVideoSize recordVideoSize;
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public Optional<ReducedMotion> reducedMotion;
|
||||
/**
|
||||
@@ -691,10 +690,11 @@ public interface BrowserType {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
|
||||
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
|
||||
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* 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
|
||||
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
|
||||
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
|
||||
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
|
||||
* corresponding URL. Unset by default. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
|
||||
@@ -744,8 +744,8 @@ public interface BrowserType {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
|
||||
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "light"}.
|
||||
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
|
||||
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setColorScheme(ColorScheme colorScheme) {
|
||||
this.colorScheme = Optional.ofNullable(colorScheme);
|
||||
@@ -760,8 +760,7 @@ public interface BrowserType {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
|
||||
* headless} option will be set {@code false}.
|
||||
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setDevtools(boolean devtools) {
|
||||
this.devtools = devtools;
|
||||
@@ -809,8 +808,8 @@ public interface BrowserType {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
|
||||
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
|
||||
* Defaults to {@code "none"}.
|
||||
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
|
||||
* to system defaults. Defaults to {@code "none"}.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setForcedColors(ForcedColors forcedColors) {
|
||||
this.forcedColors = Optional.ofNullable(forcedColors);
|
||||
@@ -936,8 +935,9 @@ public interface BrowserType {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
|
||||
* BrowserContext.grantPermissions()} for more details. Defaults to none.
|
||||
* A list of permissions to grant to all pages in this context. See {@link
|
||||
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
|
||||
* to none.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setPermissions(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
@@ -983,8 +983,8 @@ public interface BrowserType {
|
||||
}
|
||||
/**
|
||||
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
|
||||
* BrowserContext.close()} for the HAR to be saved.
|
||||
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
|
||||
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setRecordHarPath(Path recordHarPath) {
|
||||
this.recordHarPath = recordHarPath;
|
||||
@@ -1000,7 +1000,7 @@ public interface BrowserType {
|
||||
}
|
||||
/**
|
||||
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
|
||||
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setRecordVideoDir(Path recordVideoDir) {
|
||||
this.recordVideoDir = recordVideoDir;
|
||||
@@ -1025,8 +1025,8 @@ public interface BrowserType {
|
||||
}
|
||||
/**
|
||||
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
|
||||
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
|
||||
* defaults. Defaults to {@code "no-preference"}.
|
||||
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
|
||||
* emulation to system defaults. Defaults to {@code "no-preference"}.
|
||||
*/
|
||||
public LaunchPersistentContextOptions setReducedMotion(ReducedMotion reducedMotion) {
|
||||
this.reducedMotion = Optional.ofNullable(reducedMotion);
|
||||
@@ -1154,11 +1154,11 @@ public interface BrowserType {
|
||||
/**
|
||||
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
||||
*
|
||||
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
|
||||
* <p> The default browser context is accessible via {@link com.microsoft.playwright.Browser#contexts Browser.contexts()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
||||
* BrowserContext defaultContext = browser.contexts().get(0);
|
||||
@@ -1175,11 +1175,11 @@ public interface BrowserType {
|
||||
/**
|
||||
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
|
||||
*
|
||||
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
|
||||
* <p> The default browser context is accessible via {@link com.microsoft.playwright.Browser#contexts Browser.contexts()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
||||
* BrowserContext defaultContext = browser.contexts().get(0);
|
||||
@@ -1200,7 +1200,7 @@ public interface BrowserType {
|
||||
/**
|
||||
* Returns the browser instance.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> You can use {@code ignoreDefaultArgs} to filter out {@code --mute-audio} from default arguments:
|
||||
* <pre>{@code
|
||||
@@ -1236,7 +1236,7 @@ public interface BrowserType {
|
||||
/**
|
||||
* Returns the browser instance.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> You can use {@code ignoreDefaultArgs} to filter out {@code --mute-audio} from default arguments:
|
||||
* <pre>{@code
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.gson.JsonObject;
|
||||
* <li> Documentation on DevTools Protocol can be found here: <a
|
||||
* href="https://chromedevtools.github.io/devtools-protocol/">DevTools Protocol Viewer</a>.</li>
|
||||
* <li> Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md</li>
|
||||
* </ul>
|
||||
* <pre>{@code
|
||||
* CDPSession client = page.context().newCDPSession(page);
|
||||
* client.send("Runtime.enable");
|
||||
@@ -45,7 +46,6 @@ import com.google.gson.JsonObject;
|
||||
* params.addProperty("playbackRate", playbackRate / 2);
|
||||
* client.send("Animation.setPlaybackRate", params);
|
||||
* }</pre>
|
||||
* </ul>
|
||||
*/
|
||||
public interface CDPSession {
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,9 @@ package com.microsoft.playwright;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()}
|
||||
* event. For each console messages logged in the page there will be corresponding event in the Playwright context.
|
||||
* {@code ConsoleMessage} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onConsoleMessage
|
||||
* Page.onConsoleMessage()} event. For each console messages logged in the page there will be corresponding event in the
|
||||
* Playwright context.
|
||||
* <pre>{@code
|
||||
* // Listen for all console messages and print them to the standard output.
|
||||
* page.onConsoleMessage(msg -> System.out.println(msg.text()));
|
||||
@@ -44,8 +45,8 @@ import java.util.*;
|
||||
*/
|
||||
public interface ConsoleMessage {
|
||||
/**
|
||||
* List of arguments passed to a {@code console} function call. See also {@link Page#onConsoleMessage
|
||||
* Page.onConsoleMessage()}.
|
||||
* List of arguments passed to a {@code console} function call. See also {@link
|
||||
* com.microsoft.playwright.Page#onConsoleMessage Page.onConsoleMessage()}.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,8 @@ package com.microsoft.playwright;
|
||||
|
||||
|
||||
/**
|
||||
* {@code Dialog} objects are dispatched by page via the {@link Page#onDialog Page.onDialog()} event.
|
||||
* {@code Dialog} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onDialog Page.onDialog()}
|
||||
* event.
|
||||
*
|
||||
* <p> An example of using {@code Dialog} class:
|
||||
* <pre>{@code
|
||||
@@ -41,9 +42,9 @@ package com.microsoft.playwright;
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Dialogs are dismissed automatically, unless there is a {@link Page#onDialog Page.onDialog()} listener. When listener is
|
||||
* present, it **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss Dialog.dismiss()} the dialog
|
||||
* - otherwise the page will <a
|
||||
* <p> <strong>NOTE:</strong> Dialogs are dismissed automatically, unless there is a {@link com.microsoft.playwright.Page#onDialog Page.onDialog()}
|
||||
* listener. When listener is present, it **must** either {@link com.microsoft.playwright.Dialog#accept Dialog.accept()} or
|
||||
* {@link com.microsoft.playwright.Dialog#dismiss Dialog.dismiss()} the dialog - otherwise the page will <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
|
||||
* dialog, and actions like click will never finish.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* {@code Download} objects are dispatched by page via the {@link Page#onDownload Page.onDownload()} event.
|
||||
* {@code Download} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onDownload
|
||||
* Page.onDownload()} event.
|
||||
*
|
||||
* <p> All the downloaded files belonging to the browser context are deleted when the browser context is closed.
|
||||
*
|
||||
@@ -72,8 +73,8 @@ public interface Download {
|
||||
* Returns path to the downloaded file for a successful download, or throws for a failed/canceled download. The method will
|
||||
* wait for the download to finish if necessary. The method throws when connected remotely.
|
||||
*
|
||||
* <p> Note that the download's file name is a random GUID, use {@link Download#suggestedFilename Download.suggestedFilename()}
|
||||
* to get suggested file name.
|
||||
* <p> Note that the download's file name is a random GUID, use {@link com.microsoft.playwright.Download#suggestedFilename
|
||||
* Download.suggestedFilename()} to get suggested file name.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -82,7 +83,7 @@ public interface Download {
|
||||
* Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will
|
||||
* wait for the download to finish if necessary.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
|
||||
* }</pre>
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ElementHandle represents an in-page DOM element. ElementHandles can be created with the {@link Page#querySelector
|
||||
* Page.querySelector()} method.
|
||||
* ElementHandle represents an in-page DOM element. ElementHandles can be created with the {@link
|
||||
* com.microsoft.playwright.Page#querySelector Page.querySelector()} method.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> The use of ElementHandle is discouraged, use {@code Locator} objects and web-first assertions instead.
|
||||
* <pre>{@code
|
||||
@@ -30,11 +30,12 @@ import java.util.*;
|
||||
* hrefElement.click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> ElementHandle prevents DOM element from garbage collection unless the handle is disposed with {@link JSHandle#dispose
|
||||
* JSHandle.dispose()}. ElementHandles are auto-disposed when their origin frame gets navigated.
|
||||
* <p> ElementHandle prevents DOM element from garbage collection unless the handle is disposed with {@link
|
||||
* com.microsoft.playwright.JSHandle#dispose JSHandle.dispose()}. ElementHandles are auto-disposed when their origin frame
|
||||
* gets navigated.
|
||||
*
|
||||
* <p> ElementHandle instances can be used as an argument in {@link Page#evalOnSelector Page.evalOnSelector()} and {@link
|
||||
* Page#evaluate Page.evaluate()} methods.
|
||||
* <p> ElementHandle instances can be used as an argument in {@link com.microsoft.playwright.Page#evalOnSelector
|
||||
* Page.evalOnSelector()} and {@link com.microsoft.playwright.Page#evaluate Page.evaluate()} methods.
|
||||
*
|
||||
* <p> The difference between the {@code Locator} and ElementHandle is that the ElementHandle points to a particular element,
|
||||
* while {@code Locator} captures the logic of how to retrieve an element.
|
||||
@@ -76,8 +77,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -121,8 +123,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 CheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -174,8 +177,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -248,8 +252,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 ClickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -297,8 +302,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -364,8 +370,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 DblclickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -395,8 +402,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -419,8 +427,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 FillOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -451,8 +460,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -504,8 +514,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 HoverOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -524,15 +535,17 @@ public interface ElementHandle extends JSHandle {
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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) {
|
||||
this.timeout = timeout;
|
||||
@@ -552,8 +565,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -575,8 +589,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 PressOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -642,8 +657,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public String style;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -736,8 +752,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 ScreenshotOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -754,15 +771,17 @@ public interface ElementHandle extends JSHandle {
|
||||
class ScrollIntoViewIfNeededOptions {
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 ScrollIntoViewIfNeededOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -783,8 +802,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -807,8 +827,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 SelectOptionOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -823,8 +844,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean force;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -838,8 +860,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 SelectTextOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -865,8 +888,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -910,8 +934,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 SetCheckedOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -936,8 +961,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -952,8 +978,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 SetInputFilesOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -984,8 +1011,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -1037,8 +1065,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 TapOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -1067,8 +1096,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -1090,8 +1120,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 TypeOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -1117,8 +1148,9 @@ public interface ElementHandle extends JSHandle {
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
/**
|
||||
@@ -1162,8 +1194,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 UncheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -1182,15 +1215,17 @@ public interface ElementHandle extends JSHandle {
|
||||
class WaitForElementStateOptions {
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
|
||||
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 WaitForElementStateOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -1217,8 +1252,9 @@ public interface ElementHandle extends JSHandle {
|
||||
public Boolean strict;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -1247,8 +1283,9 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 WaitForSelectorOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -1269,7 +1306,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <p> Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
|
||||
* snippet should click the center of the element.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* BoundingBox box = elementHandle.boundingBox();
|
||||
* page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
|
||||
@@ -1286,7 +1323,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now checked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -1309,7 +1346,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now checked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -1328,7 +1365,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element, or the specified
|
||||
* {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -1348,7 +1386,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element, or the specified
|
||||
* {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -1372,7 +1411,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
|
||||
* specified {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
|
||||
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
|
||||
* </ol>
|
||||
@@ -1395,7 +1435,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
|
||||
* specified {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
|
||||
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
|
||||
* </ol>
|
||||
@@ -1415,7 +1456,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* {@code click} is dispatched. This is equivalent to calling <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* elementHandle.dispatchEvent("click");
|
||||
* }</pre>
|
||||
@@ -1459,7 +1500,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* {@code click} is dispatched. This is equivalent to calling <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* elementHandle.dispatchEvent("click");
|
||||
* }</pre>
|
||||
@@ -1505,9 +1546,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to resolve and return its value.
|
||||
* com.microsoft.playwright.ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to
|
||||
* resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle tweetHandle = page.querySelector(".tweet");
|
||||
* assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
|
||||
@@ -1530,9 +1572,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to resolve and return its value.
|
||||
* com.microsoft.playwright.ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to
|
||||
* resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle tweetHandle = page.querySelector(".tweet");
|
||||
* assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
|
||||
@@ -1554,10 +1597,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise to resolve and return its
|
||||
* value.
|
||||
* com.microsoft.playwright.ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise
|
||||
* to resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle feedHandle = page.querySelector(".feed");
|
||||
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
|
||||
@@ -1579,10 +1622,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise to resolve and return its
|
||||
* value.
|
||||
* com.microsoft.playwright.ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise
|
||||
* to resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle feedHandle = page.querySelector(".feed");
|
||||
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
|
||||
@@ -1605,7 +1648,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
|
||||
* instead.
|
||||
*
|
||||
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
|
||||
* <p> To send fine-grained keyboard events, use {@link com.microsoft.playwright.Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
*
|
||||
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
|
||||
* @since v1.8
|
||||
@@ -1623,7 +1667,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
|
||||
* instead.
|
||||
*
|
||||
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
|
||||
* <p> To send fine-grained keyboard events, use {@link com.microsoft.playwright.Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
*
|
||||
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
|
||||
* @since v1.8
|
||||
@@ -1648,7 +1693,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
|
||||
* {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -1668,7 +1714,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
|
||||
* {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -1759,7 +1806,8 @@ public interface ElementHandle extends JSHandle {
|
||||
*/
|
||||
Frame ownerFrame();
|
||||
/**
|
||||
* Focuses the element, and then uses {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
|
||||
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||
*
|
||||
* <p> {@code key} can specify the intended <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
|
||||
@@ -1779,8 +1827,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <p> If {@code key} is a single character, it is case-sensitive, so the values {@code a} and {@code A} will generate
|
||||
* different respective texts.
|
||||
*
|
||||
* <p> Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When specified with
|
||||
* the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
|
||||
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
*
|
||||
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
|
||||
* @since v1.8
|
||||
@@ -1789,7 +1837,8 @@ public interface ElementHandle extends JSHandle {
|
||||
press(key, null);
|
||||
}
|
||||
/**
|
||||
* Focuses the element, and then uses {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
|
||||
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||
*
|
||||
* <p> {@code key} can specify the intended <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
|
||||
@@ -1809,8 +1858,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <p> If {@code key} is a single character, it is case-sensitive, so the values {@code a} and {@code A} will generate
|
||||
* different respective texts.
|
||||
*
|
||||
* <p> Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When specified with
|
||||
* the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
|
||||
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
*
|
||||
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
|
||||
* @since v1.8
|
||||
@@ -1899,7 +1948,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -1930,7 +1979,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -1959,7 +2008,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -1990,7 +2039,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2019,7 +2068,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2050,7 +2099,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2079,7 +2128,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2110,7 +2159,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2139,7 +2188,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2170,7 +2219,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2199,7 +2248,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2230,7 +2279,7 @@ public interface ElementHandle extends JSHandle {
|
||||
*
|
||||
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Single selection matching the value or label
|
||||
* handle.selectOption("blue");
|
||||
@@ -2278,7 +2327,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
|
||||
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -2300,7 +2349,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
|
||||
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -2430,7 +2479,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
|
||||
* specified {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -2452,7 +2502,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
|
||||
* specified {@code position}.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* </ol>
|
||||
*
|
||||
@@ -2473,9 +2524,9 @@ public interface ElementHandle extends JSHandle {
|
||||
*/
|
||||
String textContent();
|
||||
/**
|
||||
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
|
||||
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
* @deprecated In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
|
||||
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
|
||||
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
|
||||
*
|
||||
* @param text A text to type into a focused element.
|
||||
* @since v1.8
|
||||
@@ -2484,9 +2535,9 @@ public interface ElementHandle extends JSHandle {
|
||||
type(text, null);
|
||||
}
|
||||
/**
|
||||
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
|
||||
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
* @deprecated In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
|
||||
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
|
||||
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
|
||||
*
|
||||
* @param text A text to type into a focused element.
|
||||
* @since v1.8
|
||||
@@ -2500,7 +2551,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -2523,7 +2574,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
|
||||
* force} option is set.</li>
|
||||
* <li> Scroll the element into view if needed.</li>
|
||||
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
|
||||
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
|
||||
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
|
||||
* </ol>
|
||||
@@ -2603,7 +2654,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* condition, the method will return immediately. If the selector doesn't satisfy the condition for the {@code timeout}
|
||||
* milliseconds, the function will throw.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.setContent("<div><span></span></div>");
|
||||
* ElementHandle div = page.querySelector("div");
|
||||
@@ -2612,7 +2663,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* .setState(WaitForSelectorState.ATTACHED));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
|
||||
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link com.microsoft.playwright.Page#waitForSelector
|
||||
* Page.waitForSelector()} instead.
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
* @since v1.8
|
||||
@@ -2629,7 +2681,7 @@ public interface ElementHandle extends JSHandle {
|
||||
* condition, the method will return immediately. If the selector doesn't satisfy the condition for the {@code timeout}
|
||||
* milliseconds, the function will throw.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.setContent("<div><span></span></div>");
|
||||
* ElementHandle div = page.querySelector("div");
|
||||
@@ -2638,7 +2690,8 @@ public interface ElementHandle extends JSHandle {
|
||||
* .setState(WaitForSelectorState.ATTACHED));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
|
||||
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link com.microsoft.playwright.Page#waitForSelector
|
||||
* Page.waitForSelector()} instead.
|
||||
*
|
||||
* @param selector A selector to query for.
|
||||
* @since v1.8
|
||||
|
||||
@@ -20,7 +20,8 @@ import com.microsoft.playwright.options.*;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* {@code FileChooser} objects are dispatched by the page in the {@link Page#onFileChooser Page.onFileChooser()} event.
|
||||
* {@code FileChooser} objects are dispatched by the page in the {@link com.microsoft.playwright.Page#onFileChooser
|
||||
* Page.onFileChooser()} event.
|
||||
* <pre>{@code
|
||||
* FileChooser fileChooser = page.waitForFileChooser(() -> page.getByText("Upload file").click());
|
||||
* fileChooser.setFiles(Paths.get("myfile.pdf"));
|
||||
@@ -36,8 +37,9 @@ public interface FileChooser {
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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;
|
||||
|
||||
@@ -52,8 +54,9 @@ public interface FileChooser {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
|
||||
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
|
||||
* 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 SetFilesOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,15 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* FrameLocator represents a view to the {@code iframe} on the page. It captures the logic sufficient to retrieve the
|
||||
* {@code iframe} and locate elements in that iframe. FrameLocator can be created with either {@link Page#frameLocator
|
||||
* Page.frameLocator()} or {@link Locator#frameLocator Locator.frameLocator()} method.
|
||||
* {@code iframe} and locate elements in that iframe. FrameLocator can be created with either {@link
|
||||
* com.microsoft.playwright.Page#frameLocator Page.frameLocator()} or {@link com.microsoft.playwright.Locator#frameLocator
|
||||
* Locator.frameLocator()} method.
|
||||
* <pre>{@code
|
||||
* Locator locator = page.frameLocator("#my-frame").getByText("Submit");
|
||||
* locator.click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Strictness**
|
||||
* <p> <strong>Strictness</strong>
|
||||
*
|
||||
* <p> Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
|
||||
* a given selector.
|
||||
@@ -40,13 +41,15 @@ import java.util.regex.Pattern;
|
||||
* page.frame_locator(".result-frame").first().getByRole(AriaRole.BUTTON).click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Converting Locator to FrameLocator**
|
||||
* <p> <strong>Converting Locator to FrameLocator</strong>
|
||||
*
|
||||
* <p> If you have a {@code Locator} object pointing to an {@code iframe} it can be converted to {@code FrameLocator} using <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/:scope">{@code :scope}</a> CSS selector:
|
||||
* <pre>{@code
|
||||
* Locator frameLocator = locator.frameLocator(':scope');
|
||||
* }</pre>
|
||||
* <p> If you have a {@code Locator} object pointing to an {@code iframe} it can be converted to {@code FrameLocator} using
|
||||
* {@link com.microsoft.playwright.Locator#contentFrame Locator.contentFrame()}.
|
||||
*
|
||||
* <p> <strong>Converting FrameLocator to Locator</strong>
|
||||
*
|
||||
* <p> If you have a {@code FrameLocator} object it can be converted to {@code Locator} pointing to the same {@code iframe}
|
||||
* using {@link com.microsoft.playwright.FrameLocator#owner FrameLocator.owner()}.
|
||||
*/
|
||||
public interface FrameLocator {
|
||||
class GetByAltTextOptions {
|
||||
@@ -396,7 +399,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their alt text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find the image by alt text "Playwright logo":
|
||||
* <pre>{@code
|
||||
@@ -412,7 +415,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their alt text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find the image by alt text "Playwright logo":
|
||||
* <pre>{@code
|
||||
@@ -426,7 +429,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their alt text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find the image by alt text "Playwright logo":
|
||||
* <pre>{@code
|
||||
@@ -442,7 +445,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their alt text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find the image by alt text "Playwright logo":
|
||||
* <pre>{@code
|
||||
@@ -457,7 +460,7 @@ public interface FrameLocator {
|
||||
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
|
||||
* the {@code aria-label} attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
|
||||
* <pre>{@code
|
||||
@@ -475,7 +478,7 @@ public interface FrameLocator {
|
||||
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
|
||||
* the {@code aria-label} attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
|
||||
* <pre>{@code
|
||||
@@ -491,7 +494,7 @@ public interface FrameLocator {
|
||||
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
|
||||
* the {@code aria-label} attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
|
||||
* <pre>{@code
|
||||
@@ -509,7 +512,7 @@ public interface FrameLocator {
|
||||
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
|
||||
* the {@code aria-label} attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
|
||||
* <pre>{@code
|
||||
@@ -524,7 +527,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating input elements by the placeholder text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, consider the following DOM structure.
|
||||
*
|
||||
@@ -542,7 +545,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating input elements by the placeholder text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, consider the following DOM structure.
|
||||
*
|
||||
@@ -558,7 +561,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating input elements by the placeholder text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, consider the following DOM structure.
|
||||
*
|
||||
@@ -576,7 +579,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating input elements by the placeholder text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, consider the following DOM structure.
|
||||
*
|
||||
@@ -594,7 +597,7 @@ public interface FrameLocator {
|
||||
* href="https://www.w3.org/TR/wai-aria-1.2/#aria-attributes">ARIA attributes</a> and <a
|
||||
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -615,7 +618,7 @@ public interface FrameLocator {
|
||||
* .click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the
|
||||
* ARIA guidelines.
|
||||
@@ -637,7 +640,7 @@ public interface FrameLocator {
|
||||
* href="https://www.w3.org/TR/wai-aria-1.2/#aria-attributes">ARIA attributes</a> and <a
|
||||
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -658,7 +661,7 @@ public interface FrameLocator {
|
||||
* .click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the
|
||||
* ARIA guidelines.
|
||||
@@ -676,7 +679,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Locate element by the test id.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -685,10 +688,11 @@ public interface FrameLocator {
|
||||
* page.getByTestId("directions").click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link Selectors#setTestIdAttribute
|
||||
* Selectors.setTestIdAttribute()} to configure a different test id attribute if necessary.
|
||||
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link
|
||||
* com.microsoft.playwright.Selectors#setTestIdAttribute Selectors.setTestIdAttribute()} to configure a different test id
|
||||
* attribute if necessary.
|
||||
*
|
||||
* @param testId Id to locate the element by.
|
||||
* @since v1.27
|
||||
@@ -697,7 +701,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Locate element by the test id.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -706,10 +710,11 @@ public interface FrameLocator {
|
||||
* page.getByTestId("directions").click();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link Selectors#setTestIdAttribute
|
||||
* Selectors.setTestIdAttribute()} to configure a different test id attribute if necessary.
|
||||
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link
|
||||
* com.microsoft.playwright.Selectors#setTestIdAttribute Selectors.setTestIdAttribute()} to configure a different test id
|
||||
* attribute if necessary.
|
||||
*
|
||||
* @param testId Id to locate the element by.
|
||||
* @since v1.27
|
||||
@@ -718,10 +723,10 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements that contain given text.
|
||||
*
|
||||
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
|
||||
* then filter by the text content.
|
||||
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
|
||||
* an accessible role, and then filter by the text content.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure:
|
||||
*
|
||||
@@ -743,7 +748,7 @@ public interface FrameLocator {
|
||||
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
|
||||
* turns line breaks into spaces and ignores leading and trailing whitespace.
|
||||
@@ -760,10 +765,10 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements that contain given text.
|
||||
*
|
||||
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
|
||||
* then filter by the text content.
|
||||
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
|
||||
* an accessible role, and then filter by the text content.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure:
|
||||
*
|
||||
@@ -785,7 +790,7 @@ public interface FrameLocator {
|
||||
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
|
||||
* turns line breaks into spaces and ignores leading and trailing whitespace.
|
||||
@@ -800,10 +805,10 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements that contain given text.
|
||||
*
|
||||
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
|
||||
* then filter by the text content.
|
||||
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
|
||||
* an accessible role, and then filter by the text content.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure:
|
||||
*
|
||||
@@ -825,7 +830,7 @@ public interface FrameLocator {
|
||||
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
|
||||
* turns line breaks into spaces and ignores leading and trailing whitespace.
|
||||
@@ -842,10 +847,10 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements that contain given text.
|
||||
*
|
||||
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
|
||||
* then filter by the text content.
|
||||
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
|
||||
* an accessible role, and then filter by the text content.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure:
|
||||
*
|
||||
@@ -867,7 +872,7 @@ public interface FrameLocator {
|
||||
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
|
||||
* turns line breaks into spaces and ignores leading and trailing whitespace.
|
||||
@@ -882,7 +887,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their title attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -900,7 +905,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their title attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -916,7 +921,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their title attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -934,7 +939,7 @@ public interface FrameLocator {
|
||||
/**
|
||||
* Allows locating elements by their title attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Consider the following DOM structure.
|
||||
*
|
||||
@@ -955,7 +960,7 @@ public interface FrameLocator {
|
||||
FrameLocator last();
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to {@link Locator#filter Locator.filter()} method.
|
||||
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
|
||||
*
|
||||
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
|
||||
*
|
||||
@@ -967,7 +972,7 @@ public interface FrameLocator {
|
||||
}
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to {@link Locator#filter Locator.filter()} method.
|
||||
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
|
||||
*
|
||||
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
|
||||
*
|
||||
@@ -977,7 +982,7 @@ public interface FrameLocator {
|
||||
Locator locator(String selectorOrLocator, LocatorOptions options);
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to {@link Locator#filter Locator.filter()} method.
|
||||
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
|
||||
*
|
||||
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
|
||||
*
|
||||
@@ -989,7 +994,7 @@ public interface FrameLocator {
|
||||
}
|
||||
/**
|
||||
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
|
||||
* similar to {@link Locator#filter Locator.filter()} method.
|
||||
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
|
||||
*
|
||||
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
|
||||
*
|
||||
@@ -1003,5 +1008,24 @@ public interface FrameLocator {
|
||||
* @since v1.17
|
||||
*/
|
||||
FrameLocator nth(int index);
|
||||
/**
|
||||
* Returns a {@code Locator} object pointing to the same {@code iframe} as this frame locator.
|
||||
*
|
||||
* <p> Useful when you have a {@code FrameLocator} object obtained somewhere, and later on would like to interact with the
|
||||
* {@code iframe} element.
|
||||
*
|
||||
* <p> For a reverse operation, use {@link com.microsoft.playwright.Locator#contentFrame Locator.contentFrame()}.
|
||||
*
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* FrameLocator frameLocator = page.frameLocator("iframe[name=\"embedded\"]");
|
||||
* // ...
|
||||
* Locator locator = frameLocator.owner();
|
||||
* assertThat(locator).isVisible();
|
||||
* }</pre>
|
||||
*
|
||||
* @since v1.43
|
||||
*/
|
||||
Locator owner();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,20 @@ package com.microsoft.playwright;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* JSHandle represents an in-page JavaScript object. JSHandles can be created with the {@link Page#evaluateHandle
|
||||
* Page.evaluateHandle()} method.
|
||||
* JSHandle represents an in-page JavaScript object. JSHandles can be created with the {@link
|
||||
* com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} method.
|
||||
* <pre>{@code
|
||||
* JSHandle windowHandle = page.evaluateHandle("() => window");
|
||||
* // ...
|
||||
* }</pre>
|
||||
*
|
||||
* <p> JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with {@link
|
||||
* JSHandle#dispose JSHandle.dispose()}. JSHandles are auto-disposed when their origin frame gets navigated or the parent
|
||||
* context gets destroyed.
|
||||
* com.microsoft.playwright.JSHandle#dispose JSHandle.dispose()}. JSHandles are auto-disposed when their origin frame gets
|
||||
* navigated or the parent context gets destroyed.
|
||||
*
|
||||
* <p> JSHandle instances can be used as an argument in {@link Page#evalOnSelector Page.evalOnSelector()}, {@link Page#evaluate
|
||||
* Page.evaluate()} and {@link Page#evaluateHandle Page.evaluateHandle()} methods.
|
||||
* <p> JSHandle instances can be used as an argument in {@link com.microsoft.playwright.Page#evalOnSelector
|
||||
* Page.evalOnSelector()}, {@link com.microsoft.playwright.Page#evaluate Page.evaluate()} and {@link
|
||||
* com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} methods.
|
||||
*/
|
||||
public interface JSHandle {
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ public interface JSHandle {
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
|
||||
* handle.evaluate} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
|
||||
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
|
||||
@@ -77,7 +78,7 @@ public interface JSHandle {
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
|
||||
* handle.evaluate} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
|
||||
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
|
||||
@@ -101,7 +102,7 @@ public interface JSHandle {
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
|
||||
* jsHandle.evaluateHandle} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
|
||||
* <p> See {@link com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} for more details.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
@@ -122,7 +123,7 @@ public interface JSHandle {
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
|
||||
* jsHandle.evaluateHandle} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
|
||||
* <p> See {@link com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} for more details.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
@@ -133,7 +134,7 @@ public interface JSHandle {
|
||||
/**
|
||||
* The method returns a map with **own property names** as keys and JSHandle instances for the property values.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* JSHandle handle = page.evaluateHandle("() => ({ window, document })");
|
||||
* Map<String, JSHandle> properties = handle.getProperties();
|
||||
|
||||
@@ -19,12 +19,13 @@ package com.microsoft.playwright;
|
||||
import com.microsoft.playwright.options.*;
|
||||
|
||||
/**
|
||||
* Keyboard provides an api for managing a virtual keyboard. The high level api is {@link Keyboard#type Keyboard.type()},
|
||||
* which takes raw characters and generates proper {@code keydown}, {@code keypress}/{@code input}, and {@code keyup}
|
||||
* events on your page.
|
||||
* Keyboard provides an api for managing a virtual keyboard. The high level api is {@link
|
||||
* com.microsoft.playwright.Keyboard#type Keyboard.type()}, which takes raw characters and generates proper {@code
|
||||
* keydown}, {@code keypress}/{@code input}, and {@code keyup} events on your page.
|
||||
*
|
||||
* <p> For finer control, you can use {@link Keyboard#down Keyboard.down()}, {@link Keyboard#up Keyboard.up()}, and {@link
|
||||
* Keyboard#insertText Keyboard.insertText()} to manually fire events as if they were generated from a real keyboard.
|
||||
* <p> For finer control, you can use {@link com.microsoft.playwright.Keyboard#down Keyboard.down()}, {@link
|
||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}, and {@link com.microsoft.playwright.Keyboard#insertText
|
||||
* Keyboard.insertText()} to manually fire events as if they were generated from a real keyboard.
|
||||
*
|
||||
* <p> An example of holding down {@code Shift} in order to select and delete some text:
|
||||
* <pre>{@code
|
||||
@@ -104,11 +105,12 @@ public interface Keyboard {
|
||||
* different respective texts.
|
||||
*
|
||||
* <p> If {@code key} is a modifier key, {@code Shift}, {@code Meta}, {@code Control}, or {@code Alt}, subsequent key presses
|
||||
* will be sent with that modifier active. To release the modifier key, use {@link Keyboard#up Keyboard.up()}.
|
||||
* will be sent with that modifier active. To release the modifier key, use {@link com.microsoft.playwright.Keyboard#up
|
||||
* Keyboard.up()}.
|
||||
*
|
||||
* <p> After the key is pressed once, subsequent calls to {@link Keyboard#down Keyboard.down()} will have <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat">repeat</a> set to true. To release the key,
|
||||
* use {@link Keyboard#up Keyboard.up()}.
|
||||
* <p> After the key is pressed once, subsequent calls to {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} will
|
||||
* have <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat">repeat</a> set to true. To release
|
||||
* the key, use {@link com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Modifier keys DO influence {@code keyboard.down}. Holding down {@code Shift} will type the text in upper case.
|
||||
*
|
||||
@@ -119,7 +121,7 @@ public interface Keyboard {
|
||||
/**
|
||||
* Dispatches only {@code input} event, does not emit the {@code keydown}, {@code keyup} or {@code keypress} events.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.keyboard().insertText("嗨");
|
||||
* }</pre>
|
||||
@@ -132,7 +134,7 @@ public interface Keyboard {
|
||||
*/
|
||||
void insertText(String text);
|
||||
/**
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#press Locator.press()} instead.
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#press Locator.press()} instead.
|
||||
*
|
||||
* <p> {@code key} can specify the intended <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
|
||||
@@ -152,10 +154,10 @@ public interface Keyboard {
|
||||
* <p> If {@code key} is a single character, it is case-sensitive, so the values {@code a} and {@code A} will generate
|
||||
* different respective texts.
|
||||
*
|
||||
* <p> Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When specified with
|
||||
* the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
|
||||
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Page page = browser.newPage();
|
||||
* page.navigate("https://keycode.info");
|
||||
@@ -168,7 +170,8 @@ public interface Keyboard {
|
||||
* browser.close();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Shortcut for {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
|
||||
* <p> Shortcut for {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||
*
|
||||
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
|
||||
* @since v1.8
|
||||
@@ -177,7 +180,7 @@ public interface Keyboard {
|
||||
press(key, null);
|
||||
}
|
||||
/**
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#press Locator.press()} instead.
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#press Locator.press()} instead.
|
||||
*
|
||||
* <p> {@code key} can specify the intended <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
|
||||
@@ -197,10 +200,10 @@ public interface Keyboard {
|
||||
* <p> If {@code key} is a single character, it is case-sensitive, so the values {@code a} and {@code A} will generate
|
||||
* different respective texts.
|
||||
*
|
||||
* <p> Shortcuts such as {@code key: "Control+o"} or {@code key: "Control+Shift+T"} are supported as well. When specified with
|
||||
* the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
|
||||
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Page page = browser.newPage();
|
||||
* page.navigate("https://keycode.info");
|
||||
@@ -213,22 +216,24 @@ public interface Keyboard {
|
||||
* browser.close();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Shortcut for {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
|
||||
* <p> Shortcut for {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
|
||||
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
|
||||
*
|
||||
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
|
||||
* @since v1.8
|
||||
*/
|
||||
void press(String key, PressOptions options);
|
||||
/**
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
|
||||
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
|
||||
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
|
||||
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
|
||||
*
|
||||
* <p> Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text.
|
||||
*
|
||||
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
|
||||
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link com.microsoft.playwright.Keyboard#press
|
||||
* Keyboard.press()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Types instantly
|
||||
* page.keyboard().type("Hello");
|
||||
@@ -247,15 +252,16 @@ public interface Keyboard {
|
||||
type(text, null);
|
||||
}
|
||||
/**
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
|
||||
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
|
||||
* Locator.pressSequentially()}.
|
||||
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
|
||||
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
|
||||
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
|
||||
*
|
||||
* <p> Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text.
|
||||
*
|
||||
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
|
||||
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link com.microsoft.playwright.Keyboard#press
|
||||
* Keyboard.press()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // Types instantly
|
||||
* page.keyboard().type("Hello");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ import com.microsoft.playwright.options.*;
|
||||
/**
|
||||
* The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
|
||||
*
|
||||
* <p> Every {@code page} object has its own Mouse, accessible with {@link Page#mouse Page.mouse()}.
|
||||
* <p> Every {@code page} object has its own Mouse, accessible with {@link com.microsoft.playwright.Page#mouse Page.mouse()}.
|
||||
* <pre>{@code
|
||||
* // Using ‘page.mouse’ to trace a 100x100 square.
|
||||
* page.mouse().move(0, 0);
|
||||
@@ -160,7 +160,8 @@ public interface Mouse {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}.
|
||||
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -168,14 +169,16 @@ public interface Mouse {
|
||||
click(x, y, null);
|
||||
}
|
||||
/**
|
||||
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}.
|
||||
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
void click(double x, double y, ClickOptions options);
|
||||
/**
|
||||
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}, {@link
|
||||
* Mouse#down Mouse.down()} and {@link Mouse#up Mouse.up()}.
|
||||
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -183,8 +186,9 @@ public interface Mouse {
|
||||
dblclick(x, y, null);
|
||||
}
|
||||
/**
|
||||
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}, {@link
|
||||
* Mouse#down Mouse.down()} and {@link Mouse#up Mouse.up()}.
|
||||
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}, {@link com.microsoft.playwright.Mouse#down
|
||||
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -94,8 +94,8 @@ public interface Playwright extends AutoCloseable {
|
||||
*/
|
||||
void close();
|
||||
/**
|
||||
* Launches new Playwright driver process and connects to it. {@link Playwright#close Playwright.close()} should be called
|
||||
* when the instance is no longer needed.
|
||||
* Launches new Playwright driver process and connects to it. {@link com.microsoft.playwright.Playwright#close
|
||||
* Playwright.close()} should be called when the instance is no longer needed.
|
||||
* <pre>{@code
|
||||
* Playwright playwright = Playwright.create();
|
||||
* Browser browser = playwright.webkit().launch();
|
||||
|
||||
@@ -22,14 +22,15 @@ import java.util.*;
|
||||
/**
|
||||
* Whenever the page sends a request for a network resource the following sequence of events are emitted by {@code Page}:
|
||||
* <ul>
|
||||
* <li> {@link Page#onRequest Page.onRequest()} emitted when the request is issued by the page.</li>
|
||||
* <li> {@link Page#onResponse Page.onResponse()} emitted when/if the response status and headers are received for the request.</li>
|
||||
* <li> {@link Page#onRequestFinished Page.onRequestFinished()} emitted when the response body is downloaded and the request is
|
||||
* complete.</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#onRequest Page.onRequest()} emitted when the request is issued by the page.</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#onResponse Page.onResponse()} emitted when/if the response status and headers are
|
||||
* received for the request.</li>
|
||||
* <li> {@link com.microsoft.playwright.Page#onRequestFinished Page.onRequestFinished()} emitted when the response body is
|
||||
* downloaded and the request is complete.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> If request fails at some point, then instead of {@code "requestfinished"} event (and possibly instead of 'response'
|
||||
* event), the {@link Page#onRequestFailed Page.onRequestFailed()} event is emitted.
|
||||
* event), the {@link com.microsoft.playwright.Page#onRequestFailed Page.onRequestFailed()} event is emitted.
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
|
||||
* with {@code "requestfinished"} event.
|
||||
@@ -47,7 +48,7 @@ public interface Request {
|
||||
/**
|
||||
* The method returns {@code null} unless this request has failed, as reported by {@code requestfailed} event.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> Example of logging of all the failed requests:
|
||||
* <pre>{@code
|
||||
@@ -62,18 +63,18 @@ public interface Request {
|
||||
/**
|
||||
* Returns the {@code Frame} that initiated this request.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* String frameUrl = request.frame().url();
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Note that in some cases the frame is not available, and this method will throw.
|
||||
* <ul>
|
||||
* <li> When request originates in the Service Worker. You can use {@code request.serviceWorker()} to check that.</li>
|
||||
* <li> When navigation request is issued before the corresponding frame is created. You can use {@link
|
||||
* Request#isNavigationRequest Request.isNavigationRequest()} to check that.</li>
|
||||
* com.microsoft.playwright.Request#isNavigationRequest Request.isNavigationRequest()} to check that.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Here is an example that handles all the cases:
|
||||
@@ -83,16 +84,16 @@ public interface Request {
|
||||
Frame frame();
|
||||
/**
|
||||
* An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
|
||||
* security-related headers, including cookie-related ones. You can use {@link Request#allHeaders Request.allHeaders()} for
|
||||
* complete list of headers that include {@code cookie} information.
|
||||
* security-related headers, including cookie-related ones. You can use {@link com.microsoft.playwright.Request#allHeaders
|
||||
* Request.allHeaders()} for complete list of headers that include {@code cookie} information.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
Map<String, String> headers();
|
||||
/**
|
||||
* An array with all the request HTTP headers associated with this request. Unlike {@link Request#allHeaders
|
||||
* Request.allHeaders()}, header names are NOT lower-cased. Headers with multiple entries, such as {@code Set-Cookie},
|
||||
* appear in the array multiple times.
|
||||
* An array with all the request HTTP headers associated with this request. Unlike {@link
|
||||
* com.microsoft.playwright.Request#allHeaders Request.allHeaders()}, header names are NOT lower-cased. Headers with
|
||||
* multiple entries, such as {@code Set-Cookie}, appear in the array multiple times.
|
||||
*
|
||||
* @since v1.15
|
||||
*/
|
||||
@@ -108,7 +109,7 @@ public interface Request {
|
||||
* Whether this request is driving frame's navigation.
|
||||
*
|
||||
* <p> Some navigation requests are issued before the corresponding frame is created, and therefore do not have {@link
|
||||
* Request#frame Request.frame()} available.
|
||||
* com.microsoft.playwright.Request#frame Request.frame()} available.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -138,7 +139,7 @@ public interface Request {
|
||||
* connected by {@code redirectedFrom()} and {@code redirectedTo()} methods. When multiple server redirects has happened,
|
||||
* it is possible to construct the whole redirect chain by repeatedly calling {@code redirectedFrom()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, if the website {@code http://example.com} redirects to {@code https://example.com}:
|
||||
* <pre>{@code
|
||||
@@ -158,9 +159,9 @@ public interface Request {
|
||||
/**
|
||||
* New request issued by the browser if the server responded with redirect.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> This method is the opposite of {@link Request#redirectedFrom Request.redirectedFrom()}:
|
||||
* <p> This method is the opposite of {@link com.microsoft.playwright.Request#redirectedFrom Request.redirectedFrom()}:
|
||||
* <pre>{@code
|
||||
* System.out.println(request.redirectedFrom().redirectedTo() == request); // true
|
||||
* }</pre>
|
||||
@@ -193,7 +194,7 @@ public interface Request {
|
||||
* {@code responseEnd} becomes available when request finishes. Find more information at <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming">Resource Timing API</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.onRequestFinished(request -> {
|
||||
* Timing timing = request.timing();
|
||||
|
||||
@@ -56,16 +56,16 @@ public interface Response {
|
||||
boolean fromServiceWorker();
|
||||
/**
|
||||
* An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
|
||||
* security-related headers, including cookie-related ones. You can use {@link Response#allHeaders Response.allHeaders()}
|
||||
* for complete list of headers that include {@code cookie} information.
|
||||
* security-related headers, including cookie-related ones. You can use {@link com.microsoft.playwright.Response#allHeaders
|
||||
* Response.allHeaders()} for complete list of headers that include {@code cookie} information.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
Map<String, String> headers();
|
||||
/**
|
||||
* An array with all the request HTTP headers associated with this response. Unlike {@link Response#allHeaders
|
||||
* Response.allHeaders()}, header names are NOT lower-cased. Headers with multiple entries, such as {@code Set-Cookie},
|
||||
* appear in the array multiple times.
|
||||
* An array with all the request HTTP headers associated with this response. Unlike {@link
|
||||
* com.microsoft.playwright.Response#allHeaders Response.allHeaders()}, header names are NOT lower-cased. Headers with
|
||||
* multiple entries, such as {@code Set-Cookie}, appear in the array multiple times.
|
||||
*
|
||||
* @since v1.15
|
||||
*/
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Whenever a network route is set up with {@link Page#route Page.route()} or {@link BrowserContext#route
|
||||
* BrowserContext.route()}, the {@code Route} object allows to handle the route.
|
||||
* Whenever a network route is set up with {@link com.microsoft.playwright.Page#route Page.route()} or {@link
|
||||
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}, the {@code Route} object allows to handle the
|
||||
* route.
|
||||
*
|
||||
* <p> Learn more about <a href="https://playwright.dev/java/docs/network">networking</a>.
|
||||
*/
|
||||
@@ -334,7 +335,7 @@ public interface Route {
|
||||
/**
|
||||
* Continues route's request with optional overrides.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("**\/*", route -> {
|
||||
* // Override headers
|
||||
@@ -345,12 +346,12 @@ public interface Route {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Note that any overrides such as {@code url} or {@code headers} only apply to the request being routed. If this request
|
||||
* results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header
|
||||
* through redirects, use the combination of {@link Route#fetch Route.fetch()} and {@link Route#fulfill Route.fulfill()}
|
||||
* instead.
|
||||
* through redirects, use the combination of {@link com.microsoft.playwright.Route#fetch Route.fetch()} and {@link
|
||||
* com.microsoft.playwright.Route#fulfill Route.fulfill()} instead.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -360,7 +361,7 @@ public interface Route {
|
||||
/**
|
||||
* Continues route's request with optional overrides.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("**\/*", route -> {
|
||||
* // Override headers
|
||||
@@ -371,12 +372,12 @@ public interface Route {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Note that any overrides such as {@code url} or {@code headers} only apply to the request being routed. If this request
|
||||
* results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header
|
||||
* through redirects, use the combination of {@link Route#fetch Route.fetch()} and {@link Route#fulfill Route.fulfill()}
|
||||
* instead.
|
||||
* through redirects, use the combination of {@link com.microsoft.playwright.Route#fetch Route.fetch()} and {@link
|
||||
* com.microsoft.playwright.Route#fulfill Route.fulfill()} instead.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
@@ -387,7 +388,7 @@ public interface Route {
|
||||
* bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
|
||||
* registered route.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("**\/*", route -> {
|
||||
* // Runs last.
|
||||
@@ -452,7 +453,7 @@ public interface Route {
|
||||
* bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
|
||||
* registered route.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("**\/*", route -> {
|
||||
* // Runs last.
|
||||
@@ -513,7 +514,7 @@ public interface Route {
|
||||
* Performs the request and fetches result without fulfilling it, so that the response could be modified and then
|
||||
* fulfilled.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("https://dog.ceo/api/breeds/list/all", route -> {
|
||||
* APIResponse response = route.fetch();
|
||||
@@ -526,11 +527,11 @@ public interface Route {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Note that {@code headers} option will apply to the fetched request as well as any redirects initiated by it. If you want
|
||||
* to only apply {@code headers} to the original request, but not to redirects, look into {@link Route#resume
|
||||
* Route.resume()} instead.
|
||||
* to only apply {@code headers} to the original request, but not to redirects, look into {@link
|
||||
* com.microsoft.playwright.Route#resume Route.resume()} instead.
|
||||
*
|
||||
* @since v1.29
|
||||
*/
|
||||
@@ -541,7 +542,7 @@ public interface Route {
|
||||
* Performs the request and fetches result without fulfilling it, so that the response could be modified and then
|
||||
* fulfilled.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* page.route("https://dog.ceo/api/breeds/list/all", route -> {
|
||||
* APIResponse response = route.fetch();
|
||||
@@ -554,11 +555,11 @@ public interface Route {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> Note that {@code headers} option will apply to the fetched request as well as any redirects initiated by it. If you want
|
||||
* to only apply {@code headers} to the original request, but not to redirects, look into {@link Route#resume
|
||||
* Route.resume()} instead.
|
||||
* to only apply {@code headers} to the original request, but not to redirects, look into {@link
|
||||
* com.microsoft.playwright.Route#resume Route.resume()} instead.
|
||||
*
|
||||
* @since v1.29
|
||||
*/
|
||||
@@ -566,7 +567,7 @@ public interface Route {
|
||||
/**
|
||||
* Fulfills route's request with given response.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of fulfilling all requests with 404 responses:
|
||||
* <pre>{@code
|
||||
@@ -592,7 +593,7 @@ public interface Route {
|
||||
/**
|
||||
* Fulfills route's request with given response.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of fulfilling all requests with 404 responses:
|
||||
* <pre>{@code
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface Selectors {
|
||||
/**
|
||||
* Selectors must be registered before creating the page.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of registering selector engine that queries elements based on a tag name:
|
||||
* <pre>{@code
|
||||
@@ -84,7 +84,7 @@ public interface Selectors {
|
||||
/**
|
||||
* Selectors must be registered before creating the page.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of registering selector engine that queries elements based on a tag name:
|
||||
* <pre>{@code
|
||||
@@ -122,7 +122,7 @@ public interface Selectors {
|
||||
/**
|
||||
* Selectors must be registered before creating the page.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of registering selector engine that queries elements based on a tag name:
|
||||
* <pre>{@code
|
||||
@@ -162,7 +162,7 @@ public interface Selectors {
|
||||
/**
|
||||
* Selectors must be registered before creating the page.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> An example of registering selector engine that queries elements based on a tag name:
|
||||
* <pre>{@code
|
||||
@@ -198,8 +198,8 @@ public interface Selectors {
|
||||
*/
|
||||
void register(String name, Path script, RegisterOptions options);
|
||||
/**
|
||||
* Defines custom attribute name to be used in {@link Page#getByTestId Page.getByTestId()}. {@code data-testid} is used by
|
||||
* default.
|
||||
* Defines custom attribute name to be used in {@link com.microsoft.playwright.Page#getByTestId Page.getByTestId()}. {@code
|
||||
* data-testid} is used by default.
|
||||
*
|
||||
* @param attributeName Test id attribute name.
|
||||
* @since v1.27
|
||||
|
||||
@@ -25,7 +25,8 @@ public interface Touchscreen {
|
||||
/**
|
||||
* Dispatches a {@code touchstart} and {@code touchend} event with a single touch at the position ({@code x},{@code y}).
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser context is false.
|
||||
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser
|
||||
* context is false.
|
||||
*
|
||||
* @since v1.8
|
||||
*/
|
||||
|
||||
@@ -39,8 +39,9 @@ public interface Tracing {
|
||||
class StartOptions {
|
||||
/**
|
||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
|
||||
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
|
||||
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
|
||||
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stop
|
||||
* Tracing.stop()} instead.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
@@ -68,8 +69,9 @@ public interface Tracing {
|
||||
|
||||
/**
|
||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
|
||||
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
|
||||
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
|
||||
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stop
|
||||
* Tracing.stop()} instead.
|
||||
*/
|
||||
public StartOptions setName(String name) {
|
||||
this.name = name;
|
||||
@@ -113,8 +115,9 @@ public interface Tracing {
|
||||
class StartChunkOptions {
|
||||
/**
|
||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
|
||||
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
|
||||
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
|
||||
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stopChunk
|
||||
* Tracing.stopChunk()} instead.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
@@ -124,8 +127,9 @@ public interface Tracing {
|
||||
|
||||
/**
|
||||
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
|
||||
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
|
||||
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
|
||||
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
|
||||
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stopChunk
|
||||
* Tracing.stopChunk()} instead.
|
||||
*/
|
||||
public StartChunkOptions setName(String name) {
|
||||
this.name = name;
|
||||
@@ -155,14 +159,14 @@ public interface Tracing {
|
||||
}
|
||||
class StopChunkOptions {
|
||||
/**
|
||||
* Export trace collected since the last {@link Tracing#startChunk Tracing.startChunk()} call into the file with the given
|
||||
* path.
|
||||
* Export trace collected since the last {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} call into
|
||||
* the file with the given path.
|
||||
*/
|
||||
public Path path;
|
||||
|
||||
/**
|
||||
* Export trace collected since the last {@link Tracing#startChunk Tracing.startChunk()} call into the file with the given
|
||||
* path.
|
||||
* Export trace collected since the last {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} call into
|
||||
* the file with the given path.
|
||||
*/
|
||||
public StopChunkOptions setPath(Path path) {
|
||||
this.path = path;
|
||||
@@ -172,7 +176,7 @@ public interface Tracing {
|
||||
/**
|
||||
* Start tracing.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.tracing().start(new Tracing.StartOptions()
|
||||
* .setScreenshots(true)
|
||||
@@ -191,7 +195,7 @@ public interface Tracing {
|
||||
/**
|
||||
* Start tracing.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.tracing().start(new Tracing.StartOptions()
|
||||
* .setScreenshots(true)
|
||||
@@ -207,10 +211,11 @@ public interface Tracing {
|
||||
void start(StartOptions options);
|
||||
/**
|
||||
* Start a new trace chunk. If you'd like to record multiple traces on the same {@code BrowserContext}, use {@link
|
||||
* Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link Tracing#startChunk
|
||||
* Tracing.startChunk()} and {@link Tracing#stopChunk Tracing.stopChunk()}.
|
||||
* com.microsoft.playwright.Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link
|
||||
* com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} and {@link com.microsoft.playwright.Tracing#stopChunk
|
||||
* Tracing.stopChunk()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.tracing().start(new Tracing.StartOptions()
|
||||
* .setScreenshots(true)
|
||||
@@ -238,10 +243,11 @@ public interface Tracing {
|
||||
}
|
||||
/**
|
||||
* Start a new trace chunk. If you'd like to record multiple traces on the same {@code BrowserContext}, use {@link
|
||||
* Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link Tracing#startChunk
|
||||
* Tracing.startChunk()} and {@link Tracing#stopChunk Tracing.stopChunk()}.
|
||||
* com.microsoft.playwright.Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link
|
||||
* com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} and {@link com.microsoft.playwright.Tracing#stopChunk
|
||||
* Tracing.stopChunk()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* context.tracing().start(new Tracing.StartOptions()
|
||||
* .setScreenshots(true)
|
||||
@@ -280,7 +286,8 @@ public interface Tracing {
|
||||
*/
|
||||
void stop(StopOptions options);
|
||||
/**
|
||||
* Stop the trace chunk. See {@link Tracing#startChunk Tracing.startChunk()} for more details about multiple trace chunks.
|
||||
* Stop the trace chunk. See {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} for more details
|
||||
* about multiple trace chunks.
|
||||
*
|
||||
* @since v1.15
|
||||
*/
|
||||
@@ -288,7 +295,8 @@ public interface Tracing {
|
||||
stopChunk(null);
|
||||
}
|
||||
/**
|
||||
* Stop the trace chunk. See {@link Tracing#startChunk Tracing.startChunk()} for more details about multiple trace chunks.
|
||||
* Stop the trace chunk. See {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} for more details
|
||||
* about multiple trace chunks.
|
||||
*
|
||||
* @since v1.15
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.microsoft.playwright;
|
||||
|
||||
/**
|
||||
* {@code WebError} class represents an unhandled exception thrown in the page. It is dispatched via the {@link
|
||||
* BrowserContext#onWebError BrowserContext.onWebError()} event.
|
||||
* com.microsoft.playwright.BrowserContext#onWebError BrowserContext.onWebError()} event.
|
||||
* <pre>{@code
|
||||
* // Log all uncaught errors to the terminal
|
||||
* context.onWebError(webError -> {
|
||||
|
||||
@@ -67,7 +67,8 @@ public interface WebSocket {
|
||||
public Predicate<WebSocketFrame> predicate;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
@@ -80,7 +81,8 @@ public interface WebSocket {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public WaitForFrameReceivedOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -94,7 +96,8 @@ public interface WebSocket {
|
||||
public Predicate<WebSocketFrame> predicate;
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
@@ -107,7 +110,8 @@ public interface WebSocket {
|
||||
}
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public WaitForFrameSentOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
|
||||
@@ -19,8 +19,8 @@ package com.microsoft.playwright;
|
||||
|
||||
/**
|
||||
* The {@code WebSocketFrame} class represents frames sent over {@code WebSocket} connections in the page. Frame payload is
|
||||
* returned by either {@link WebSocketFrame#text WebSocketFrame.text()} or {@link WebSocketFrame#binary
|
||||
* WebSocketFrame.binary()} method depending on the its type.
|
||||
* returned by either {@link com.microsoft.playwright.WebSocketFrame#text WebSocketFrame.text()} or {@link
|
||||
* com.microsoft.playwright.WebSocketFrame#binary WebSocketFrame.binary()} method depending on the its type.
|
||||
*/
|
||||
public interface WebSocketFrame {
|
||||
/**
|
||||
|
||||
@@ -47,13 +47,15 @@ public interface Worker {
|
||||
class WaitForCloseOptions {
|
||||
/**
|
||||
* 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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
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 BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
|
||||
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
|
||||
* BrowserContext.setDefaultTimeout()}.
|
||||
*/
|
||||
public WaitForCloseOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
@@ -63,13 +65,14 @@ public interface Worker {
|
||||
/**
|
||||
* Returns the return value of {@code expression}.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a <a
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
* com.microsoft.playwright.Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional
|
||||
* values that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a
|
||||
* non-[Serializable] value, then {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns {@code
|
||||
* undefined}. Playwright also supports transferring some additional values that are not serializable by {@code JSON}:
|
||||
* {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
@@ -81,13 +84,14 @@ public interface Worker {
|
||||
/**
|
||||
* Returns the return value of {@code expression}.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a <a
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
* com.microsoft.playwright.Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
|
||||
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional
|
||||
* values that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a
|
||||
* non-[Serializable] value, then {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns {@code
|
||||
* undefined}. Playwright also supports transferring some additional values that are not serializable by {@code JSON}:
|
||||
* {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
@@ -98,12 +102,14 @@ public interface Worker {
|
||||
/**
|
||||
* Returns the return value of {@code expression} as a {@code JSHandle}.
|
||||
*
|
||||
* <p> The only difference between {@link Worker#evaluate Worker.evaluate()} and {@link Worker#evaluateHandle
|
||||
* Worker.evaluateHandle()} is that {@link Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
|
||||
* <p> The only difference between {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} and {@link
|
||||
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} is that {@link
|
||||
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluateHandle Worker.evaluateHandle()} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and return its value.
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns a
|
||||
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then
|
||||
* {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and
|
||||
* return its value.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
@@ -115,12 +121,14 @@ public interface Worker {
|
||||
/**
|
||||
* Returns the return value of {@code expression} as a {@code JSHandle}.
|
||||
*
|
||||
* <p> The only difference between {@link Worker#evaluate Worker.evaluate()} and {@link Worker#evaluateHandle
|
||||
* Worker.evaluateHandle()} is that {@link Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
|
||||
* <p> The only difference between {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} and {@link
|
||||
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} is that {@link
|
||||
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
|
||||
*
|
||||
* <p> If the function passed to the {@link Worker#evaluateHandle Worker.evaluateHandle()} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and return its value.
|
||||
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns a
|
||||
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then
|
||||
* {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and
|
||||
* return its value.
|
||||
*
|
||||
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
|
||||
* automatically invoked.
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public interface APIResponseAssertions {
|
||||
/**
|
||||
* Ensures the response status code is within {@code 200..299} range.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(response).isOK();
|
||||
* }</pre>
|
||||
|
||||
+88
-86
@@ -430,7 +430,7 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} points to an element that is <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByText("Hidden text")).isAttached();
|
||||
* }</pre>
|
||||
@@ -444,7 +444,7 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} points to an element that is <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByText("Hidden text")).isAttached();
|
||||
* }</pre>
|
||||
@@ -455,7 +455,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to a checked input.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByLabel("Subscribe to newsletter")).isChecked();
|
||||
* }</pre>
|
||||
@@ -468,7 +468,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to a checked input.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByLabel("Subscribe to newsletter")).isChecked();
|
||||
* }</pre>
|
||||
@@ -484,7 +484,7 @@ public interface LocatorAssertions {
|
||||
* {@code option}, {@code optgroup} can be disabled by setting "disabled" attribute. "disabled" attribute on other elements
|
||||
* is ignored by the browser.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("button.submit")).isDisabled();
|
||||
* }</pre>
|
||||
@@ -502,7 +502,7 @@ public interface LocatorAssertions {
|
||||
* {@code option}, {@code optgroup} can be disabled by setting "disabled" attribute. "disabled" attribute on other elements
|
||||
* is ignored by the browser.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("button.submit")).isDisabled();
|
||||
* }</pre>
|
||||
@@ -513,7 +513,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an editable element.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isEditable();
|
||||
* }</pre>
|
||||
@@ -526,7 +526,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an editable element.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isEditable();
|
||||
* }</pre>
|
||||
@@ -537,7 +537,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an empty editable element or to a DOM node that has no text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("div.warning")).isEmpty();
|
||||
* }</pre>
|
||||
@@ -550,7 +550,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an empty editable element or to a DOM node that has no text.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("div.warning")).isEmpty();
|
||||
* }</pre>
|
||||
@@ -561,7 +561,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an enabled element.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("button.submit")).isEnabled();
|
||||
* }</pre>
|
||||
@@ -574,7 +574,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an enabled element.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("button.submit")).isEnabled();
|
||||
* }</pre>
|
||||
@@ -585,7 +585,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to a focused DOM node.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isFocused();
|
||||
* }</pre>
|
||||
@@ -598,7 +598,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to a focused DOM node.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isFocused();
|
||||
* }</pre>
|
||||
@@ -610,7 +610,7 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a <a
|
||||
* href="https://playwright.dev/java/docs/actionability#visible">non-visible</a> one.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".my-element")).isHidden();
|
||||
* }</pre>
|
||||
@@ -624,7 +624,7 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a <a
|
||||
* href="https://playwright.dev/java/docs/actionability#visible">non-visible</a> one.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".my-element")).isHidden();
|
||||
* }</pre>
|
||||
@@ -636,7 +636,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that intersects viewport, according to the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">intersection observer API</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Locator locator = page.getByRole(AriaRole.BUTTON);
|
||||
* // Make sure at least some part of element intersects viewport.
|
||||
@@ -656,7 +656,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that intersects viewport, according to the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">intersection observer API</a>.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* Locator locator = page.getByRole(AriaRole.BUTTON);
|
||||
* // Make sure at least some part of element intersects viewport.
|
||||
@@ -674,9 +674,10 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} points to an attached and <a
|
||||
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
|
||||
*
|
||||
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
|
||||
* <p> To check that at least one element from the list is visible, use {@link com.microsoft.playwright.Locator#first
|
||||
* Locator.first()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // A specific element is visible.
|
||||
* assertThat(page.getByText("Welcome")).isVisible();
|
||||
@@ -701,9 +702,10 @@ public interface LocatorAssertions {
|
||||
* Ensures that {@code Locator} points to an attached and <a
|
||||
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
|
||||
*
|
||||
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
|
||||
* <p> To check that at least one element from the list is visible, use {@link com.microsoft.playwright.Locator#first
|
||||
* Locator.first()}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* // A specific element is visible.
|
||||
* assertThat(page.getByText("Welcome")).isVisible();
|
||||
@@ -726,12 +728,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -771,12 +773,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -814,12 +816,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -859,12 +861,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -902,12 +904,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -947,12 +949,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -990,12 +992,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -1035,12 +1037,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
|
||||
* when computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).containsText("substring");
|
||||
* }</pre>
|
||||
@@ -1077,7 +1079,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with given attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasAttribute("type", "text");
|
||||
* }</pre>
|
||||
@@ -1092,7 +1094,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with given attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasAttribute("type", "text");
|
||||
* }</pre>
|
||||
@@ -1105,7 +1107,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with given attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasAttribute("type", "text");
|
||||
* }</pre>
|
||||
@@ -1120,7 +1122,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with given attribute.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasAttribute("type", "text");
|
||||
* }</pre>
|
||||
@@ -1134,7 +1136,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1155,7 +1157,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1174,7 +1176,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1195,7 +1197,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1214,7 +1216,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1235,7 +1237,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1254,7 +1256,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1275,7 +1277,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
|
||||
* relaxed regular expression.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
|
||||
* assertThat(page.locator("#component")).hasClass("selected row");
|
||||
@@ -1293,7 +1295,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an exact number of DOM nodes.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("list > .component")).hasCount(3);
|
||||
* }</pre>
|
||||
@@ -1307,7 +1309,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an exact number of DOM nodes.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("list > .component")).hasCount(3);
|
||||
* }</pre>
|
||||
@@ -1319,7 +1321,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
|
||||
* }</pre>
|
||||
@@ -1334,7 +1336,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
|
||||
* }</pre>
|
||||
@@ -1347,7 +1349,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
|
||||
* }</pre>
|
||||
@@ -1362,7 +1364,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
|
||||
* }</pre>
|
||||
@@ -1375,7 +1377,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
|
||||
* }</pre>
|
||||
@@ -1389,7 +1391,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
|
||||
* }</pre>
|
||||
@@ -1401,7 +1403,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
|
||||
* }</pre>
|
||||
@@ -1415,7 +1417,7 @@ public interface LocatorAssertions {
|
||||
/**
|
||||
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
|
||||
* }</pre>
|
||||
@@ -1428,7 +1430,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given JavaScript property. Note that this property can be of a
|
||||
* primitive type as well as a plain serializable JavaScript object.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasJSProperty("loaded", true);
|
||||
* }</pre>
|
||||
@@ -1444,7 +1446,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with given JavaScript property. Note that this property can be of a
|
||||
* primitive type as well as a plain serializable JavaScript object.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input")).hasJSProperty("loaded", true);
|
||||
* }</pre>
|
||||
@@ -1458,12 +1460,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1503,12 +1505,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1546,12 +1548,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1591,12 +1593,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1634,12 +1636,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1679,12 +1681,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1722,12 +1724,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1767,12 +1769,12 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
|
||||
* computing the text content of the element. You can use regular expressions for the value as well.
|
||||
*
|
||||
* <p> **Details**
|
||||
* <p> <strong>Details</strong>
|
||||
*
|
||||
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
|
||||
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
|
||||
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
|
||||
@@ -1810,7 +1812,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
|
||||
* value as well.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
|
||||
* }</pre>
|
||||
@@ -1825,7 +1827,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
|
||||
* value as well.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
|
||||
* }</pre>
|
||||
@@ -1838,7 +1840,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
|
||||
* value as well.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
|
||||
* }</pre>
|
||||
@@ -1853,7 +1855,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
|
||||
* value as well.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
|
||||
* }</pre>
|
||||
@@ -1866,7 +1868,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
|
||||
* and the specified values are selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, given the following element:
|
||||
* <pre>{@code
|
||||
@@ -1884,7 +1886,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
|
||||
* and the specified values are selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, given the following element:
|
||||
* <pre>{@code
|
||||
@@ -1900,7 +1902,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
|
||||
* and the specified values are selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, given the following element:
|
||||
* <pre>{@code
|
||||
@@ -1918,7 +1920,7 @@ public interface LocatorAssertions {
|
||||
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
|
||||
* and the specified values are selected.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
*
|
||||
* <p> For example, given the following element:
|
||||
* <pre>{@code
|
||||
|
||||
@@ -78,7 +78,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page has the given title.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasTitle("Playwright");
|
||||
* }</pre>
|
||||
@@ -92,7 +92,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page has the given title.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasTitle("Playwright");
|
||||
* }</pre>
|
||||
@@ -104,7 +104,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page has the given title.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasTitle("Playwright");
|
||||
* }</pre>
|
||||
@@ -118,7 +118,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page has the given title.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasTitle("Playwright");
|
||||
* }</pre>
|
||||
@@ -130,7 +130,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page is navigated to the given URL.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasURL(".com");
|
||||
* }</pre>
|
||||
@@ -144,7 +144,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page is navigated to the given URL.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasURL(".com");
|
||||
* }</pre>
|
||||
@@ -156,7 +156,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page is navigated to the given URL.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasURL(".com");
|
||||
* }</pre>
|
||||
@@ -170,7 +170,7 @@ public interface PageAssertions {
|
||||
/**
|
||||
* Ensures the page is navigated to the given URL.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* assertThat(page).hasURL(".com");
|
||||
* }</pre>
|
||||
|
||||
+6
-6
@@ -54,7 +54,7 @@ public interface PlaywrightAssertions {
|
||||
/**
|
||||
* Creates a {@code APIResponseAssertions} object for the given {@code APIResponse}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* PlaywrightAssertions.assertThat(response).isOK();
|
||||
* }</pre>
|
||||
@@ -69,7 +69,7 @@ public interface PlaywrightAssertions {
|
||||
/**
|
||||
* Creates a {@code LocatorAssertions} object for the given {@code Locator}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* PlaywrightAssertions.assertThat(locator).isVisible();
|
||||
* }</pre>
|
||||
@@ -84,7 +84,7 @@ public interface PlaywrightAssertions {
|
||||
/**
|
||||
* Creates a {@code PageAssertions} object for the given {@code Page}.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* PlaywrightAssertions.assertThat(page).hasTitle("News");
|
||||
* }</pre>
|
||||
@@ -99,7 +99,7 @@ public interface PlaywrightAssertions {
|
||||
/**
|
||||
* Changes default timeout for Playwright assertions from 5 seconds to the specified value.
|
||||
*
|
||||
* <p> **Usage**
|
||||
* <p> <strong>Usage</strong>
|
||||
* <pre>{@code
|
||||
* PlaywrightAssertions.setDefaultAssertionTimeout(30_000);
|
||||
* }</pre>
|
||||
@@ -107,8 +107,8 @@ public interface PlaywrightAssertions {
|
||||
* @param timeout Timeout in milliseconds.
|
||||
* @since v1.25
|
||||
*/
|
||||
static void setDefaultAssertionTimeout(double milliseconds) {
|
||||
AssertionsTimeout.setDefaultTimeout(milliseconds);
|
||||
static void setDefaultAssertionTimeout(double timeout) {
|
||||
AssertionsTimeout.setDefaultTimeout(timeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
/*
|
||||
* 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.*;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.microsoft.playwright.APIRequestContext;
|
||||
import com.microsoft.playwright.APIResponse;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
@@ -10,7 +25,6 @@ import com.microsoft.playwright.options.FilePayload;
|
||||
import com.microsoft.playwright.options.RequestOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Base64;
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.Gson;
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.regex.Pattern;
|
||||
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
|
||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
|
||||
import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.nio.file.Files.readAllBytes;
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -46,6 +47,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
private final TracingImpl tracing;
|
||||
private final APIRequestContextImpl request;
|
||||
final List<PageImpl> pages = new ArrayList<>();
|
||||
|
||||
final Router routes = new Router();
|
||||
private boolean closeWasCalled;
|
||||
private final WaitableEvent<EventType, ?> closePromise;
|
||||
@@ -335,8 +337,29 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCookies() {
|
||||
withLogging("BrowserContext.clearCookies", () -> sendMessage("clearCookies"));
|
||||
public void clearCookies(ClearCookiesOptions options) {
|
||||
withLogging("BrowserContext.clearCookies", () -> clearCookiesImpl(options));
|
||||
}
|
||||
|
||||
private void clearCookiesImpl(ClearCookiesOptions options) {
|
||||
if (options == null) {
|
||||
options = new ClearCookiesOptions();
|
||||
}
|
||||
JsonObject params = new JsonObject();
|
||||
setStringOrRegex(params, "name", options.name);
|
||||
setStringOrRegex(params, "domain", options.domain);
|
||||
setStringOrRegex(params, "path", options.path);
|
||||
sendMessage("clearCookies", params);
|
||||
}
|
||||
|
||||
private static void setStringOrRegex(JsonObject params, String name, Object value) {
|
||||
if (value instanceof String) {
|
||||
params.addProperty(name, (String) value);
|
||||
} else if (value instanceof Pattern) {
|
||||
Pattern pattern = (Pattern) value;
|
||||
params.addProperty(name + "RegexSource", pattern.pattern());
|
||||
params.addProperty(name + "RegexFlags", toJsRegexFlags(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.JsonElement;
|
||||
|
||||
@@ -71,6 +71,7 @@ public class Connection {
|
||||
isLogging = (debug != null) && debug.contains("pw:channel");
|
||||
}
|
||||
LocalUtils localUtils;
|
||||
PlaywrightImpl playwright;
|
||||
final Map<String, String> env;
|
||||
private int tracingCount;
|
||||
|
||||
@@ -79,7 +80,7 @@ public class Connection {
|
||||
super(connection, "Root", "");
|
||||
}
|
||||
|
||||
Playwright initialize() {
|
||||
PlaywrightImpl initialize() {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("sdkLanguage", "java");
|
||||
JsonElement result = sendMessage("initialize", params.getAsJsonObject());
|
||||
@@ -177,7 +178,8 @@ public class Connection {
|
||||
}
|
||||
|
||||
public PlaywrightImpl initializePlaywright() {
|
||||
return (PlaywrightImpl) this.root.initialize();
|
||||
playwright = root.initialize();
|
||||
return playwright;
|
||||
}
|
||||
|
||||
LocalUtils localUtils() {
|
||||
|
||||
@@ -490,7 +490,7 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
||||
options = new SetInputFilesOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
params.add("files", Serialization.toJsonArray(files));
|
||||
params.add("payloads", Serialization.toJsonArray(files));
|
||||
sendMessage("setInputFiles", params);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
throw new PlaywrightException("Failed to read from file", e);
|
||||
}
|
||||
String content = new String(encoded, StandardCharsets.UTF_8);
|
||||
content += "//# sourceURL=" + options.path.toString().replace("\n", "");
|
||||
content = addSourceUrlToScript(content, options.path);
|
||||
jsonOptions.addProperty("content", content);
|
||||
}
|
||||
JsonElement json = sendMessage("addScriptTag", jsonOptions);
|
||||
@@ -407,12 +407,12 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(String testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(Pattern testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,12 +82,12 @@ class FrameLocatorImpl implements FrameLocator {
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(String testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, frame.connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(Pattern testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, frame.connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,4 +133,9 @@ class FrameLocatorImpl implements FrameLocator {
|
||||
public FrameLocator nth(int index) {
|
||||
return new FrameLocatorImpl(frame, frameSelector + " >> nth=" + index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator owner() {
|
||||
return new LocatorImpl(frame, frameSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,14 @@ public class HARRouter {
|
||||
|
||||
if ("fulfill".equals(action)) {
|
||||
int status = response.get("status").getAsInt();
|
||||
// If the response status is -1, the request was canceled or stalled, so we just stall it here.
|
||||
// See https://github.com/microsoft/playwright/issues/29311.
|
||||
// TODO: it'd be better to abort such requests, but then we likely need to respect the timing,
|
||||
// because the request might have been stalled for a long time until the very end of the
|
||||
// test when HAR was recorded but we'd abort it immediately.
|
||||
if (status == -1) {
|
||||
return;
|
||||
}
|
||||
Map<String, String> headers = fromNameValues(response.getAsJsonArray("headers"));
|
||||
byte[] buffer = Base64.getDecoder().decode(response.get("body").getAsString());
|
||||
route.fulfill(new Route.FulfillOptions()
|
||||
|
||||
@@ -41,7 +41,12 @@ public class JSHandleImpl extends ChannelOwner implements JSHandle {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
withLogging("JSHandle.dispose", () -> sendMessage("dispose"));
|
||||
withLogging("JSHandle.dispose", () -> {
|
||||
try {
|
||||
sendMessage("dispose");
|
||||
} catch (TargetClosedError e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,10 @@ class LocalUtils extends ChannelOwner {
|
||||
super(parent, type, guid, initializer);
|
||||
}
|
||||
|
||||
JsonArray deviceDescriptors() {
|
||||
return initializer.getAsJsonArray("deviceDescriptors");
|
||||
}
|
||||
|
||||
void zip(Path zipFile, JsonArray entries, String stacksId, boolean appendMode, boolean includeSources) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("zipFile", zipFile.toString());
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.JsonElement;
|
||||
@@ -23,6 +39,10 @@ class LocatorImpl implements Locator {
|
||||
final FrameImpl frame;
|
||||
final String selector;
|
||||
|
||||
LocatorImpl(FrameImpl frame, String frameSelector) {
|
||||
this(frame, frameSelector, null);
|
||||
}
|
||||
|
||||
public LocatorImpl(FrameImpl frame, String selector, LocatorOptions options) {
|
||||
this.frame = frame;
|
||||
if (options != null) {
|
||||
@@ -187,6 +207,11 @@ class LocatorImpl implements Locator {
|
||||
return frame.querySelectorAll(selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrameLocator contentFrame() {
|
||||
return new FrameLocatorImpl(frame, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(String expression, Object arg, EvaluateOptions options) {
|
||||
return withElement((h, o) -> h.evaluate(expression, arg), options);
|
||||
@@ -278,12 +303,12 @@ class LocatorImpl implements Locator {
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(String testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, frame.connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator getByTestId(Pattern testId) {
|
||||
return locator(getByTestIdSelector(testId));
|
||||
return locator(getByTestIdSelector(testId, frame.connection.playwright));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.Locator;
|
||||
@@ -9,12 +25,6 @@ import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
|
||||
|
||||
public class LocatorUtils {
|
||||
private static volatile String testIdAttributeName = "data-testid";;
|
||||
|
||||
static void setTestIdAttributeName(String name) {
|
||||
testIdAttributeName = name;
|
||||
}
|
||||
|
||||
static String getByTextSelector(Object text, Locator.GetByTextOptions options) {
|
||||
boolean exact = options != null && options.exact != null && options.exact;
|
||||
return "internal:text=" + escapeForTextSelector(text, exact);
|
||||
@@ -29,7 +39,8 @@ public class LocatorUtils {
|
||||
return "internal:attr=[" + attrName + "=" + escapeForAttributeSelector(value, exact) + "]";
|
||||
}
|
||||
|
||||
static String getByTestIdSelector(Object testId) {
|
||||
static String getByTestIdSelector(Object testId, PlaywrightImpl playwright) {
|
||||
String testIdAttributeName = ((SharedSelectors) playwright.selectors()).testIdAttributeName;
|
||||
return getByAttributeTextSelector(testIdAttributeName, testId, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
private ViewportSize viewport;
|
||||
private final Router routes = new Router();
|
||||
private final Set<FrameImpl> frames = new LinkedHashSet<>();
|
||||
private final Map<Integer, Runnable> locatorHandlers = new HashMap<>();
|
||||
|
||||
private static final Map<EventType, String> eventSubscriptions() {
|
||||
Map<EventType, String> result = new HashMap<>();
|
||||
result.put(EventType.CONSOLE, "console");
|
||||
@@ -170,6 +172,9 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
frame.parentFrame.childFrames.remove(frame);
|
||||
}
|
||||
listeners.notify(EventType.FRAMEDETACHED, frame);
|
||||
} else if ("locatorHandlerTriggered".equals(event)) {
|
||||
int uid = params.get("uid").getAsInt();
|
||||
onLocatorHandlerTriggered(uid);
|
||||
} else if ("route".equals(event)) {
|
||||
RouteImpl route = connection.getExistingObject(params.getAsJsonObject("route").get("guid").getAsString());
|
||||
route.browserContext = browserContext;
|
||||
@@ -523,6 +528,34 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
return withLogging("Page.querySelectorAll", () -> mainFrame.querySelectorAllImpl(selector));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLocatorHandler(Locator locator, Runnable handler) {
|
||||
LocatorImpl locatorImpl = (LocatorImpl) locator;
|
||||
if (locatorImpl.frame != mainFrame) {
|
||||
throw new PlaywrightException("Locator must belong to the main frame of this page");
|
||||
}
|
||||
withLogging("Page.addLocatorHandler", () -> {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("selector", locatorImpl.selector);
|
||||
JsonObject json = (JsonObject) sendMessage("registerLocatorHandler", params);
|
||||
int uid = json.get("uid").getAsInt();
|
||||
locatorHandlers.put(uid, handler);
|
||||
});
|
||||
}
|
||||
|
||||
private void onLocatorHandlerTriggered(int uid) {
|
||||
try {
|
||||
Runnable handler = locatorHandlers.get(uid);
|
||||
if (handler != null) {
|
||||
handler.run();
|
||||
}
|
||||
} finally {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("uid", uid);
|
||||
sendMessageAsync("resolveLocatorHandlerNoReply", params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evalOnSelector(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
||||
return withLogging("Page.evalOnSelector", () -> mainFrame.evalOnSelectorImpl(
|
||||
@@ -544,7 +577,8 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
withLogging("Page.addInitScript", () -> {
|
||||
try {
|
||||
byte[] bytes = readAllBytes(path);
|
||||
addInitScriptImpl(new String(bytes, UTF_8));
|
||||
String script = addSourceUrlToScript(new String(bytes, UTF_8), path);
|
||||
addInitScriptImpl(script);
|
||||
} catch (IOException e) {
|
||||
throw new PlaywrightException("Failed to read script from file", e);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.microsoft.playwright.impl;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.microsoft.playwright.APIRequest;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
@@ -89,6 +90,10 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
|
||||
sharedSelectors.removeChannel(selectors);
|
||||
}
|
||||
|
||||
public JsonArray deviceDescriptors() {
|
||||
return connection.localUtils.deviceDescriptors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserTypeImpl chromium() {
|
||||
return chromium;
|
||||
|
||||
@@ -17,22 +17,16 @@
|
||||
package com.microsoft.playwright.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
import com.microsoft.playwright.Selectors;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
class SelectorsImpl extends ChannelOwner {
|
||||
SelectorsImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
|
||||
super(parent, type, guid, initializer);
|
||||
}
|
||||
|
||||
void registerImpl(String name, String script, Selectors.RegisterOptions options) {
|
||||
void register(String name, String script, Selectors.RegisterOptions options) {
|
||||
if (options == null) {
|
||||
options = new Selectors.RegisterOptions();
|
||||
}
|
||||
@@ -41,4 +35,10 @@ class SelectorsImpl extends ChannelOwner {
|
||||
params.addProperty("source", script);
|
||||
sendMessage("register", params);
|
||||
}
|
||||
|
||||
void setTestIdAttributeName(String name) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("testIdAttributeName", name);
|
||||
sendMessageAsync("setTestIdAttributeName", params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.microsoft.playwright.impl.LocatorUtils.setTestIdAttributeName;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
public class SharedSelectors extends LoggingSupport implements Selectors {
|
||||
private final List<SelectorsImpl> channels = new ArrayList<>();
|
||||
private final List<Registration> registrations = new ArrayList<>();
|
||||
|
||||
String testIdAttributeName = "data-testid";
|
||||
|
||||
private static class Registration {
|
||||
final String name;
|
||||
final String script;
|
||||
@@ -64,12 +65,22 @@ public class SharedSelectors extends LoggingSupport implements Selectors {
|
||||
|
||||
@Override
|
||||
public void setTestIdAttribute(String attributeName) {
|
||||
// TODO: set it per playwright insttance
|
||||
setTestIdAttributeName(attributeName);
|
||||
if (attributeName == null) {
|
||||
throw new PlaywrightException("Test id attribute cannot be null");
|
||||
}
|
||||
testIdAttributeName = attributeName;
|
||||
channels.forEach(channel -> channel.setTestIdAttributeName(testIdAttributeName));
|
||||
}
|
||||
|
||||
void addChannel(SelectorsImpl channel) {
|
||||
registrations.forEach(r -> channel.registerImpl(r.name, r.script, r.options));
|
||||
registrations.forEach(r -> {
|
||||
try {
|
||||
channel.register(r.name, r.script, r.options);
|
||||
} catch (PlaywrightException e) {
|
||||
// This should not fail except for connection closure, but just in case we catch.
|
||||
}
|
||||
channel.setTestIdAttributeName(testIdAttributeName);
|
||||
});
|
||||
channels.add(channel);
|
||||
}
|
||||
|
||||
@@ -78,7 +89,7 @@ public class SharedSelectors extends LoggingSupport implements Selectors {
|
||||
}
|
||||
|
||||
private void registerImpl(String name, String script, RegisterOptions options) {
|
||||
channels.forEach(impl -> impl.registerImpl(name, script, options));
|
||||
channels.forEach(impl -> impl.register(name, script, options));
|
||||
registrations.add(new Registration(name, script, options));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public class TargetClosedError extends PlaywrightException {
|
||||
}
|
||||
|
||||
public TargetClosedError(String message) {
|
||||
super(message != null ? message : "Target page, context or browser has been closed");
|
||||
this(message, null);
|
||||
}
|
||||
|
||||
public TargetClosedError(String message, Throwable cause) {
|
||||
super(message != null ? message : "Target page, context or browser has been closed", cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@@ -341,4 +341,8 @@ public class Utils {
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
static String addSourceUrlToScript(String source, Path path) {
|
||||
return source + "\n//# sourceURL=" + path.toString().replace("\n", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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 java.util.function.BooleanSupplier;
|
||||
|
||||
@@ -50,6 +50,8 @@ class WaitableResult<T> implements Waitable<T> {
|
||||
if (exception != null) {
|
||||
if (exception instanceof TimeoutError) {
|
||||
throw new TimeoutError(exception.getMessage(), exception);
|
||||
} if (exception instanceof TargetClosedError) {
|
||||
throw new TargetClosedError(exception.getMessage(), exception);
|
||||
}
|
||||
throw new PlaywrightException(exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.WebError;
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.APIRequest;
|
||||
import com.microsoft.playwright.APIRequestContext;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.impl.Utils;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.isParameterSupported;
|
||||
|
||||
public class APIRequestContextExtension implements ParameterResolver, BeforeEachCallback, AfterAllCallback {
|
||||
private static final ThreadLocal<APIRequestContext> threadLocalAPIRequestContext = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) {
|
||||
threadLocalAPIRequestContext.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
threadLocalAPIRequestContext.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, APIRequestContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateAPIRequestContext(extensionContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the APIRequestContext that belongs to the current test. Will be created if it doesn't already exist.
|
||||
* <strong>NOTE:</strong> this method is subject to change.
|
||||
* @param extensionContext the context in which the current test or container is being executed.
|
||||
* @return The APIRequestContext that belongs to the current test.
|
||||
*/
|
||||
public static APIRequestContext getOrCreateAPIRequestContext(ExtensionContext extensionContext) {
|
||||
APIRequestContext apiRequestContext = threadLocalAPIRequestContext.get();
|
||||
if (apiRequestContext != null) {
|
||||
return apiRequestContext;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
apiRequestContext = playwright.request().newContext(getContextOptions(options));
|
||||
threadLocalAPIRequestContext.set(apiRequestContext);
|
||||
return apiRequestContext;
|
||||
}
|
||||
|
||||
private static APIRequest.NewContextOptions getContextOptions(Options options) {
|
||||
APIRequest.NewContextOptions contextOptions = Utils.clone(options.apiRequestOptions);
|
||||
if(contextOptions == null) {
|
||||
contextOptions = new APIRequest.NewContextOptions();
|
||||
}
|
||||
|
||||
if(options.ignoreHTTPSErrors != null) {
|
||||
contextOptions.ignoreHTTPSErrors = options.ignoreHTTPSErrors;
|
||||
}
|
||||
return contextOptions;
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserContext;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
import com.microsoft.playwright.impl.Utils;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
|
||||
|
||||
public class BrowserContextExtension implements ParameterResolver, AfterEachCallback {
|
||||
private static final ThreadLocal<BrowserContext> threadLocalBrowserContext = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext extensionContext) {
|
||||
BrowserContext browserContext = threadLocalBrowserContext.get();
|
||||
threadLocalBrowserContext.remove();
|
||||
if (browserContext != null) {
|
||||
browserContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return !isClassHook(extensionContext) && isParameterSupported(parameterContext, extensionContext, BrowserContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateBrowserContext(extensionContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BrowserContext that belongs to the current test. Will be created if it doesn't already exist.
|
||||
* <strong>NOTE:</strong> this method is subject to change.
|
||||
* @param extensionContext the context in which the current test or container is being executed.
|
||||
* @return The BrowserContext that belongs to the current test.
|
||||
*/
|
||||
public static BrowserContext getOrCreateBrowserContext(ExtensionContext extensionContext) {
|
||||
BrowserContext browserContext = threadLocalBrowserContext.get();
|
||||
if (browserContext != null) {
|
||||
return browserContext;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
setTestIdAttribute(playwright, options);
|
||||
Browser browser = BrowserExtension.getOrCreateBrowser(extensionContext);
|
||||
Browser.NewContextOptions contextOptions = getContextOptions(playwright, options);
|
||||
browserContext = browser.newContext(contextOptions);
|
||||
threadLocalBrowserContext.set(browserContext);
|
||||
return browserContext;
|
||||
}
|
||||
|
||||
private static Browser.NewContextOptions getContextOptions(Playwright playwright, Options options) {
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.contextOptions);
|
||||
if (contextOptions == null) {
|
||||
contextOptions = new Browser.NewContextOptions();
|
||||
}
|
||||
|
||||
if (options.baseUrl != null) {
|
||||
contextOptions.setBaseURL(options.baseUrl);
|
||||
}
|
||||
|
||||
if (options.deviceName != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.deviceName);
|
||||
if (deviceDescriptor == null) {
|
||||
throw new PlaywrightException("Unknown device name: " + options.deviceName);
|
||||
}
|
||||
contextOptions.userAgent = deviceDescriptor.userAgent;
|
||||
if (deviceDescriptor.viewport != null) {
|
||||
contextOptions.setViewportSize(deviceDescriptor.viewport.width, deviceDescriptor.viewport.height);
|
||||
}
|
||||
contextOptions.deviceScaleFactor = deviceDescriptor.deviceScaleFactor;
|
||||
contextOptions.isMobile = deviceDescriptor.isMobile;
|
||||
contextOptions.hasTouch = deviceDescriptor.hasTouch;
|
||||
}
|
||||
|
||||
if(options.ignoreHTTPSErrors != null) {
|
||||
contextOptions.setIgnoreHTTPSErrors(options.ignoreHTTPSErrors);
|
||||
}
|
||||
|
||||
return contextOptions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
import com.microsoft.playwright.impl.Utils;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
|
||||
|
||||
public class BrowserExtension implements ParameterResolver, AfterAllCallback {
|
||||
private static final ThreadLocal<Browser> threadLocalBrowser = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
Browser browser = threadLocalBrowser.get();
|
||||
threadLocalBrowser.remove();
|
||||
if (browser != null) {
|
||||
browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, Browser.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateBrowser(extensionContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Browser that belongs to the current test. Will be created if it doesn't already exist.
|
||||
* <strong>NOTE:</strong> this method is subject to change.
|
||||
* @param extensionContext the context in which the current test or container is being executed.
|
||||
* @return The Browser that belongs to the current test.
|
||||
*/
|
||||
public static Browser getOrCreateBrowser(ExtensionContext extensionContext) {
|
||||
Browser browser = threadLocalBrowser.get();
|
||||
if (browser != null) {
|
||||
return browser;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
BrowserType.LaunchOptions launchOptions = getLaunchOptions(options);
|
||||
|
||||
BrowserType browserType = playwright.chromium();
|
||||
if (options.browserName != null) {
|
||||
browserType = getBrowserTypeForName(playwright, options.browserName);
|
||||
} else if (options.deviceName != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.deviceName);
|
||||
if (deviceDescriptor != null && deviceDescriptor.defaultBrowserType != null) {
|
||||
browserType = getBrowserTypeForName(playwright, deviceDescriptor.defaultBrowserType);
|
||||
}
|
||||
}
|
||||
browser = browserType.launch(launchOptions);
|
||||
|
||||
threadLocalBrowser.set(browser);
|
||||
return browser;
|
||||
}
|
||||
|
||||
private static BrowserType getBrowserTypeForName(Playwright playwright, String name) {
|
||||
switch (name) {
|
||||
case "webkit":
|
||||
return playwright.webkit();
|
||||
case "firefox":
|
||||
return playwright.firefox();
|
||||
case "chromium":
|
||||
return playwright.chromium();
|
||||
default:
|
||||
throw new PlaywrightException("Invalid browser name.");
|
||||
}
|
||||
}
|
||||
|
||||
private static BrowserType.LaunchOptions getLaunchOptions(Options options) {
|
||||
BrowserType.LaunchOptions launchOptions = Utils.clone(options.launchOptions);
|
||||
if (launchOptions == null) {
|
||||
launchOptions = new BrowserType.LaunchOptions();
|
||||
}
|
||||
|
||||
if (options.headless != null) {
|
||||
launchOptions.setHeadless(options.headless);
|
||||
}
|
||||
|
||||
if (options.channel != null) {
|
||||
launchOptions.setChannel(options.channel);
|
||||
}
|
||||
|
||||
return launchOptions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.impl.junit;
|
||||
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import com.microsoft.playwright.junit.OptionsFactory;
|
||||
|
||||
public class DefaultOptions implements OptionsFactory {
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
return new Options();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.impl.PlaywrightImpl;
|
||||
import com.microsoft.playwright.options.ViewportSize;
|
||||
|
||||
class DeviceDescriptor {
|
||||
public String userAgent;
|
||||
public ViewportSize viewport;
|
||||
public Double deviceScaleFactor;
|
||||
public Boolean isMobile;
|
||||
public Boolean hasTouch;
|
||||
public String defaultBrowserType;
|
||||
|
||||
static DeviceDescriptor findByName(Playwright playwright, String name) {
|
||||
JsonArray devices = ((PlaywrightImpl) playwright).deviceDescriptors();
|
||||
JsonObject descriptor = null;
|
||||
for (JsonElement item : devices) {
|
||||
if (name.equals(item.getAsJsonObject().get("name").getAsString())) {
|
||||
descriptor = item.getAsJsonObject().getAsJsonObject("descriptor");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
}
|
||||
return new Gson().fromJson(descriptor, DeviceDescriptor.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.impl.junit;
|
||||
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import com.microsoft.playwright.junit.UsePlaywright;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.platform.commons.support.AnnotationSupport;
|
||||
|
||||
import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation;
|
||||
|
||||
class ExtensionUtils {
|
||||
static boolean hasUsePlaywrightAnnotation(ExtensionContext extensionContext) {
|
||||
Class<?> outerClass = getOuterClass(extensionContext.getRequiredTestClass());
|
||||
return AnnotationSupport.isAnnotated(outerClass, UsePlaywright.class);
|
||||
}
|
||||
|
||||
static UsePlaywright getUsePlaywrightAnnotation(ExtensionContext extensionContext) {
|
||||
Class<?> topLevelClass = getOuterClass(extensionContext.getRequiredTestClass());
|
||||
return findAnnotation(topLevelClass, UsePlaywright.class).get();
|
||||
}
|
||||
|
||||
static boolean isClassHook(ExtensionContext extensionContext) {
|
||||
return !extensionContext.getTestMethod().isPresent();
|
||||
}
|
||||
|
||||
static boolean isParameterSupported(ParameterContext parameterContext, ExtensionContext extensionContext, Class<?> subject) {
|
||||
if (!hasUsePlaywrightAnnotation(extensionContext)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> clazz = parameterContext.getParameter().getType();
|
||||
return subject.equals(clazz);
|
||||
}
|
||||
|
||||
static void setTestIdAttribute(Playwright playwright, Options options) {
|
||||
String testIdAttribute = options.testIdAttribute == null ? "data-testid" : options.testIdAttribute;
|
||||
playwright.selectors().setTestIdAttribute(testIdAttribute);
|
||||
}
|
||||
|
||||
private static Class<?> getOuterClass(Class<?> clazz) {
|
||||
if (clazz.getDeclaringClass() == null) {
|
||||
return clazz;
|
||||
} else {
|
||||
return getOuterClass(clazz.getDeclaringClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-3
@@ -1,4 +1,20 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
@@ -6,7 +22,7 @@ import com.microsoft.playwright.junit.UsePlaywright;
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.getUsePlaywrightAnnotation;
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
|
||||
|
||||
public class OptionsExtension implements AfterAllCallback {
|
||||
private static final ThreadLocal<Options> threadLocalOptions = new ThreadLocal<>();
|
||||
@@ -24,7 +40,7 @@ public class OptionsExtension implements AfterAllCallback {
|
||||
|
||||
UsePlaywright usePlaywrightAnnotation = getUsePlaywrightAnnotation(extensionContext);
|
||||
try {
|
||||
options = usePlaywrightAnnotation.options().newInstance();
|
||||
options = usePlaywrightAnnotation.value().newInstance().getOptions();
|
||||
threadLocalOptions.set(options);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new PlaywrightException("Failed to create options", e);
|
||||
+25
-4
@@ -1,11 +1,26 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.BrowserContext;
|
||||
import com.microsoft.playwright.Page;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isClassHook;
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
|
||||
|
||||
public class PageExtension implements ParameterResolver, AfterEachCallback {
|
||||
private static final ThreadLocal<Page> threadLocalPage = new ThreadLocal<>();
|
||||
@@ -29,7 +44,13 @@ public class PageExtension implements ParameterResolver, AfterEachCallback {
|
||||
return getOrCreatePage(extensionContext);
|
||||
}
|
||||
|
||||
static Page getOrCreatePage(ExtensionContext extensionContext) {
|
||||
/**
|
||||
* Returns the Page that belongs to the current test. Will be created if it doesn't already exist.
|
||||
* <strong>NOTE:</strong> this method is subject to change.
|
||||
* @param extensionContext the context in which the current test or container is being executed.
|
||||
* @return The Page that belongs to the current test.
|
||||
*/
|
||||
public static Page getOrCreatePage(ExtensionContext extensionContext) {
|
||||
Page page = threadLocalPage.get();
|
||||
if (page != null) {
|
||||
return page;
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
|
||||
|
||||
public class PlaywrightExtension implements ParameterResolver {
|
||||
private static final ThreadLocal<Playwright> threadLocalPlaywright = new ThreadLocal<>();
|
||||
private static final ExtensionContext.Namespace namespace = ExtensionContext.Namespace.create(PlaywrightExtension.class);
|
||||
|
||||
// There should be at most one instance of PlaywrightRegistry per test run, it keeps
|
||||
// track of all created Playwright instances and calls `close()` on each of them after
|
||||
// the tests finished.
|
||||
static class PlaywrightRegistry implements ExtensionContext.Store.CloseableResource {
|
||||
private final List<Playwright> playwrightList = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
static synchronized PlaywrightRegistry getOrCreateFor(ExtensionContext extensionContext) {
|
||||
ExtensionContext.Store rootStore = extensionContext.getRoot().getStore(namespace);
|
||||
PlaywrightRegistry instance = (PlaywrightRegistry) rootStore.get(PlaywrightRegistry.class);
|
||||
if (instance == null) {
|
||||
instance = new PlaywrightRegistry();
|
||||
rootStore.put(PlaywrightRegistry.class, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
Playwright createPlaywright(Playwright.CreateOptions options) {
|
||||
Playwright playwright = Playwright.create(options);
|
||||
playwrightList.add(playwright);
|
||||
return playwright;
|
||||
}
|
||||
|
||||
|
||||
// This is a workaround for JUnit's lack of an "AfterTestRun" hook
|
||||
// This will be called once after all tests have completed.
|
||||
@Override
|
||||
public void close() throws Throwable {
|
||||
for (Playwright playwright : playwrightList) {
|
||||
playwright.close();
|
||||
}
|
||||
playwrightList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, Playwright.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreatePlaywright(extensionContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Playwright that belongs to the current test. Will be created if it doesn't already exist.
|
||||
* <strong>NOTE:</strong> this method is subject to change.
|
||||
* @param extensionContext the context in which the current test or container is being executed.
|
||||
* @return The Playwright that belongs to the current test.
|
||||
*/
|
||||
public static Playwright getOrCreatePlaywright(ExtensionContext extensionContext) {
|
||||
Playwright playwright = threadLocalPlaywright.get();
|
||||
if (playwright != null) {
|
||||
return playwright;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
PlaywrightRegistry registry = PlaywrightRegistry.getOrCreateFor(extensionContext);
|
||||
playwright = registry.createPlaywright(options.playwrightCreateOptions);
|
||||
threadLocalPlaywright.set(playwright);
|
||||
|
||||
setTestIdAttribute(playwright, options);
|
||||
return playwright;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,87 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
import com.microsoft.playwright.APIRequest;
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.options.ViewportSize;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* <strong>NOTE:</strong> this API is experimental and is subject to changes.
|
||||
*
|
||||
* <p> Instances of this class are expected to be created by custom {@link OptionsFactory}
|
||||
* implementations. Implement custom factories to provide custom Playwright configurations.
|
||||
*
|
||||
* <p> For more details and usage examples see our
|
||||
* <a href="https://playwright.dev/java/docs/junit">JUnit guide</a>.
|
||||
*/
|
||||
public class Options {
|
||||
public String baseUrl;
|
||||
public Path storageStatePath;
|
||||
public ViewportSize viewportSize;
|
||||
public String channel;
|
||||
public Boolean headless;
|
||||
public String browserName = "chromium";
|
||||
public String browserName;
|
||||
public String deviceName;
|
||||
// Custom attribute to be used in page.getByTestId(). data-testid is used by default.
|
||||
public String testIdAttribute;
|
||||
public Boolean ignoreHTTPSErrors;
|
||||
public BrowserType.LaunchOptions launchOptions;
|
||||
public Browser.NewContextOptions contextOption;
|
||||
public Browser.NewContextOptions contextOptions;
|
||||
public APIRequest.NewContextOptions apiRequestOptions;
|
||||
public Playwright.CreateOptions playwrightCreateOptions;
|
||||
|
||||
public Playwright.CreateOptions getPlaywrightCreateOptions() {
|
||||
return playwrightCreateOptions;
|
||||
}
|
||||
|
||||
public Options setPlaywrightCreateOptions(Playwright.CreateOptions playwrightCreateOptions) {
|
||||
this.playwrightCreateOptions = playwrightCreateOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BrowserType.LaunchOptions getLaunchOptions() {
|
||||
return launchOptions;
|
||||
}
|
||||
|
||||
public Options setLaunchOptions(BrowserType.LaunchOptions launchOptions) {
|
||||
this.launchOptions = launchOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Browser.NewContextOptions getContextOption() {
|
||||
return contextOption;
|
||||
}
|
||||
|
||||
public Options setContextOption(Browser.NewContextOptions contextOption) {
|
||||
this.contextOption = contextOption;
|
||||
public Options setContextOptions(Browser.NewContextOptions contextOptions) {
|
||||
this.contextOptions = contextOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public APIRequest.NewContextOptions getApiRequestOptions() {
|
||||
return apiRequestOptions;
|
||||
}
|
||||
|
||||
public Options setApiRequestOptions(APIRequest.NewContextOptions apiRequestOptions) {
|
||||
this.apiRequestOptions = apiRequestOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public Options setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Path getStorageStatePath() {
|
||||
return storageStatePath;
|
||||
}
|
||||
|
||||
public Options setStorageStatePath(Path storageStatePath) {
|
||||
this.storageStatePath = storageStatePath;
|
||||
public Options setTestIdAttribute(String name) {
|
||||
this.testIdAttribute = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBrowserName() {
|
||||
return browserName;
|
||||
}
|
||||
|
||||
public Options setBrowserName(String browserName) {
|
||||
this.browserName = browserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
public Options setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Options setChannel(String channel) {
|
||||
@@ -92,21 +89,13 @@ public class Options {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean isHeadless() {
|
||||
return headless;
|
||||
}
|
||||
|
||||
public Options setHeadless(Boolean headless) {
|
||||
this.headless = headless;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ViewportSize getViewportSize() {
|
||||
return viewportSize;
|
||||
}
|
||||
|
||||
public Options setViewportSize(ViewportSize viewportSize) {
|
||||
this.viewportSize = viewportSize;
|
||||
public Options setIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) {
|
||||
this.ignoreHTTPSErrors = ignoreHTTPSErrors;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.junit;
|
||||
|
||||
/**
|
||||
* <strong>NOTE:</strong> this API is experimental and is subject to changes.
|
||||
*
|
||||
* <p> Implement this interface to pass custom options to {@link UsePlaywright}
|
||||
* annotation.
|
||||
*
|
||||
* <p> An example of implementing {@code @OptionsFactory}:
|
||||
* <pre>{@code
|
||||
* import com.microsoft.playwright.junit.Options;
|
||||
* import com.microsoft.playwright.junit.OptionsFactory;
|
||||
* import com.microsoft.playwright.junit.UsePlaywright;
|
||||
*
|
||||
* @UsePlaywright(MyTest.CustomOptions.class)
|
||||
* public class MyTest {
|
||||
*
|
||||
* public static class CustomOptions implements OptionsFactory {
|
||||
* @Override
|
||||
* public Options getOptions() {
|
||||
* return new Options()
|
||||
* .setHeadless(false)
|
||||
* .setContextOption(new Browser.NewContextOptions()
|
||||
* .setBaseURL("https://github.com"))
|
||||
* .setApiRequestOptions(new APIRequest.NewContextOptions()
|
||||
* .setBaseURL("https://playwright.dev"));
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @Test
|
||||
* public void testWithCustomOptions(Page page, APIRequestContext request) {
|
||||
* page.navigate("/");
|
||||
* assertThat(page).hasURL(Pattern.compile("github"));
|
||||
*
|
||||
* APIResponse response = request.get("/");
|
||||
* assertTrue(response.text().contains("Playwright"));
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p>For more details and usage examples see our
|
||||
* <a href="https://playwright.dev/java/docs/junit">JUnit guide</a>.
|
||||
*/
|
||||
public interface OptionsFactory {
|
||||
Options getOptions();
|
||||
}
|
||||
@@ -1,17 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.junit;
|
||||
|
||||
import com.microsoft.playwright.junit.impl.*;
|
||||
import com.microsoft.playwright.impl.junit.*;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <strong>NOTE:</strong> this API is experimental and is subject to changes.
|
||||
*
|
||||
* Use {@code @UsePlaywright} annotation to automatically manage Playwright objects
|
||||
* used in your test. Custom configuration can be provided by implementing
|
||||
* {@link OptionsFactory} and passing the class as a parameter.
|
||||
*
|
||||
* <p> When a test class is annotated with {@code @UsePlaywright} each test method can
|
||||
* use any of the following arguments that will be automatically created at run time:
|
||||
* <ul>
|
||||
* <li> {@link com.microsoft.playwright.Page Page page}</li>
|
||||
* <li> {@link com.microsoft.playwright.BrowserContext BrowserContext context}</li>
|
||||
* <li> {@link com.microsoft.playwright.Browser Browser browser}</li>
|
||||
* <li> {@link com.microsoft.playwright.APIRequestContext APIRequestContext request}</li>
|
||||
* <li> {@link com.microsoft.playwright.Playwright Playwright playwright}</li>
|
||||
* </ul>
|
||||
* {@code Page} and {@code BrowserContext} are created before each test and closed
|
||||
* after the test has finished. {@code Browser} and {@code Playwright} are reused
|
||||
* between tests for better efficiency.
|
||||
*
|
||||
* <p> An example of using {@code @UsePlaywright} annotation:
|
||||
* <pre>{@code
|
||||
* import com.microsoft.playwright.Browser;
|
||||
* import com.microsoft.playwright.BrowserContext;
|
||||
* import com.microsoft.playwright.Page;
|
||||
* import org.junit.jupiter.api.Test;
|
||||
*
|
||||
* import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
|
||||
* import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
* import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
*
|
||||
* @UsePlaywright
|
||||
* public class TestExample {
|
||||
* @Test
|
||||
* void shouldProvidePage(Page page) {
|
||||
* page.navigate("https://playwright.dev");
|
||||
* assertThat(page).hasURL("https://playwright.dev/");
|
||||
* }
|
||||
*
|
||||
* @Test
|
||||
* void shouldResolvePlaywrightObjects(Page page, BrowserContext context, Browser browser) {
|
||||
* assertEquals(context, page.context());
|
||||
* assertEquals(browser, context.browser());
|
||||
* assertNotNull(browser.version());
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* <p> For more details and usage examples see our
|
||||
* <a href="https://playwright.dev/java/docs/junit">JUnit guide</a>.
|
||||
*/
|
||||
@ExtendWith({OptionsExtension.class, PlaywrightExtension.class, BrowserExtension.class, BrowserContextExtension.class,
|
||||
PageExtension.class, APIRequestContextExtension.class})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Inherited
|
||||
public @interface UsePlaywright {
|
||||
Class<? extends Options> options() default Options.class;
|
||||
Class<? extends OptionsFactory> value() default DefaultOptions.class;
|
||||
}
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
|
||||
import com.microsoft.playwright.APIRequestContext;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
|
||||
|
||||
public class APIRequestContextExtension implements ParameterResolver, BeforeEachCallback, AfterAllCallback {
|
||||
private static final ThreadLocal<APIRequestContext> threadLocalAPIRequestContext = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext extensionContext) {
|
||||
threadLocalAPIRequestContext.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
threadLocalAPIRequestContext.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, APIRequestContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateAPIRequestContext(extensionContext);
|
||||
}
|
||||
|
||||
static APIRequestContext getOrCreateAPIRequestContext(ExtensionContext extensionContext) {
|
||||
APIRequestContext apiRequestContext = threadLocalAPIRequestContext.get();
|
||||
if (apiRequestContext != null) {
|
||||
return apiRequestContext;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
apiRequestContext = playwright.request().newContext(options.getApiRequestOptions());
|
||||
threadLocalAPIRequestContext.set(apiRequestContext);
|
||||
return apiRequestContext;
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserContext;
|
||||
import com.microsoft.playwright.impl.Utils;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isClassHook;
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
|
||||
|
||||
public class BrowserContextExtension implements ParameterResolver, AfterEachCallback {
|
||||
private static final ThreadLocal<BrowserContext> threadLocalBrowserContext = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext extensionContext) {
|
||||
BrowserContext browserContext = threadLocalBrowserContext.get();
|
||||
threadLocalBrowserContext.remove();
|
||||
if (browserContext != null) {
|
||||
browserContext.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return !isClassHook(extensionContext) && isParameterSupported(parameterContext, extensionContext, BrowserContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateBrowserContext(extensionContext);
|
||||
}
|
||||
|
||||
static BrowserContext getOrCreateBrowserContext(ExtensionContext extensionContext) {
|
||||
BrowserContext browserContext = threadLocalBrowserContext.get();
|
||||
if (browserContext != null) {
|
||||
return browserContext;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Browser browser = BrowserExtension.getOrCreateBrowser(extensionContext);
|
||||
Browser.NewContextOptions contextOptions = getContextOptions(options);
|
||||
browserContext = browser.newContext(contextOptions);
|
||||
threadLocalBrowserContext.set(browserContext);
|
||||
return browserContext;
|
||||
}
|
||||
|
||||
private static Browser.NewContextOptions getContextOptions(Options options) {
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.getContextOption());
|
||||
if (contextOptions == null) {
|
||||
contextOptions = new Browser.NewContextOptions();
|
||||
}
|
||||
|
||||
if (options.getBaseUrl() != null) {
|
||||
contextOptions.setBaseURL(options.getBaseUrl());
|
||||
}
|
||||
|
||||
if (options.getStorageStatePath() != null) {
|
||||
contextOptions.setStorageStatePath(options.getStorageStatePath());
|
||||
}
|
||||
|
||||
if (options.getViewportSize() != null) {
|
||||
contextOptions.setViewportSize(options.getViewportSize());
|
||||
}
|
||||
|
||||
return contextOptions;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.PlaywrightException;
|
||||
import com.microsoft.playwright.impl.Utils;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
|
||||
|
||||
public class BrowserExtension implements ParameterResolver, AfterAllCallback {
|
||||
private static final ThreadLocal<Browser> threadLocalBrowser = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
Browser browser = threadLocalBrowser.get();
|
||||
threadLocalBrowser.remove();
|
||||
if (browser != null) {
|
||||
browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, Browser.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreateBrowser(extensionContext);
|
||||
}
|
||||
|
||||
static Browser getOrCreateBrowser(ExtensionContext extensionContext) {
|
||||
Browser browser = threadLocalBrowser.get();
|
||||
if (browser != null) {
|
||||
return browser;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
BrowserType.LaunchOptions launchOptions = getLaunchOptions(options);
|
||||
|
||||
switch (options.getBrowserName()) {
|
||||
case "webkit":
|
||||
browser = playwright.webkit().launch(launchOptions);
|
||||
break;
|
||||
case "firefox":
|
||||
browser = playwright.firefox().launch(launchOptions);
|
||||
break;
|
||||
case "chromium":
|
||||
browser = playwright.chromium().launch(launchOptions);
|
||||
break;
|
||||
default:
|
||||
throw new PlaywrightException("Invalid browser name.");
|
||||
}
|
||||
|
||||
threadLocalBrowser.set(browser);
|
||||
return browser;
|
||||
}
|
||||
|
||||
private static BrowserType.LaunchOptions getLaunchOptions(Options options) {
|
||||
BrowserType.LaunchOptions launchOptions = Utils.clone(options.getLaunchOptions());
|
||||
if (launchOptions == null) {
|
||||
launchOptions = new BrowserType.LaunchOptions();
|
||||
}
|
||||
|
||||
if (options.isHeadless() != null) {
|
||||
launchOptions.setHeadless(options.isHeadless());
|
||||
}
|
||||
|
||||
if (options.getChannel() != null) {
|
||||
options.setChannel(options.getChannel());
|
||||
}
|
||||
|
||||
return launchOptions;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
|
||||
import com.microsoft.playwright.junit.UsePlaywright;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.jupiter.api.extension.ParameterContext;
|
||||
import org.junit.platform.commons.support.AnnotationSupport;
|
||||
|
||||
import static org.junit.platform.commons.support.AnnotationSupport.findAnnotation;
|
||||
|
||||
class ExtensionUtils {
|
||||
static boolean hasUsePlaywrightAnnotation(ExtensionContext extensionContext) {
|
||||
return AnnotationSupport.isAnnotated(extensionContext.getTestClass(), UsePlaywright.class);
|
||||
}
|
||||
|
||||
static UsePlaywright getUsePlaywrightAnnotation(ExtensionContext extensionContext) {
|
||||
return findAnnotation(extensionContext.getTestClass(), UsePlaywright.class).get();
|
||||
}
|
||||
|
||||
static boolean isClassHook(ExtensionContext extensionContext) {
|
||||
return !extensionContext.getTestMethod().isPresent();
|
||||
}
|
||||
|
||||
static boolean isParameterSupported(ParameterContext parameterContext, ExtensionContext extensionContext, Class<?> subject) {
|
||||
if (!hasUsePlaywrightAnnotation(extensionContext)) {
|
||||
return false;
|
||||
}
|
||||
Class<?> clazz = parameterContext.getParameter().getType();
|
||||
return subject.equals(clazz);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.microsoft.playwright.junit.impl;
|
||||
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.junit.Options;
|
||||
import org.junit.jupiter.api.extension.*;
|
||||
|
||||
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
|
||||
|
||||
public class PlaywrightExtension implements ParameterResolver, AfterAllCallback {
|
||||
private static final ThreadLocal<Playwright> threadLocalPlaywright = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
Playwright playwright = threadLocalPlaywright.get();
|
||||
threadLocalPlaywright.remove();
|
||||
if (playwright != null) {
|
||||
playwright.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return isParameterSupported(parameterContext, extensionContext, Playwright.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
|
||||
return getOrCreatePlaywright(extensionContext);
|
||||
}
|
||||
|
||||
static Playwright getOrCreatePlaywright(ExtensionContext extensionContext) {
|
||||
Playwright playwright = threadLocalPlaywright.get();
|
||||
if (playwright != null) {
|
||||
return playwright;
|
||||
}
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
playwright = Playwright.create(options.getPlaywrightCreateOptions());
|
||||
threadLocalPlaywright.set(playwright);
|
||||
return playwright;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import com.microsoft.playwright.impl.RequestOptionsImpl;
|
||||
* .setData("My data"));
|
||||
* }</pre>
|
||||
*
|
||||
* <p> **Uploading html form data**
|
||||
* <p> <strong>Uploading html form data</strong>
|
||||
*
|
||||
* <p> {@code FormData} class can be used to send a form to the server, by default the request will use {@code
|
||||
* application/x-www-form-urlencoded} encoding:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user