@@ -224,8 +224,7 @@ type BrowserContext interface {
224
224
// - The [Browser.Close] method was called.
225
225
OnClose (fn func (BrowserContext ))
226
226
227
- // Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also
228
- // emitted if the page throws an error or a warning.
227
+ // Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.
229
228
// The arguments passed into `console.log` and the page are available on the [ConsoleMessage] event handler argument.
230
229
OnConsole (fn func (ConsoleMessage ))
231
230
@@ -905,8 +904,8 @@ type ElementHandle interface {
905
904
// Holding down `Shift` will type the text that corresponds to the “key” in the upper case.
906
905
// If “key” is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
907
906
// texts.
908
- // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
909
- // modifier, modifier is pressed and being held while the subsequent key is being pressed.
907
+ // Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When
908
+ // specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
910
909
//
911
910
// Deprecated: Use locator-based [Locator.Press] instead. Read more about [locators].
912
911
//
@@ -1597,8 +1596,8 @@ type Frame interface {
1597
1596
// Holding down `Shift` will type the text that corresponds to the “key” in the upper case.
1598
1597
// If “key” is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
1599
1598
// texts.
1600
- // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
1601
- // modifier, modifier is pressed and being held while the subsequent key is being pressed.
1599
+ // Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When
1600
+ // specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
1602
1601
//
1603
1602
// Deprecated: Use locator-based [Locator.Press] instead. Read more about [locators].
1604
1603
//
@@ -2031,8 +2030,8 @@ type Keyboard interface {
2031
2030
// Holding down `Shift` will type the text that corresponds to the “key” in the upper case.
2032
2031
// If “key” is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
2033
2032
// texts.
2034
- // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
2035
- // modifier, modifier is pressed and being held while the subsequent key is being pressed.
2033
+ // Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When
2034
+ // specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
2036
2035
//
2037
2036
// key: Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
2038
2037
//
@@ -2536,8 +2535,8 @@ type Locator interface {
2536
2535
// Holding down `Shift` will type the text that corresponds to the “key” in the upper case.
2537
2536
// If “key” is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
2538
2537
// texts.
2539
- // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
2540
- // modifier, modifier is pressed and being held while the subsequent key is being pressed.
2538
+ // Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When
2539
+ // specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
2541
2540
//
2542
2541
// key: Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
2543
2542
//
@@ -2870,8 +2869,7 @@ type Page interface {
2870
2869
// Emitted when the page closes.
2871
2870
OnClose (fn func (Page ))
2872
2871
2873
- // Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also
2874
- // emitted if the page throws an error or a warning.
2872
+ // Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.
2875
2873
// The arguments passed into `console.log` are available on the [ConsoleMessage] event handler argument.
2876
2874
OnConsole (fn func (ConsoleMessage ))
2877
2875
@@ -3489,8 +3487,8 @@ type Page interface {
3489
3487
// Holding down `Shift` will type the text that corresponds to the “key” in the upper case.
3490
3488
// If “key” is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
3491
3489
// texts.
3492
- // Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
3493
- // modifier, modifier is pressed and being held while the subsequent key is being pressed.
3490
+ // Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When
3491
+ // specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
3494
3492
//
3495
3493
// Deprecated: Use locator-based [Locator.Press] instead. Read more about [locators].
3496
3494
//
@@ -3523,6 +3521,38 @@ type Page interface {
3523
3521
// [locators]: https://playwright.dev/docs/locators
3524
3522
QuerySelectorAll (selector string ) ([]ElementHandle , error )
3525
3523
3524
+ // When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you
3525
+ // want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time,
3526
+ // making them tricky to handle in automated tests.
3527
+ // This method lets you set up a special function, called a handler, that activates when it detects that overlay is
3528
+ // visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.
3529
+ // Things to keep in mind:
3530
+ // - When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as
3531
+ // a part of your normal test flow, instead of using [Page.AddLocatorHandler].
3532
+ // - Playwright checks for the overlay every time before executing or retrying an action that requires an
3533
+ // [actionability check], or before performing an auto-waiting assertion check. When overlay
3534
+ // is visible, Playwright calls the handler first, and then proceeds with the action/assertion.
3535
+ // - The execution time of the handler counts towards the timeout of the action/assertion that executed the handler.
3536
+ // If your handler takes too long, it might cause timeouts.
3537
+ // - You can register multiple handlers. However, only a single handler will be running at a time. Make sure the
3538
+ // actions within a handler don't depend on another handler.
3539
+ // **NOTE** Running the handler will alter your page state mid-test. For example it will change the currently focused
3540
+ // element and move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on
3541
+ // the focus and mouse state being unchanged. <br /> <br /> For example, consider a test that calls [Locator.Focus]
3542
+ // followed by [Keyboard.Press]. If your handler clicks a button between these two actions, the focused element most
3543
+ // likely will be wrong, and key press will happen on the unexpected element. Use [Locator.Press] instead to avoid
3544
+ // this problem. <br /> <br /> Another example is a series of mouse actions, where [Mouse.Move] is followed by
3545
+ // [Mouse.Down]. Again, when the handler runs between these two actions, the mouse position will be wrong during the
3546
+ // mouse down. Prefer self-contained actions like [Locator.Click] that do not rely on the state being unchanged by a
3547
+ // handler.
3548
+ //
3549
+ // 1. locator: Locator that triggers the handler.
3550
+ // 2. handler: Function that should be run once “locator” appears. This function should get rid of the element that blocks actions
3551
+ // like click.
3552
+ //
3553
+ // [actionability check]: https://playwright.dev/docs/actionability
3554
+ AddLocatorHandler (locator Locator , handler func ()) error
3555
+
3526
3556
// This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the
3527
3557
// main resource response. In case of multiple redirects, the navigation will resolve with the response of the last
3528
3558
// redirect.
0 commit comments