Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/playwright
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.42.0
Choose a base ref
...
head repository: microsoft/playwright
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.42.1
Choose a head ref
  • 10 commits
  • 38 files changed
  • 4 contributors

Commits on Feb 28, 2024

  1. cherry-pick(#29715): fix: point to the right cli program export

    pavelfeldman committed Feb 28, 2024
    Copy the full SHA
    84780b1 View commit details

Commits on Feb 29, 2024

  1. cherry-pick(#29706): fit(ct): remove unused type import (#29709)

    This PR cherry-picks the following commits:
    
    - 772345c
    
    Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
    playwrightmachine and github-actions[bot] authored Feb 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    20db86d View commit details
  2. cherry-pick(#29738): fix(HEAD): revert GET->HEAD migration, net-effec…

    …t was negative
    pavelfeldman committed Feb 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3f6b641 View commit details
  3. cherry-pick(#29748): fix(ct): fix the non-react cli entry points

    pavelfeldman committed Feb 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    56e50a7 View commit details

Commits on Mar 1, 2024

  1. cherry-pick(#29754): chore: remove pw- binaries from ct

    pavelfeldman committed Mar 1, 2024
    Copy the full SHA
    d23fb00 View commit details
  2. cherry-pick(#29744): fix(ct): stop-gap for shared file import

    pavelfeldman committed Mar 1, 2024
    Copy the full SHA
    3a43813 View commit details
  3. cherry-pick(#29766): fix(tsload): fix tsconfig inheritance resolution

    pavelfeldman committed Mar 1, 2024
    Copy the full SHA
    b670506 View commit details
  4. cherry-pick(#29765): Revert "chore(role): cache element list by role (#…

    …29130)"
    
    This reverts commit 1ce3ca2.
    
    Added a regression test.
    
    Fixes #29760.
    dgozman committed Mar 1, 2024
    Copy the full SHA
    a702595 View commit details
  5. cherry-pick(#29770): docs: improve addLocatorHandler docs

    dgozman committed Mar 1, 2024
    Copy the full SHA
    d4ac444 View commit details
  6. chore: mark 1.42.1 (#29774)

    dgozman authored Mar 1, 2024
    Copy the full SHA
    9749f75 View commit details
Showing with 246 additions and 209 deletions.
  1. +10 −8 docs/src/api/class-page.md
  2. +40 −46 package-lock.json
  3. +1 −1 package.json
  4. +2 −2 packages/playwright-browser-chromium/package.json
  5. +2 −2 packages/playwright-browser-firefox/package.json
  6. +2 −2 packages/playwright-browser-webkit/package.json
  7. +1 −1 packages/playwright-chromium/cli.js
  8. +2 −2 packages/playwright-chromium/package.json
  9. +1 −1 packages/playwright-core/package.json
  10. +30 −17 packages/playwright-core/src/server/injected/roleSelectorEngine.ts
  11. +0 −42 packages/playwright-core/src/server/injected/roleUtils.ts
  12. +1 −2 packages/playwright-core/src/utils/network.ts
  13. +26 −23 packages/playwright-core/types/types.d.ts
  14. +3 −3 packages/playwright-ct-core/package.json
  15. +27 −2 packages/playwright-ct-core/src/tsxTransform.ts
  16. +0 −2 packages/playwright-ct-core/types/component.d.ts
  17. +3 −4 packages/playwright-ct-react/package.json
  18. +1 −3 packages/playwright-ct-react17/cli.js
  19. +3 −4 packages/playwright-ct-react17/package.json
  20. +1 −3 packages/playwright-ct-solid/cli.js
  21. +3 −4 packages/playwright-ct-solid/package.json
  22. +1 −3 packages/playwright-ct-svelte/cli.js
  23. +3 −4 packages/playwright-ct-svelte/package.json
  24. +1 −3 packages/playwright-ct-vue/cli.js
  25. +3 −4 packages/playwright-ct-vue/package.json
  26. +1 −3 packages/playwright-ct-vue2/cli.js
  27. +3 −4 packages/playwright-ct-vue2/package.json
  28. +1 −1 packages/playwright-firefox/cli.js
  29. +2 −2 packages/playwright-firefox/package.json
  30. +2 −2 packages/playwright-test/package.json
  31. +1 −1 packages/playwright-webkit/cli.js
  32. +2 −2 packages/playwright-webkit/package.json
  33. +2 −2 packages/playwright/package.json
  34. +7 −3 packages/playwright/src/third_party/tsconfig-loader.ts
  35. +6 −0 tests/installation/playwright-cli-install-should-work.spec.ts
  36. +17 −0 tests/page/selectors-role.spec.ts
  37. +34 −0 tests/playwright-test/playwright.ct-react.spec.ts
  38. +1 −1 tests/playwright-test/web-server.spec.ts
18 changes: 10 additions & 8 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
@@ -3146,27 +3146,29 @@ return value resolves to `[]`.
## async method: Page.addLocatorHandler
* since: v1.42

Sometimes, the web page can show an overlay that obstructs elements behind it and prevents certain actions, like click, from completing. When such an overlay is shown predictably, we recommend dismissing it as a part of your test flow. However, sometimes such an overlay may appear non-deterministically, for example certain cookies consent dialogs behave this way. In this case, [`method: Page.addLocatorHandler`] allows handling an overlay during an action that it would block.
When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making them tricky to handle in automated tests.
This method registers a handler for an overlay that is executed once the locator is visible on the page. The handler should get rid of the overlay so that actions blocked by it can proceed. This is useful for nondeterministic interstitial pages or dialogs, like a cookie consent dialog.
This method lets you set up a special function, called a handler, that activates when it detects that overlay is visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.
Note that execution time of the handler counts towards the timeout of the action/assertion that executed the handler.

You can register multiple handlers. However, only a single handler will be running at a time. Any actions inside a handler must not require another handler to run.
Things to keep in mind:
* When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as a part of your normal test flow, instead of using [`method: Page.addLocatorHandler`].
* Playwright checks for the overlay every time before executing or retrying an action that requires an [actionability check](../actionability.md), or before performing an auto-waiting assertion check. When overlay is visible, Playwright calls the handler first, and then proceeds with the action/assertion.
* The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. If your handler takes too long, it might cause timeouts.
* You can register multiple handlers. However, only a single handler will be running at a time. Make sure the actions within a handler don't depend on another handler.

:::warning
Running the interceptor will alter your page state mid-test. For example it will change the currently focused element and move the mouse. Make sure that the actions that run after the interceptor are self-contained and do not rely on the focus and mouse state.
Running the handler will alter your page state mid-test. For example it will change the currently focused element and move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on the focus and mouse state being unchanged.
<br />
<br />
For example, consider a test that calls [`method: Locator.focus`] followed by [`method: Keyboard.press`]. If your handler clicks a button between these two actions, the focused element most likely will be wrong, and key press will happen on the unexpected element. Use [`method: Locator.press`] instead to avoid this problem.
<br />
<br />
Another example is a series of mouse actions, where [`method: Mouse.move`] is followed by [`method: Mouse.down`]. Again, when the handler runs between these two actions, the mouse position will be wrong during the mouse down. Prefer methods like [`method: Locator.click`] that are self-contained.
Another example is a series of mouse actions, where [`method: Mouse.move`] is followed by [`method: Mouse.down`]. Again, when the handler runs between these two actions, the mouse position will be wrong during the mouse down. Prefer self-contained actions like [`method: Locator.click`] that do not rely on the state being unchanged by a handler.
:::

**Usage**

An example that closes a cookie dialog when it appears:
An example that closes a cookie consent dialog when it appears:

```js
// Setup the handler.
86 changes: 40 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "playwright-internal",
"private": true,
"version": "1.42.0",
"version": "1.42.1",
"description": "A high-level API to automate web browsers",
"repository": {
"type": "git",
4 changes: 2 additions & 2 deletions packages/playwright-browser-chromium/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@playwright/browser-chromium",
"version": "1.42.0",
"version": "1.42.1",
"description": "Playwright package that automatically installs Chromium",
"repository": {
"type": "git",
@@ -27,6 +27,6 @@
"install": "node install.js"
},
"dependencies": {
"playwright-core": "1.42.0"
"playwright-core": "1.42.1"
}
}
4 changes: 2 additions & 2 deletions packages/playwright-browser-firefox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@playwright/browser-firefox",
"version": "1.42.0",
"version": "1.42.1",
"description": "Playwright package that automatically installs Firefox",
"repository": {
"type": "git",
@@ -27,6 +27,6 @@
"install": "node install.js"
},
"dependencies": {
"playwright-core": "1.42.0"
"playwright-core": "1.42.1"
}
}
4 changes: 2 additions & 2 deletions packages/playwright-browser-webkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@playwright/browser-webkit",
"version": "1.42.0",
"version": "1.42.1",
"description": "Playwright package that automatically installs WebKit",
"repository": {
"type": "git",
@@ -27,6 +27,6 @@
"install": "node install.js"
},
"dependencies": {
"playwright-core": "1.42.0"
"playwright-core": "1.42.1"
}
}
2 changes: 1 addition & 1 deletion packages/playwright-chromium/cli.js
Original file line number Diff line number Diff line change
@@ -15,5 +15,5 @@
* limitations under the License.
*/

const { program } = require('playwright-core/lib/program');
const { program } = require('playwright-core/lib/cli/program');
program.parse(process.argv);
4 changes: 2 additions & 2 deletions packages/playwright-chromium/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playwright-chromium",
"version": "1.42.0",
"version": "1.42.1",
"description": "A high-level API to automate Chromium",
"repository": {
"type": "git",
@@ -30,6 +30,6 @@
"install": "node install.js"
},
"dependencies": {
"playwright-core": "1.42.0"
"playwright-core": "1.42.1"
}
}
2 changes: 1 addition & 1 deletion packages/playwright-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playwright-core",
"version": "1.42.0",
"version": "1.42.1",
"description": "A high-level API to automate web browsers",
"repository": {
"type": "git",
Loading