![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|


Public Member Functions | |
| "Page" | page (self) |
| str | name (self) |
| str | url (self) |
| typing.Optional["Frame"] | parent_frame (self) |
| typing.List["Frame"] | child_frames (self) |
| typing.Optional["Response"] | goto (self, str url, *typing.Optional[float] timeout=None, typing.Optional[Literal["commit", "domcontentloaded", "load", "networkidle"]] wait_until=None, typing.Optional[str] referer=None) |
| AsyncEventContextManager["Response"] | expect_navigation (self, *typing.Optional[typing.Union[str, typing.Pattern[str], typing.Callable[[str], bool]]] url=None, typing.Optional[Literal["commit", "domcontentloaded", "load", "networkidle"]] wait_until=None, typing.Optional[float] timeout=None) |
| None | wait_for_url (self, typing.Union[str, typing.Pattern[str], typing.Callable[[str], bool]] url, *typing.Optional[Literal["commit", "domcontentloaded", "load", "networkidle"]] wait_until=None, typing.Optional[float] timeout=None) |
| None | wait_for_load_state (self, typing.Optional[Literal["domcontentloaded", "load", "networkidle"]] state=None, *typing.Optional[float] timeout=None) |
| "ElementHandle" | frame_element (self) |
| typing.Any | evaluate (self, str expression, typing.Optional[typing.Any] arg=None) |
| "JSHandle" | evaluate_handle (self, str expression, typing.Optional[typing.Any] arg=None) |
| typing.Optional["ElementHandle"] | query_selector (self, str selector, *typing.Optional[bool] strict=None) |
| typing.List["ElementHandle"] | query_selector_all (self, str selector) |
| typing.Optional["ElementHandle"] | wait_for_selector (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None, typing.Optional[Literal["attached", "detached", "hidden", "visible"]] state=None) |
| bool | is_checked (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| bool | is_disabled (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| bool | is_editable (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| bool | is_enabled (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| bool | is_hidden (self, str selector, *typing.Optional[bool] strict=None) |
| bool | is_visible (self, str selector, *typing.Optional[bool] strict=None) |
| None | dispatch_event (self, str selector, str type, typing.Optional[typing.Dict] event_init=None, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| typing.Any | eval_on_selector (self, str selector, str expression, typing.Optional[typing.Any] arg=None, *typing.Optional[bool] strict=None) |
| typing.Any | eval_on_selector_all (self, str selector, str expression, typing.Optional[typing.Any] arg=None) |
| str | content (self) |
| None | set_content (self, str html, *typing.Optional[float] timeout=None, typing.Optional[Literal["commit", "domcontentloaded", "load", "networkidle"]] wait_until=None) |
| bool | is_detached (self) |
| "ElementHandle" | add_script_tag (self, *typing.Optional[str] url=None, typing.Optional[typing.Union[pathlib.Path, str]] path=None, typing.Optional[str] content=None, typing.Optional[str] type=None) |
| "ElementHandle" | add_style_tag (self, *typing.Optional[str] url=None, typing.Optional[typing.Union[pathlib.Path, str]] path=None, typing.Optional[str] content=None) |
| None | click (self, str selector, *typing.Optional[typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]] modifiers=None, typing.Optional[Position] position=None, typing.Optional[float] delay=None, typing.Optional[Literal["left", "middle", "right"]] button=None, typing.Optional[int] click_count=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | dblclick (self, str selector, *typing.Optional[typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]] modifiers=None, typing.Optional[Position] position=None, typing.Optional[float] delay=None, typing.Optional[Literal["left", "middle", "right"]] button=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | tap (self, str selector, *typing.Optional[typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]] modifiers=None, typing.Optional[Position] position=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | fill (self, str selector, str value, *typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] force=None) |
| "Locator" | locator (self, str selector, *typing.Optional[typing.Union[typing.Pattern[str], str]] has_text=None, typing.Optional[typing.Union[typing.Pattern[str], str]] has_not_text=None, typing.Optional["Locator"] has=None, typing.Optional["Locator"] has_not=None) |
| "Locator" | get_by_alt_text (self, typing.Union[str, typing.Pattern[str]] text, *typing.Optional[bool] exact=None) |
| "Locator" | get_by_label (self, typing.Union[str, typing.Pattern[str]] text, *typing.Optional[bool] exact=None) |
| "Locator" | get_by_placeholder (self, typing.Union[str, typing.Pattern[str]] text, *typing.Optional[bool] exact=None) |
| "Locator" | get_by_role (self, Literal["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "directory", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem",] role, *typing.Optional[bool] checked=None, typing.Optional[bool] disabled=None, typing.Optional[bool] expanded=None, typing.Optional[bool] include_hidden=None, typing.Optional[int] level=None, typing.Optional[typing.Union[typing.Pattern[str], str]] name=None, typing.Optional[bool] pressed=None, typing.Optional[bool] selected=None, typing.Optional[bool] exact=None) |
| "Locator" | get_by_test_id (self, typing.Union[str, typing.Pattern[str]] test_id) |
| "Locator" | get_by_text (self, typing.Union[str, typing.Pattern[str]] text, *typing.Optional[bool] exact=None) |
| "Locator" | get_by_title (self, typing.Union[str, typing.Pattern[str]] text, *typing.Optional[bool] exact=None) |
| "FrameLocator" | frame_locator (self, str selector) |
| None | focus (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| typing.Optional[str] | text_content (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| str | inner_text (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| str | inner_html (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| typing.Optional[str] | get_attribute (self, str selector, str name, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| None | hover (self, str selector, *typing.Optional[typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]] modifiers=None, typing.Optional[Position] position=None, typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] force=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | drag_and_drop (self, str source, str target, *typing.Optional[Position] source_position=None, typing.Optional[Position] target_position=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[float] timeout=None, typing.Optional[bool] trial=None, typing.Optional[int] steps=None) |
| typing.List[str] | select_option (self, str selector, typing.Optional[typing.Union[str, typing.Sequence[str]]] value=None, *typing.Optional[typing.Union[int, typing.Sequence[int]]] index=None, typing.Optional[typing.Union[str, typing.Sequence[str]]] label=None, typing.Optional[typing.Union["ElementHandle", typing.Sequence["ElementHandle"]]] element=None, typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] force=None) |
| str | input_value (self, str selector, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None) |
| None | set_input_files (self, str selector, typing.Union[str, pathlib.Path, FilePayload, typing.Sequence[typing.Union[str, pathlib.Path]], typing.Sequence[FilePayload],] files, *typing.Optional[bool] strict=None, typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None) |
| None | type (self, str selector, str text, *typing.Optional[float] delay=None, typing.Optional[bool] strict=None, typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None) |
| None | press (self, str selector, str key, *typing.Optional[float] delay=None, typing.Optional[bool] strict=None, typing.Optional[float] timeout=None, typing.Optional[bool] no_wait_after=None) |
| None | check (self, str selector, *typing.Optional[Position] position=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | uncheck (self, str selector, *typing.Optional[Position] position=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
| None | wait_for_timeout (self, float timeout) |
| "JSHandle" | wait_for_function (self, str expression, *typing.Optional[typing.Any] arg=None, typing.Optional[float] timeout=None, typing.Optional[typing.Union[float, Literal["raf"]]] polling=None) |
| str | title (self) |
| None | set_checked (self, str selector, bool checked, *typing.Optional[Position] position=None, typing.Optional[float] timeout=None, typing.Optional[bool] force=None, typing.Optional[bool] no_wait_after=None, typing.Optional[bool] strict=None, typing.Optional[bool] trial=None) |
Public Member Functions inherited from playwright._impl._async_base.AsyncBase | |
| None | __init__ (self, Any impl_obj) |
| str | __str__ (self) |
| None | on (self, Any event, Any f) |
| None | once (self, Any event, Any f) |
| None | remove_listener (self, Any event, Any f) |
Public Member Functions inherited from playwright._impl._impl_to_api_mapping.ImplWrapper | |
| str | __repr__ (self) |
Additional Inherited Members | |
Protected Member Functions inherited from playwright._impl._async_base.AsyncBase | |
| Callable[..., None] | _wrap_handler (self, Union[Callable[..., Any], Any] handler) |
Protected Attributes inherited from playwright._impl._async_base.AsyncBase | |
| _loop | |
Protected Attributes inherited from playwright._impl._impl_to_api_mapping.ImplWrapper | |
| _impl_obj | |
| "ElementHandle" playwright.async_api._generated.Frame.add_script_tag | ( | self, | |
| *typing.Optional[str] | url = None, |
||
| typing.Optional[typing.Union[pathlib.Path, str]] | path = None, |
||
| typing.Optional[str] | content = None, |
||
| typing.Optional[str] | type = None |
||
| ) |
Frame.add_script_tag
Returns the added tag when the script's onload fires or when the script content was injected into frame.
Adds a `<script>` tag into the page with the desired url or content.
Parameters
----------
url : Union[str, None]
URL of a script to be added.
path : Union[pathlib.Path, str, None]
Path to the JavaScript file to be injected into frame. If `path` is a relative path, then it is resolved relative
to the current working directory.
content : Union[str, None]
Raw JavaScript content to be injected into frame.
type : Union[str, None]
Script type. Use 'module' in order to load a JavaScript ES6 module. See
[script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details.
Returns
-------
ElementHandle
| "ElementHandle" playwright.async_api._generated.Frame.add_style_tag | ( | self, | |
| *typing.Optional[str] | url = None, |
||
| typing.Optional[typing.Union[pathlib.Path, str]] | path = None, |
||
| typing.Optional[str] | content = None |
||
| ) |
Frame.add_style_tag
Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
Adds a `<link rel=\"stylesheet\">` tag into the page with the desired url or a `<style type=\"text/css\">` tag with the
content.
Parameters
----------
url : Union[str, None]
URL of the `<link>` tag.
path : Union[pathlib.Path, str, None]
Path to the CSS file to be injected into frame. If `path` is a relative path, then it is resolved relative to the
current working directory.
content : Union[str, None]
Raw CSS content to be injected into frame.
Returns
-------
ElementHandle
| None playwright.async_api._generated.Frame.check | ( | self, | |
| str | selector, | ||
| *typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.check
This method checks an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is
already checked, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to click in the center of the element.
1. Ensure that the element is now checked. If not, this method throws.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it.
| typing.List["Frame"] playwright.async_api._generated.Frame.child_frames | ( | self | ) |
Frame.child_frames Returns ------- List[Frame]
| None playwright.async_api._generated.Frame.click | ( | self, | |
| str | selector, | ||
| *typing.Optional[ typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]] ] | modifiers = None, |
||
| typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | delay = None, |
||
| typing.Optional[Literal["left", "middle", "right"]] | button = None, |
||
| typing.Optional[int] | click_count = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.click
This method clicks an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to click in the center of the element, or the specified `position`.
1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
"Control" on Windows and Linux and to "Meta" on macOS.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
delay : Union[float, None]
Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
button : Union["left", "middle", "right", None]
Defaults to `left`.
click_count : Union[int, None]
defaults to 1. See [UIEvent.detail].
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
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`.
Deprecated: This option will default to `true` in the future.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard
`modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys
are pressed.
| str playwright.async_api._generated.Frame.content | ( | self | ) |
Frame.content Gets the full HTML contents of the frame, including the doctype. Returns ------- str
| None playwright.async_api._generated.Frame.dblclick | ( | self, | |
| str | selector, | ||
| *typing.Optional[ typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]] ] | modifiers = None, |
||
| typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | delay = None, |
||
| typing.Optional[Literal["left", "middle", "right"]] | button = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.dblclick
This method double clicks an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to double click in the center of the element, or the specified `position`. if
the first click of the `dblclick()` triggers a navigation event, this method will throw.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
**NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
"Control" on Windows and Linux and to "Meta" on macOS.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
delay : Union[float, None]
Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
button : Union["left", "middle", "right", None]
Defaults to `left`.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard
`modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys
are pressed.
| None playwright.async_api._generated.Frame.dispatch_event | ( | self, | |
| str | selector, | ||
| str | type, | ||
| typing.Optional[typing.Dict] | event_init = None, |
||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.dispatch_event
The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
`click` is dispatched. This is equivalent to calling
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
**Usage**
```py
await frame.dispatch_event(\"button#submit\", \"click\")
```
Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit`
properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
- [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
- [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
- [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
- [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
- [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
- [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
- [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
- [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
- [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
- [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
```py
# note you can only create data_transfer in chromium and firefox
data_transfer = await frame.evaluate_handle(\"new DataTransfer()\")
await frame.dispatch_event(\"#source\", \"dragstart\", { \"dataTransfer\": data_transfer })
```
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
type : str
DOM event type: `"click"`, `"dragstart"`, etc.
event_init : Union[Dict, None]
Optional event-specific initialization properties.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
| None playwright.async_api._generated.Frame.drag_and_drop | ( | self, | |
| str | source, | ||
| str | target, | ||
| *typing.Optional[Position] | source_position = None, |
||
| typing.Optional[Position] | target_position = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | trial = None, |
||
| typing.Optional[int] | steps = None |
||
| ) |
Frame.drag_and_drop
Parameters
----------
source : str
A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will
be used.
target : str
A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first
will be used.
source_position : Union[{x: float, y: float}, None]
Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
specified, some visible point of the element is used.
target_position : Union[{x: float, y: float}, None]
Drops on the target element at this point relative to the top-left corner of the element's padding box. If not
specified, some visible point of the element is used.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it.
steps : Union[int, None]
Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between the `mousedown` and `mouseup`
of the drag. When set to 1, emits a single `mousemove` event at the destination location.
| typing.Any playwright.async_api._generated.Frame.eval_on_selector | ( | self, | |
| str | selector, | ||
| str | expression, | ||
| typing.Optional[typing.Any] | arg = None, |
||
| *typing.Optional[bool] | strict = None |
||
| ) |
Frame.eval_on_selector
Returns the return value of `expression`.
The method finds an element matching the specified selector within the frame and passes it as a first argument to
`expression`. If no elements match the selector, the method throws an error.
If `expression` returns a [Promise], then `frame.eval_on_selector()` would wait for the promise to resolve
and return its value.
**Usage**
```py
search_value = await frame.eval_on_selector(\"#search\", \"el => el.value\")
preload_href = await frame.eval_on_selector(\"link[rel=preload]\", \"el => el.href\")
html = await frame.eval_on_selector(\".main-container\", \"(e, suffix) => e.outerHTML + suffix\", \"hello\")
```
Parameters
----------
selector : str
A selector to query for.
expression : str
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`.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
Returns
-------
Any
| typing.Any playwright.async_api._generated.Frame.eval_on_selector_all | ( | self, | |
| str | selector, | ||
| str | expression, | ||
| typing.Optional[typing.Any] | arg = None |
||
| ) |
Frame.eval_on_selector_all
Returns the return value of `expression`.
The method finds all elements matching the specified selector within the frame and passes an array of matched
elements as a first argument to `expression`.
If `expression` returns a [Promise], then `frame.eval_on_selector_all()` would wait for the promise to resolve
and return its value.
**Usage**
```py
divs_counts = await frame.eval_on_selector_all(\"div\", \"(divs, min) => divs.length >= min\", 10)
```
Parameters
----------
selector : str
A selector to query for.
expression : str
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`.
Returns
-------
Any
| typing.Any playwright.async_api._generated.Frame.evaluate | ( | self, | |
| str | expression, | ||
| typing.Optional[typing.Any] | arg = None |
||
| ) |
Frame.evaluate
Returns the return value of `expression`.
If the function passed to the `frame.evaluate()` returns a [Promise], then `frame.evaluate()` would
wait for the promise to resolve and return its value.
If the function passed to the `frame.evaluate()` returns a non-[Serializable] value, then
`frame.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that
are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
**Usage**
```py
result = await frame.evaluate(\"([x, y]) => Promise.resolve(x * y)\", [7, 8])
print(result) # prints \"56\"
```
A string can also be passed in instead of a function.
```py
print(await frame.evaluate(\"1 + 2\")) # prints \"3\"
x = 10
print(await frame.evaluate(f\"1 + {x}\")) # prints \"11\"
```
`ElementHandle` instances can be passed as an argument to the `frame.evaluate()`:
```py
body_handle = await frame.evaluate(\"document.body\")
html = await frame.evaluate(\"([body, suffix]) => body.innerHTML + suffix\", [body_handle, \"hello\"])
await body_handle.dispose()
```
Parameters
----------
expression : str
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`.
Returns
-------
Any
| "JSHandle" playwright.async_api._generated.Frame.evaluate_handle | ( | self, | |
| str | expression, | ||
| typing.Optional[typing.Any] | arg = None |
||
| ) |
Frame.evaluate_handle
Returns the return value of `expression` as a `JSHandle`.
The only difference between `frame.evaluate()` and `frame.evaluate_handle()` is that
`frame.evaluate_handle()` returns `JSHandle`.
If the function, passed to the `frame.evaluate_handle()`, returns a [Promise], then
`frame.evaluate_handle()` would wait for the promise to resolve and return its value.
**Usage**
```py
a_window_handle = await frame.evaluate_handle(\"Promise.resolve(window)\")
a_window_handle # handle for the window object.
```
A string can also be passed in instead of a function.
```py
a_handle = await page.evaluate_handle(\"document\") # handle for the \"document\"
```
`JSHandle` instances can be passed as an argument to the `frame.evaluate_handle()`:
```py
a_handle = await page.evaluate_handle(\"document.body\")
result_handle = await page.evaluate_handle(\"body => body.innerHTML\", a_handle)
print(await result_handle.json_value())
await result_handle.dispose()
```
Parameters
----------
expression : str
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`.
Returns
-------
JSHandle
| AsyncEventContextManager["Response"] playwright.async_api._generated.Frame.expect_navigation | ( | self, | |
| *typing.Optional[ typing.Union[str, typing.Pattern[str], typing.Callable[[str], bool]] ] | url = None, |
||
| typing.Optional[ Literal["commit", "domcontentloaded", "load", "networkidle"] ] | wait_until = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.expect_navigation
Waits for the frame navigation and returns the main resource response. In case of multiple redirects, the
navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or
navigation due to History API usage, the navigation will resolve with `null`.
**Usage**
This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly
cause the frame to navigate. Consider this example:
```py
async with frame.expect_navigation():
await frame.click(\"a.delayed-navigation\") # clicking the link will indirectly cause a navigation
# Resolves after navigation has finished
```
**NOTE** Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL
is considered a navigation.
Parameters
----------
url : Union[Callable[[str], bool], Pattern[str], str, None]
A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
equal to the string.
wait_until : Union["commit", "domcontentloaded", "load", "networkidle", None]
When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for
at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
- `'commit'` - consider operation to be finished when network response is received and the document started
loading.
timeout : Union[float, None]
Maximum operation 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_navigation_timeout()`,
`browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
`page.set_default_timeout()` methods.
Returns
-------
EventContextManager[Response]
| None playwright.async_api._generated.Frame.fill | ( | self, | |
| str | selector, | ||
| str | value, | ||
| *typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | force = None |
||
| ) |
Frame.fill
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks,
focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string
to clear the input field.
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an
error. However, if the element is inside the `<label>` element that has an associated
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
instead.
To send fine-grained keyboard events, use `locator.press_sequentially()`.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
value : str
Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
| None playwright.async_api._generated.Frame.focus | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.focus
This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the
method waits until a matching element appears in the DOM.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
| "ElementHandle" playwright.async_api._generated.Frame.frame_element | ( | self | ) |
Frame.frame_element Returns the `frame` or `iframe` element handle which corresponds to this frame. This is an inverse of `element_handle.content_frame()`. Note that returned handle actually belongs to the parent frame. This method throws an error if the frame has been detached before `frameElement()` returns. **Usage** ```py frame_element = await frame.frame_element() content_frame = await frame_element.content_frame() assert frame == content_frame ``` Returns ------- ElementHandle
| "FrameLocator" playwright.async_api._generated.Frame.frame_locator | ( | self, | |
| str | selector | ||
| ) |
Frame.frame_locator
When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
in that iframe.
**Usage**
Following snippet locates element with text \"Submit\" in the iframe with id `my-frame`, like `<iframe
id=\"my-frame\">`:
```py
locator = frame.frame_locator(\"#my-iframe\").get_by_text(\"Submit\")
await locator.click()
```
Parameters
----------
selector : str
A selector to use when resolving DOM element.
Returns
-------
FrameLocator
| typing.Optional[str] playwright.async_api._generated.Frame.get_attribute | ( | self, | |
| str | selector, | ||
| str | name, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.get_attribute
Returns element attribute value.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
name : str
Attribute name to get the value for.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
Union[str, None]
| "Locator" playwright.async_api._generated.Frame.get_by_alt_text | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | text, | ||
| *typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_alt_text
Allows locating elements by their alt text.
**Usage**
For example, this method will find the image by alt text \"Playwright logo\":
```html
<img alt='Playwright logo'>
```
```py
await page.get_by_alt_text(\"Playwright logo\").click()
```
Parameters
----------
text : Union[Pattern[str], str]
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. Note that exact match still trims whitespace.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_label | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | text, | ||
| *typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_label
Allows locating input elements by the text of the associated `<label>` or `aria-labelledby` element, or by the
`aria-label` attribute.
**Usage**
For example, this method will find inputs by label \"Username\" and \"Password\" in the following DOM:
```html
<input aria-label=\"Username\">
<label for=\"password-input\">Password:</label>
<input id=\"password-input\">
```
```py
await page.get_by_label(\"Username\").fill(\"john\")
await page.get_by_label(\"Password\").fill(\"secret\")
```
Parameters
----------
text : Union[Pattern[str], str]
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. Note that exact match still trims whitespace.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_placeholder | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | text, | ||
| *typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_placeholder
Allows locating input elements by the placeholder text.
**Usage**
For example, consider the following DOM structure.
```html
<input type=\"email\" placeholder=\"name@example.com\" />
```
You can fill the input after locating it by the placeholder text:
```py
await page.get_by_placeholder(\"name@example.com\").fill(\"playwright@microsoft.com\")
```
Parameters
----------
text : Union[Pattern[str], str]
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. Note that exact match still trims whitespace.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_role | ( | self, | |
| Literal[ "alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "directory", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem", ] | role, | ||
| *typing.Optional[bool] | checked = None, |
||
| typing.Optional[bool] | disabled = None, |
||
| typing.Optional[bool] | expanded = None, |
||
| typing.Optional[bool] | include_hidden = None, |
||
| typing.Optional[int] | level = None, |
||
| typing.Optional[typing.Union[typing.Pattern[str], str]] | name = None, |
||
| typing.Optional[bool] | pressed = None, |
||
| typing.Optional[bool] | selected = None, |
||
| typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_role
Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles),
[ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and
[accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
**Usage**
Consider the following DOM structure.
```html
<h3>Sign up</h3>
<label>
<input type=\"checkbox\" /> Subscribe
</label>
<br/>
<button>Submit</button>
```
You can locate each element by it's implicit role:
```py
await expect(page.get_by_role(\"heading\", name=\"Sign up\")).to_be_visible()
await page.get_by_role(\"checkbox\", name=\"Subscribe\").check()
await page.get_by_role(\"button\", name=re.compile(\"submit\", re.IGNORECASE)).click()
```
**Details**
Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback
about the ARIA guidelines.
Many html elements have an implicitly [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings)
that is recognized by the role selector. You can find all the
[supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not recommend**
duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.
Parameters
----------
role : Union["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "directory", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"]
Required aria role.
checked : Union[bool, None]
An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.
Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
disabled : Union[bool, None]
An attribute that is usually set by `aria-disabled` or `disabled`.
**NOTE** Unlike most other attributes, `disabled` is inherited through the DOM hierarchy. Learn more about
[`aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled).
expanded : Union[bool, None]
An attribute that is usually set by `aria-expanded`.
Learn more about [`aria-expanded`](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded).
include_hidden : Union[bool, None]
Option that controls whether hidden elements are matched. By default, only non-hidden elements, as
[defined by ARIA](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion), are matched by role selector.
Learn more about [`aria-hidden`](https://www.w3.org/TR/wai-aria-1.2/#aria-hidden).
level : Union[int, None]
A number attribute that is usually present for roles `heading`, `listitem`, `row`, `treeitem`, with default values
for `<h1>-<h6>` elements.
Learn more about [`aria-level`](https://www.w3.org/TR/wai-aria-1.2/#aria-level).
name : Union[Pattern[str], str, None]
Option to match the [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). By default, matching is
case-insensitive and searches for a substring, use `exact` to control this behavior.
Learn more about [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
pressed : Union[bool, None]
An attribute that is usually set by `aria-pressed`.
Learn more about [`aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).
selected : Union[bool, None]
An attribute that is usually set by `aria-selected`.
Learn more about [`aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected).
exact : Union[bool, None]
Whether `name` is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when `name` is a
regular expression. Note that exact match still trims whitespace.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_test_id | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | test_id | ||
| ) |
Frame.get_by_test_id
Locate element by the test id.
**Usage**
Consider the following DOM structure.
```html
<button data-testid=\"directions\">Itinéraire</button>
```
You can locate the element by it's test id:
```py
await page.get_by_test_id(\"directions\").click()
```
**Details**
By default, the `data-testid` attribute is used as a test id. Use `selectors.set_test_id_attribute()` to
configure a different test id attribute if necessary.
Parameters
----------
test_id : Union[Pattern[str], str]
Id to locate the element by.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_text | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | text, | ||
| *typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_text
Allows locating elements that contain given text.
See also `locator.filter()` that allows to match by another criteria, like an accessible role, and then
filter by the text content.
**Usage**
Consider the following DOM structure:
```html
<div>Hello <span>world</span></div>
<div>Hello</div>
```
You can locate by text substring, exact string, or a regular expression:
```py
# Matches <span>
page.get_by_text(\"world\")
# Matches first <div>
page.get_by_text(\"Hello world\")
# Matches second <div>
page.get_by_text(\"Hello\", exact=True)
# Matches both <div>s
page.get_by_text(re.compile(\"Hello\"))
# Matches second <div>
page.get_by_text(re.compile(\"^hello$\", re.IGNORECASE))
```
**Details**
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.
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 `<input type=button value=\"Log in\">`.
Parameters
----------
text : Union[Pattern[str], str]
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. Note that exact match still trims whitespace.
Returns
-------
Locator
| "Locator" playwright.async_api._generated.Frame.get_by_title | ( | self, | |
| typing.Union[str, typing.Pattern[str]] | text, | ||
| *typing.Optional[bool] | exact = None |
||
| ) |
Frame.get_by_title
Allows locating elements by their title attribute.
**Usage**
Consider the following DOM structure.
```html
<span title='Issues count'>25 issues</span>
```
You can check the issues count after locating it by the title text:
```py
await expect(page.get_by_title(\"Issues count\")).to_have_text(\"25 issues\")
```
Parameters
----------
text : Union[Pattern[str], str]
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. Note that exact match still trims whitespace.
Returns
-------
Locator
| typing.Optional["Response"] playwright.async_api._generated.Frame.goto | ( | self, | |
| str | url, | ||
| *typing.Optional[float] | timeout = None, |
||
| typing.Optional[ Literal["commit", "domcontentloaded", "load", "networkidle"] ] | wait_until = None, |
||
| typing.Optional[str] | referer = None |
||
| ) |
Frame.goto
Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of
the last redirect.
The method will throw an error if:
- there's an SSL error (e.g. in case of self-signed certificates).
- target URL is invalid.
- the `timeout` is exceeded during navigation.
- the remote server does not respond or is unreachable.
- the main resource failed to load.
The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404
\"Not Found\" and 500 \"Internal Server Error\". The status code for such responses can be retrieved by calling
`response.status()`.
**NOTE** The method either throws an error or returns a main resource response. The only exceptions are navigation
to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
**NOTE** Headless mode doesn't support navigation to a PDF document. See the
[upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
Parameters
----------
url : str
URL to navigate frame to. The url should include scheme, e.g. `https://`.
timeout : Union[float, None]
Maximum operation 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_navigation_timeout()`,
`browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
`page.set_default_timeout()` methods.
wait_until : Union["commit", "domcontentloaded", "load", "networkidle", None]
When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for
at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
- `'commit'` - consider operation to be finished when network response is received and the document started
loading.
referer : Union[str, None]
Referer header value. If provided it will take preference over the referer header value set by
`page.set_extra_http_headers()`.
Returns
-------
Union[Response, None]
| None playwright.async_api._generated.Frame.hover | ( | self, | |
| str | selector, | ||
| *typing.Optional[ typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]] ] | modifiers = None, |
||
| typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.hover
This method hovers over an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to hover over the center of the element, or the specified `position`.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
"Control" on Windows and Linux and to "Meta" on macOS.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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]
This option has no effect.
Deprecated: This option has no effect.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard
`modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys
are pressed.
| str playwright.async_api._generated.Frame.inner_html | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.inner_html
Returns `element.innerHTML`.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
str
| str playwright.async_api._generated.Frame.inner_text | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.inner_text
Returns `element.innerText`.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
str
| str playwright.async_api._generated.Frame.input_value | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.input_value
Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the
control.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
str
| bool playwright.async_api._generated.Frame.is_checked | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.is_checked
Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
bool
| bool playwright.async_api._generated.Frame.is_detached | ( | self | ) |
Frame.is_detached Returns `true` if the frame has been detached, or `false` otherwise. Returns ------- bool
| bool playwright.async_api._generated.Frame.is_disabled | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.is_disabled
Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability#enabled).
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
bool
| bool playwright.async_api._generated.Frame.is_editable | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.is_editable
Returns whether the element is [editable](https://playwright.dev/python/docs/actionability#editable).
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
bool
| bool playwright.async_api._generated.Frame.is_enabled | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.is_enabled
Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability#enabled).
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
bool
| bool playwright.async_api._generated.Frame.is_hidden | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None |
||
| ) |
Frame.is_hidden
Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability#visible). `selector` that
does not match any elements is considered hidden.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
Returns
-------
bool
| bool playwright.async_api._generated.Frame.is_visible | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None |
||
| ) |
Frame.is_visible
Returns whether the element is [visible](https://playwright.dev/python/docs/actionability#visible). `selector` that does not match any elements
is considered not visible.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
Returns
-------
bool
| "Locator" playwright.async_api._generated.Frame.locator | ( | self, | |
| str | selector, | ||
| *typing.Optional[typing.Union[typing.Pattern[str], str]] | has_text = None, |
||
| typing.Optional[typing.Union[typing.Pattern[str], str]] | has_not_text = None, |
||
| typing.Optional["Locator"] | has = None, |
||
| typing.Optional["Locator"] | has_not = None |
||
| ) |
Frame.locator
The method returns an element locator that can be used to perform actions on this page / frame. Locator is resolved
to the element immediately before performing an action, so a series of actions on the same locator can in fact be
performed on different DOM elements. That would happen if the DOM structure between those actions has changed.
[Learn more about locators](https://playwright.dev/python/docs/locators).
[Learn more about locators](https://playwright.dev/python/docs/locators).
Parameters
----------
selector : str
A selector to use when resolving DOM element.
has_text : Union[Pattern[str], str, None]
Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When
passed a [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
`<article><div>Playwright</div></article>`.
has_not_text : Union[Pattern[str], str, None]
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
has_not : Union[Locator, None]
Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
outer one. For example, `article` that does not have `div` matches `<article><span>Playwright</span></article>`.
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
Returns
-------
Locator
| str playwright.async_api._generated.Frame.name | ( | self | ) |
Frame.name Returns frame's name attribute as specified in the tag. If the name is empty, returns the id attribute instead. **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed later. Returns ------- str
| "Page" playwright.async_api._generated.Frame.page | ( | self | ) |
Frame.page Returns the page containing this frame. Returns ------- Page
| typing.Optional["Frame"] playwright.async_api._generated.Frame.parent_frame | ( | self | ) |
Frame.parent_frame Parent frame, if any. Detached frames and main frames return `null`. Returns ------- Union[Frame, None]
| None playwright.async_api._generated.Frame.press | ( | self, | |
| str | selector, | ||
| str | key, | ||
| *typing.Optional[float] | delay = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None |
||
| ) |
Frame.press
`key` can specify the intended
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character
to generate the text for. A superset of the `key` values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`,
etc.
Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`,
`ControlOrMeta`. `ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.
Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
texts.
Shortcuts such as `key: \"Control+o\"`, `key: \"Control++` or `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.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
key : str
Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
delay : Union[float, None]
Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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`.
Deprecated: This option will default to `true` in the future.
| typing.Optional["ElementHandle"] playwright.async_api._generated.Frame.query_selector | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None |
||
| ) |
Frame.query_selector
Returns the ElementHandle pointing to the frame element.
**NOTE** The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead.
The method finds an element matching the specified selector within the frame. If no elements match the selector,
returns `null`.
Parameters
----------
selector : str
A selector to query for.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
Returns
-------
Union[ElementHandle, None]
| typing.List["ElementHandle"] playwright.async_api._generated.Frame.query_selector_all | ( | self, | |
| str | selector | ||
| ) |
Frame.query_selector_all
Returns the ElementHandles pointing to the frame elements.
**NOTE** The use of `ElementHandle` is discouraged, use `Locator` objects instead.
The method finds all elements matching the specified selector within the frame. If no elements match the selector,
returns empty array.
Parameters
----------
selector : str
A selector to query for.
Returns
-------
List[ElementHandle]
| typing.List[str] playwright.async_api._generated.Frame.select_option | ( | self, | |
| str | selector, | ||
| typing.Optional[typing.Union[str, typing.Sequence[str]]] | value = None, |
||
| *typing.Optional[typing.Union[int, typing.Sequence[int]]] | index = None, |
||
| typing.Optional[typing.Union[str, typing.Sequence[str]]] | label = None, |
||
| typing.Optional[ typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] | element = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | force = None |
||
| ) |
Frame.select_option
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits
until all specified options are present in the `<select>` element and selects these options.
If the target element is not a `<select>` element, this method throws an error. However, if the element is inside
the `<label>` element that has an associated
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used
instead.
Returns the array of option values that have been successfully selected.
Triggers a `change` and `input` event once all the provided options have been selected.
**Usage**
```py
# Single selection matching the value or label
await frame.select_option(\"select#colors\", \"blue\")
# single selection matching the label
await frame.select_option(\"select#colors\", label=\"blue\")
# multiple selection
await frame.select_option(\"select#colors\", value=[\"red\", \"green\", \"blue\"])
```
Parameters
----------
selector : str
A selector to query for.
value : Union[Sequence[str], str, None]
Options to select by value. If the `<select>` has the `multiple` attribute, all given options are selected,
otherwise only the first option matching one of the passed options is selected. Optional.
index : Union[Sequence[int], int, None]
Options to select by index. Optional.
label : Union[Sequence[str], str, None]
Options to select by label. If the `<select>` has the `multiple` attribute, all given options are selected,
otherwise only the first option matching one of the passed options is selected. Optional.
element : Union[ElementHandle, Sequence[ElementHandle], None]
Option elements to select. Optional.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
Returns
-------
List[str]
| None playwright.async_api._generated.Frame.set_checked | ( | self, | |
| str | selector, | ||
| bool | checked, | ||
| *typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.set_checked
This method checks or unchecks an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws.
1. If the element already has the right checked state, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to click in the center of the element.
1. Ensure that the element is now checked or unchecked. If not, this method throws.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
checked : bool
Whether to check or uncheck the checkbox.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it.
| None playwright.async_api._generated.Frame.set_content | ( | self, | |
| str | html, | ||
| *typing.Optional[float] | timeout = None, |
||
| typing.Optional[ Literal["commit", "domcontentloaded", "load", "networkidle"] ] | wait_until = None |
||
| ) |
Frame.set_content
This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write),
inheriting all its specific characteristics and behaviors.
Parameters
----------
html : str
HTML markup to assign to the page.
timeout : Union[float, None]
Maximum operation 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_navigation_timeout()`,
`browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
`page.set_default_timeout()` methods.
wait_until : Union["commit", "domcontentloaded", "load", "networkidle", None]
When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for
at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
- `'commit'` - consider operation to be finished when network response is received and the document started
loading.
| None playwright.async_api._generated.Frame.set_input_files | ( | self, | |
| str | selector, | ||
| typing.Union[ str, pathlib.Path, FilePayload, typing.Sequence[typing.Union[str, pathlib.Path]], typing.Sequence[FilePayload], ] | files, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None |
||
| ) |
Frame.set_input_files
Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then
they are resolved relative to the current working directory. For empty array, clears the selected files.
This method expects `selector` to point to an
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside
the `<label>` element that has an associated
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}]
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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]
This option has no effect.
Deprecated: This option has no effect.
| None playwright.async_api._generated.Frame.tap | ( | self, | |
| str | selector, | ||
| *typing.Optional[ typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]] ] | modifiers = None, |
||
| typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.tap
This method taps an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.touchscreen` to tap the center of the element, or the specified `position`.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
**NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
"Control" on Windows and Linux and to "Meta" on macOS.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard
`modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys
are pressed.
| typing.Optional[str] playwright.async_api._generated.Frame.text_content | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.text_content
Returns `element.textContent`.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
Returns
-------
Union[str, None]
| str playwright.async_api._generated.Frame.title | ( | self | ) |
Frame.title Returns the page title. Returns ------- str
| None playwright.async_api._generated.Frame.type | ( | self, | |
| str | selector, | ||
| str | text, | ||
| *typing.Optional[float] | delay = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | no_wait_after = None |
||
| ) |
Frame.type
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used
to send fine-grained keyboard events. To fill values in form fields, use `frame.fill()`.
To press a special key, like `Control` or `ArrowDown`, use `keyboard.press()`.
**Usage**
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
text : str
A text to type into a focused element.
delay : Union[float, None]
Time to wait between key presses in milliseconds. Defaults to 0.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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]
This option has no effect.
Deprecated: This option has no effect.
| None playwright.async_api._generated.Frame.uncheck | ( | self, | |
| str | selector, | ||
| *typing.Optional[Position] | position = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[bool] | force = None, |
||
| typing.Optional[bool] | no_wait_after = None, |
||
| typing.Optional[bool] | strict = None, |
||
| typing.Optional[bool] | trial = None |
||
| ) |
Frame.uncheck
This method checks an element matching `selector` by performing the following steps:
1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is
already unchecked, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If
the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `page.mouse` to click in the center of the element.
1. Ensure that the element is now unchecked. If not, this method throws.
When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
Passing zero timeout disables this.
Parameters
----------
selector : str
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
used.
position : Union[{x: float, y: float}, None]
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
the element.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
force : Union[bool, None]
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
no_wait_after : Union[bool, None]
This option has no effect.
Deprecated: This option has no effect.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
trial : Union[bool, None]
When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
to `false`. Useful to wait until the element is ready for the action without performing it.
| str playwright.async_api._generated.Frame.url | ( | self | ) |
Frame.url Returns frame's url. Returns ------- str
| "JSHandle" playwright.async_api._generated.Frame.wait_for_function | ( | self, | |
| str | expression, | ||
| *typing.Optional[typing.Any] | arg = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[typing.Union[float, Literal["raf"]]] | polling = None |
||
| ) |
Frame.wait_for_function
Returns when the `expression` returns a truthy value, returns that value.
**Usage**
The `frame.wait_for_function()` can be used to observe viewport size change:
```py
import asyncio
from playwright.async_api import async_playwright, Playwright
async def run(playwright: Playwright):
webkit = playwright.webkit
browser = await webkit.launch()
page = await browser.new_page()
await page.evaluate(\"window.x = 0; setTimeout(() => { window.x = 100 }, 1000);\")
await page.main_frame.wait_for_function(\"() => window.x > 0\")
await browser.close()
async def main():
async with async_playwright() as playwright:
await run(playwright)
asyncio.run(main())
```
To pass an argument to the predicate of `frame.waitForFunction` function:
```py
selector = \".foo\"
await frame.wait_for_function(\"selector => !!document.querySelector(selector)\", selector)
```
Parameters
----------
expression : str
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`.
timeout : Union[float, None]
Maximum time to wait for in milliseconds. Defaults to `30000` (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.
polling : Union["raf", float, None]
If `polling` is `'raf'`, then `expression` is constantly executed in `requestAnimationFrame` callback. If `polling`
is a number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to
`raf`.
Returns
-------
JSHandle
| None playwright.async_api._generated.Frame.wait_for_load_state | ( | self, | |
| typing.Optional[ Literal["domcontentloaded", "load", "networkidle"] ] | state = None, |
||
| *typing.Optional[float] | timeout = None |
||
| ) |
Frame.wait_for_load_state
Waits for the required load state to be reached.
This returns when the frame reaches a required load state, `load` by default. The navigation must have been
committed when this method is called. If current document has already reached the required state, resolves
immediately.
**NOTE** Most of the time, this method is not needed because Playwright
[auto-waits before every action](https://playwright.dev/python/docs/actionability).
**Usage**
```py
await frame.click(\"button\") # click triggers navigation.
await frame.wait_for_load_state() # the promise resolves after \"load\" event.
```
Parameters
----------
state : Union["domcontentloaded", "load", "networkidle", None]
Optional load state to wait for, defaults to `load`. If the state has been already reached while loading current
document, the method resolves immediately. Can be one of:
- `'load'` - wait for the `load` event to be fired.
- `'domcontentloaded'` - wait for the `DOMContentLoaded` event to be fired.
- `'networkidle'` - **DISCOURAGED** wait until there are no network connections for at least `500` ms. Don't use
this method for testing, rely on web assertions to assess readiness instead.
timeout : Union[float, None]
Maximum operation 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_navigation_timeout()`,
`browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
`page.set_default_timeout()` methods.
| typing.Optional["ElementHandle"] playwright.async_api._generated.Frame.wait_for_selector | ( | self, | |
| str | selector, | ||
| *typing.Optional[bool] | strict = None, |
||
| typing.Optional[float] | timeout = None, |
||
| typing.Optional[ Literal["attached", "detached", "hidden", "visible"] ] | state = None |
||
| ) |
Frame.wait_for_selector
Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
`detached`.
**NOTE** Playwright automatically waits for element to be ready before performing an action. Using `Locator`
objects and web-first assertions make the code wait-for-selector-free.
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If
at the moment of calling the method `selector` already satisfies the condition, the method will return immediately.
If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
**Usage**
This method works across navigations:
```py
import asyncio
from playwright.async_api import async_playwright, Playwright
async def run(playwright: Playwright):
chromium = playwright.chromium
browser = await chromium.launch()
page = await browser.new_page()
for current_url in [\"https://google.com\", \"https://bbc.com\"]:
await page.goto(current_url, wait_until=\"domcontentloaded\")
element = await page.main_frame.wait_for_selector(\"img\")
print(\"Loaded image: \" + str(await element.get_attribute(\"src\")))
await browser.close()
async def main():
async with async_playwright() as playwright:
await run(playwright)
asyncio.run(main())
```
Parameters
----------
selector : str
A selector to query for.
strict : Union[bool, None]
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
element, the call throws an exception.
timeout : Union[float, None]
Maximum time in milliseconds. Defaults to `30000` (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.
state : Union["attached", "detached", "hidden", "visible", None]
Defaults to `'visible'`. Can be either:
- `'attached'` - wait for element to be present in DOM.
- `'detached'` - wait for element to not be present in DOM.
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element
without any content or with `display:none` has an empty bounding box and is not considered visible.
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or
`visibility:hidden`. This is opposite to the `'visible'` option.
Returns
-------
Union[ElementHandle, None]
| None playwright.async_api._generated.Frame.wait_for_timeout | ( | self, | |
| float | timeout | ||
| ) |
Frame.wait_for_timeout
Waits for the given `timeout` in milliseconds.
Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going
to be flaky. Use signals such as network events, selectors becoming visible and others instead.
Parameters
----------
timeout : float
A timeout to wait for
| None playwright.async_api._generated.Frame.wait_for_url | ( | self, | |
| typing.Union[str, typing.Pattern[str], typing.Callable[[str], bool]] | url, | ||
| *typing.Optional[ Literal["commit", "domcontentloaded", "load", "networkidle"] ] | wait_until = None, |
||
| typing.Optional[float] | timeout = None |
||
| ) |
Frame.wait_for_url
Waits for the frame to navigate to the given URL.
**Usage**
```py
await frame.click(\"a.delayed-navigation\") # clicking the link will indirectly cause a navigation
await frame.wait_for_url(\"**/target.html\")
```
Parameters
----------
url : Union[Callable[[str], bool], Pattern[str], str]
A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation. Note that if
the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
equal to the string.
wait_until : Union["commit", "domcontentloaded", "load", "networkidle", None]
When to consider operation succeeded, defaults to `load`. Events can be either:
- `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
- `'load'` - consider operation to be finished when the `load` event is fired.
- `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for
at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
- `'commit'` - consider operation to be finished when network response is received and the document started
loading.
timeout : Union[float, None]
Maximum operation 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_navigation_timeout()`,
`browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
`page.set_default_timeout()` methods.