+ page.get_by_text(re.compile(\"^hello$\", re.IGNORECASE))
+ ```
+
+ See also `locator.filter()` that allows to match by another criteria, like an accessible role, and then filter
+ by the text content.
+
+ > NOTE: 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.
+ > NOTE: Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For
+ example, locating by text `\"Log in\"` matches `
`.
Parameters
----------
@@ -9375,7 +9619,7 @@ def get_by_text(
Text to locate the element for.
exact : Union[bool, None]
Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular
- expression.
+ expression. Note that exact match still trims whitespace.
Returns
-------
@@ -9392,7 +9636,7 @@ def get_by_title(
) -> "Locator":
"""Page.get_by_title
- Allows locating elements by their title. For example, this method will find the button by its title \"Submit\":
+ Allows locating elements by their title. For example, this method will find the button by its title \"Place the order\":
```html
@@ -9404,7 +9648,7 @@ def get_by_title(
Text to locate the element for.
exact : Union[bool, None]
Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular
- expression.
+ expression. Note that exact match still trims whitespace.
Returns
-------
@@ -9618,6 +9862,7 @@ async def hover(
] = None,
position: typing.Optional[Position] = None,
timeout: typing.Optional[float] = None,
+ no_wait_after: typing.Optional[bool] = None,
force: typing.Optional[bool] = None,
strict: typing.Optional[bool] = None,
trial: typing.Optional[bool] = None
@@ -9651,6 +9896,10 @@ async def hover(
timeout : Union[float, None]
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
+ no_wait_after : Union[bool, None]
+ Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
+ opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
+ inaccessible pages. Defaults to `false`.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
strict : Union[bool, None]
@@ -9667,6 +9916,7 @@ async def hover(
modifiers=mapping.to_impl(modifiers),
position=position,
timeout=timeout,
+ noWaitAfter=no_wait_after,
force=force,
strict=strict,
trial=trial,
@@ -10255,7 +10505,7 @@ async def main():
Parameters
----------
expression : str
- JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
+ JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
@@ -11743,7 +11993,8 @@ async def route_from_har(
Defaults to abort.
update : Union[bool, None]
- If specified, updates the given HAR with the actual network information instead of serving from file.
+ If specified, updates the given HAR with the actual network information instead of serving from file. The file is
+ written to disk when `browser_context.close()` is called.
"""
return mapping.from_maybe_impl(
@@ -12047,9 +12298,13 @@ async def new_context(
device_scale_factor: typing.Optional[float] = None,
is_mobile: typing.Optional[bool] = None,
has_touch: typing.Optional[bool] = None,
- color_scheme: typing.Optional[Literal["dark", "light", "no-preference"]] = None,
- reduced_motion: typing.Optional[Literal["no-preference", "reduce"]] = None,
- forced_colors: typing.Optional[Literal["active", "none"]] = None,
+ color_scheme: typing.Optional[
+ Literal["dark", "light", "no-preference", "null"]
+ ] = None,
+ reduced_motion: typing.Optional[
+ Literal["no-preference", "null", "reduce"]
+ ] = None,
+ forced_colors: typing.Optional[Literal["active", "none", "null"]] = None,
accept_downloads: typing.Optional[bool] = None,
default_browser_type: typing.Optional[str] = None,
proxy: typing.Optional[ProxySettings] = None,
@@ -12132,15 +12387,17 @@ async def new_context(
in Firefox.
has_touch : Union[bool, None]
Specifies if viewport supports touch events. Defaults to false.
- color_scheme : Union["dark", "light", "no-preference", None]
+ color_scheme : Union["dark", "light", "no-preference", "null", None]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'light'`.
- reduced_motion : Union["no-preference", "reduce", None]
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'light'`.
+ reduced_motion : Union["no-preference", "null", "reduce", None]
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'no-preference'`.
- forced_colors : Union["active", "none", None]
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'no-preference'`.
+ forced_colors : Union["active", "none", "null", None]
Emulates `'forced-colors'` media feature, supported values are `'active'`, `'none'`. See `page.emulate_media()`
- for more details. Defaults to `'none'`.
+ for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'none'`.
accept_downloads : Union[bool, None]
Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
proxy : Union[{server: str, bypass: Union[str, None], username: Union[str, None], password: Union[str, None]}, None]
@@ -12256,9 +12513,13 @@ async def new_page(
device_scale_factor: typing.Optional[float] = None,
is_mobile: typing.Optional[bool] = None,
has_touch: typing.Optional[bool] = None,
- color_scheme: typing.Optional[Literal["dark", "light", "no-preference"]] = None,
- forced_colors: typing.Optional[Literal["active", "none"]] = None,
- reduced_motion: typing.Optional[Literal["no-preference", "reduce"]] = None,
+ color_scheme: typing.Optional[
+ Literal["dark", "light", "no-preference", "null"]
+ ] = None,
+ forced_colors: typing.Optional[Literal["active", "none", "null"]] = None,
+ reduced_motion: typing.Optional[
+ Literal["no-preference", "null", "reduce"]
+ ] = None,
accept_downloads: typing.Optional[bool] = None,
default_browser_type: typing.Optional[str] = None,
proxy: typing.Optional[ProxySettings] = None,
@@ -12327,15 +12588,17 @@ async def new_page(
in Firefox.
has_touch : Union[bool, None]
Specifies if viewport supports touch events. Defaults to false.
- color_scheme : Union["dark", "light", "no-preference", None]
+ color_scheme : Union["dark", "light", "no-preference", "null", None]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'light'`.
- forced_colors : Union["active", "none", None]
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'light'`.
+ forced_colors : Union["active", "none", "null", None]
Emulates `'forced-colors'` media feature, supported values are `'active'`, `'none'`. See `page.emulate_media()`
- for more details. Defaults to `'none'`.
- reduced_motion : Union["no-preference", "reduce", None]
+ for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'none'`.
+ reduced_motion : Union["no-preference", "null", "reduce", None]
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'no-preference'`.
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'no-preference'`.
accept_downloads : Union[bool, None]
Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
proxy : Union[{server: str, bypass: Union[str, None], username: Union[str, None], password: Union[str, None]}, None]
@@ -12719,9 +12982,13 @@ async def launch_persistent_context(
device_scale_factor: typing.Optional[float] = None,
is_mobile: typing.Optional[bool] = None,
has_touch: typing.Optional[bool] = None,
- color_scheme: typing.Optional[Literal["dark", "light", "no-preference"]] = None,
- reduced_motion: typing.Optional[Literal["no-preference", "reduce"]] = None,
- forced_colors: typing.Optional[Literal["active", "none"]] = None,
+ color_scheme: typing.Optional[
+ Literal["dark", "light", "no-preference", "null"]
+ ] = None,
+ reduced_motion: typing.Optional[
+ Literal["no-preference", "null", "reduce"]
+ ] = None,
+ forced_colors: typing.Optional[Literal["active", "none", "null"]] = None,
accept_downloads: typing.Optional[bool] = None,
traces_dir: typing.Optional[typing.Union[str, pathlib.Path]] = None,
chromium_sandbox: typing.Optional[bool] = None,
@@ -12833,15 +13100,17 @@ async def launch_persistent_context(
in Firefox.
has_touch : Union[bool, None]
Specifies if viewport supports touch events. Defaults to false.
- color_scheme : Union["dark", "light", "no-preference", None]
+ color_scheme : Union["dark", "light", "no-preference", "null", None]
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'light'`.
- reduced_motion : Union["no-preference", "reduce", None]
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'light'`.
+ reduced_motion : Union["no-preference", "null", "reduce", None]
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
- `page.emulate_media()` for more details. Defaults to `'no-preference'`.
- forced_colors : Union["active", "none", None]
+ `page.emulate_media()` for more details. Passing `'null'` resets emulation to system defaults. Defaults to
+ `'no-preference'`.
+ forced_colors : Union["active", "none", "null", None]
Emulates `'forced-colors'` media feature, supported values are `'active'`, `'none'`. See `page.emulate_media()`
- for more details. Defaults to `'none'`.
+ for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'none'`.
accept_downloads : Union[bool, None]
Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted.
traces_dir : Union[pathlib.Path, str, None]
@@ -13624,7 +13893,7 @@ async def evaluate(
Parameters
----------
expression : str
- JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
+ JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
@@ -13664,7 +13933,7 @@ async def evaluate_all(
Parameters
----------
expression : str
- JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
+ JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
@@ -13704,7 +13973,7 @@ async def evaluate_handle(
Parameters
----------
expression : str
- JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
+ JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
automatically invoked.
arg : Union[Any, None]
Optional argument to pass to `expression`.
@@ -13764,6 +14033,42 @@ async def fill(
)
)
+ async def clear(
+ self,
+ *,
+ timeout: typing.Optional[float] = None,
+ no_wait_after: typing.Optional[bool] = None,
+ force: typing.Optional[bool] = None
+ ) -> None:
+ """Locator.clear
+
+ This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, clears it and triggers an
+ `input` event after clearing.
+
+ If the target element is not an `
`, `