From cff480b046002594705fb4571b0210ec6f533b4b Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 15 Apr 2021 14:04:59 -0700 Subject: [PATCH 1/3] feat(roll): roll to 1618513089000 --- README.md | 4 +- playwright/_impl/_element_handle.py | 12 +- playwright/_impl/_frame.py | 2 + playwright/_impl/_page.py | 2 + playwright/async_api/_generated.py | 333 ++++++++++++++++------------ playwright/sync_api/_generated.py | 327 +++++++++++++++------------ setup.py | 2 +- 7 files changed, 389 insertions(+), 293 deletions(-) diff --git a/README.md b/README.md index 8df61e0a3..33f45bc2c 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 91.0.4455.0 | ✅ | ✅ | ✅ | +| Chromium 91.0.4469.0 | ✅ | ✅ | ✅ | | WebKit 14.2 | ✅ | ✅ | ✅ | -| Firefox 88.0b6 | ✅ | ✅ | ✅ | +| Firefox 88.0b8 | ✅ | ✅ | ✅ | Headless execution is supported for all browsers on all platforms. diff --git a/playwright/_impl/_element_handle.py b/playwright/_impl/_element_handle.py index 84fed008b..dd447037e 100644 --- a/playwright/_impl/_element_handle.py +++ b/playwright/_impl/_element_handle.py @@ -200,12 +200,20 @@ async def press( await self._channel.send("press", locals_to_params(locals())) async def check( - self, timeout: float = None, force: bool = None, noWaitAfter: bool = None + self, + position: Position = None, + timeout: float = None, + force: bool = None, + noWaitAfter: bool = None, ) -> None: await self._channel.send("check", locals_to_params(locals())) async def uncheck( - self, timeout: float = None, force: bool = None, noWaitAfter: bool = None + self, + position: Position = None, + timeout: float = None, + force: bool = None, + noWaitAfter: bool = None, ) -> None: await self._channel.send("uncheck", locals_to_params(locals())) diff --git a/playwright/_impl/_frame.py b/playwright/_impl/_frame.py index 5698a90f4..8b5b1e655 100644 --- a/playwright/_impl/_frame.py +++ b/playwright/_impl/_frame.py @@ -501,6 +501,7 @@ async def press( async def check( self, selector: str, + position: Position = None, timeout: float = None, force: bool = None, noWaitAfter: bool = None, @@ -510,6 +511,7 @@ async def check( async def uncheck( self, selector: str, + position: Position = None, timeout: float = None, force: bool = None, noWaitAfter: bool = None, diff --git a/playwright/_impl/_page.py b/playwright/_impl/_page.py index 6115d681e..340a473dc 100644 --- a/playwright/_impl/_page.py +++ b/playwright/_impl/_page.py @@ -712,6 +712,7 @@ async def press( async def check( self, selector: str, + position: Position = None, timeout: float = None, force: bool = None, noWaitAfter: bool = None, @@ -721,6 +722,7 @@ async def check( async def uncheck( self, selector: str, + position: Position = None, timeout: float = None, force: bool = None, noWaitAfter: bool = None, diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index a647ecefb..f80b6df83 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -108,7 +108,7 @@ def method(self) -> str: return mapping.from_maybe_impl(self._impl_obj.method) @property - def post_data(self) -> typing.Optional[str]: + def post_data(self) -> typing.Union[str, NoneType]: """Request.post_data Request's post body, if any. @@ -120,7 +120,7 @@ def post_data(self) -> typing.Optional[str]: return mapping.from_maybe_impl(self._impl_obj.post_data) @property - def post_data_json(self) -> typing.Optional[typing.Any]: + def post_data_json(self) -> typing.Union[typing.Any, NoneType]: """Request.post_data_json Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. @@ -135,7 +135,7 @@ def post_data_json(self) -> typing.Optional[typing.Any]: return mapping.from_maybe_impl(self._impl_obj.post_data_json) @property - def post_data_buffer(self) -> typing.Optional[bytes]: + def post_data_buffer(self) -> typing.Union[bytes, NoneType]: """Request.post_data_buffer Request's post body in a binary form, if any. @@ -171,7 +171,7 @@ def frame(self) -> "Frame": return mapping.from_impl(self._impl_obj.frame) @property - def redirected_from(self) -> typing.Optional["Request"]: + def redirected_from(self) -> typing.Union["Request", NoneType]: """Request.redirected_from Request that was redirected by the server to this one, if any. @@ -201,7 +201,7 @@ def redirected_from(self) -> typing.Optional["Request"]: return mapping.from_impl_nullable(self._impl_obj.redirected_from) @property - def redirected_to(self) -> typing.Optional["Request"]: + def redirected_to(self) -> typing.Union["Request", NoneType]: """Request.redirected_to New request issued by the browser if the server responded with redirect. @@ -219,7 +219,7 @@ def redirected_to(self) -> typing.Optional["Request"]: return mapping.from_impl_nullable(self._impl_obj.redirected_to) @property - def failure(self) -> typing.Optional[str]: + def failure(self) -> typing.Union[str, NoneType]: """Request.failure The method returns `null` unless this request has failed, as reported by `requestfailed` event. @@ -257,7 +257,7 @@ def timing(self) -> ResourceTiming: """ return mapping.from_impl(self._impl_obj.timing) - async def response(self) -> typing.Optional["Response"]: + async def response(self) -> typing.Union["Response", NoneType]: """Request.response Returns the matching `Response` object, or `null` if the response was not received due to error. @@ -375,7 +375,7 @@ def frame(self) -> "Frame": """ return mapping.from_impl(self._impl_obj.frame) - async def finished(self) -> typing.Optional[str]: + async def finished(self) -> typing.Union[str, NoneType]: """Response.finished Waits for this response to finish, returns failure error if request failed. @@ -488,7 +488,7 @@ async def fulfill( self, *, status: int = None, - headers: typing.Optional[typing.Dict[str, str]] = None, + headers: typing.Union[typing.Dict[str, str]] = None, body: typing.Union[str, bytes] = None, path: typing.Union[str, pathlib.Path] = None, content_type: str = None @@ -545,7 +545,7 @@ async def continue_( *, url: str = None, method: str = None, - headers: typing.Optional[typing.Dict[str, str]] = None, + headers: typing.Union[typing.Dict[str, str]] = None, post_data: typing.Union[str, bytes] = None ) -> NoneType: """Route.continue_ @@ -1138,7 +1138,7 @@ async def get_properties(self) -> typing.Dict[str, "JSHandle"]: ) ) - def as_element(self) -> typing.Optional["ElementHandle"]: + def as_element(self) -> typing.Union["ElementHandle", NoneType]: """JSHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1185,7 +1185,7 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) - def as_element(self) -> typing.Optional["ElementHandle"]: + def as_element(self) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1197,7 +1197,7 @@ def as_element(self) -> typing.Optional["ElementHandle"]: return mapping.from_impl_nullable(self._impl_obj.as_element()) - async def owner_frame(self) -> typing.Optional["Frame"]: + async def owner_frame(self) -> typing.Union["Frame", NoneType]: """ElementHandle.owner_frame Returns the frame containing the given element. @@ -1213,7 +1213,7 @@ async def owner_frame(self) -> typing.Optional["Frame"]: ) ) - async def content_frame(self) -> typing.Optional["Frame"]: + async def content_frame(self) -> typing.Union["Frame", NoneType]: """ElementHandle.content_frame Returns the content frame for element handles referencing iframe nodes, or `null` otherwise @@ -1229,7 +1229,7 @@ async def content_frame(self) -> typing.Optional["Frame"]: ) ) - async def get_attribute(self, name: str) -> typing.Optional[str]: + async def get_attribute(self, name: str) -> typing.Union[str, NoneType]: """ElementHandle.get_attribute Returns element attribute value. @@ -1250,7 +1250,7 @@ async def get_attribute(self, name: str) -> typing.Optional[str]: ) ) - async def text_content(self) -> typing.Optional[str]: + async def text_content(self) -> typing.Union[str, NoneType]: """ElementHandle.text_content Returns the `node.textContent`. @@ -1459,7 +1459,7 @@ async def scroll_into_view_if_needed(self, *, timeout: float = None) -> NoneType async def hover( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1474,10 +1474,10 @@ async def hover( 1. Use `page.mouse` to hover over the center of the element, or the specified `position`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -1506,7 +1506,7 @@ async def hover( async def click( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1525,10 +1525,10 @@ async def click( 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. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -1574,7 +1574,7 @@ async def click( async def dblclick( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1591,12 +1591,12 @@ async def dblclick( 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + first click of the `dblclick()` triggers a navigation event, this method will throw. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event. @@ -1708,7 +1708,7 @@ async def select_option( async def tap( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1724,10 +1724,10 @@ async def tap( 1. Use `page.touchscreen` to tap the center of the element, or the specified `position`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true. @@ -1973,26 +1973,34 @@ async def press( ) async def check( - self, *, timeout: float = None, force: bool = None, no_wait_after: bool = None + self, + *, + position: Position = None, + timeout: float = None, + force: bool = None, + no_wait_after: bool = None ) -> NoneType: """ElementHandle.check This method checks the element by performing the following steps: - 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already - checked, this method returns immediately. + 1. Ensure that 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](./actionability.md) checks on the element, unless `force` option is set. 1. Scroll the element into view if needed. 1. Use `page.mouse` to click in the center of the element. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 1. Ensure that the element is now checked. If not, this method throws. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -2008,32 +2016,43 @@ async def check( await self._async( "element_handle.check", self._impl_obj.check( - timeout=timeout, force=force, noWaitAfter=no_wait_after + position=position, + timeout=timeout, + force=force, + noWaitAfter=no_wait_after, ), ) ) async def uncheck( - self, *, timeout: float = None, force: bool = None, no_wait_after: bool = None + self, + *, + position: Position = None, + timeout: float = None, + force: bool = None, + no_wait_after: bool = None ) -> NoneType: """ElementHandle.uncheck This method checks the element by performing the following steps: - 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already + 1. Ensure that 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](./actionability.md) checks on the element, unless `force` option is set. 1. Scroll the element into view if needed. 1. Use `page.mouse` to click in the center of the element. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 1. Ensure that the element is now unchecked. If not, this method throws. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -2049,12 +2068,15 @@ async def uncheck( await self._async( "element_handle.uncheck", self._impl_obj.uncheck( - timeout=timeout, force=force, noWaitAfter=no_wait_after + position=position, + timeout=timeout, + force=force, + noWaitAfter=no_wait_after, ), ) ) - async def bounding_box(self) -> typing.Optional[FloatRect]: + async def bounding_box(self) -> typing.Union[FloatRect, NoneType]: """ElementHandle.bounding_box This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is @@ -2137,7 +2159,9 @@ async def screenshot( ) ) - async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + async def query_selector( + self, selector: str + ) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.query_selector The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See @@ -2327,7 +2351,7 @@ async def wait_for_selector( *, state: Literal["attached", "detached", "hidden", "visible"] = None, timeout: float = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.wait_for_selector Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -2387,7 +2411,7 @@ def __init__(self, obj: AccessibilityImpl): async def snapshot( self, *, interesting_only: bool = None, root: "ElementHandle" = None - ) -> typing.Optional[typing.Dict]: + ) -> typing.Union[typing.Dict, NoneType]: """Accessibility.snapshot Captures the current state of the accessibility tree. The returned object represents the root accessible node of the @@ -2573,7 +2597,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def parent_frame(self) -> typing.Optional["Frame"]: + def parent_frame(self) -> typing.Union["Frame", NoneType]: """Frame.parent_frame Parent frame, if any. Detached frames and main frames return `null`. @@ -2601,7 +2625,7 @@ async def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Frame.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -2922,7 +2946,9 @@ async def evaluate_handle( ) ) - async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + async def query_selector( + self, selector: str + ) -> typing.Union["ElementHandle", NoneType]: """Frame.query_selector Returns the ElementHandle pointing to the frame element. @@ -2977,7 +3003,7 @@ async def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """Frame.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -3491,7 +3517,7 @@ async def click( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3505,15 +3531,15 @@ async def click( """Frame.click This method clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -3564,7 +3590,7 @@ async def dblclick( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3577,16 +3603,16 @@ async def dblclick( """Frame.dblclick This method double clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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. @@ -3636,7 +3662,7 @@ async def tap( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3647,15 +3673,15 @@ async def tap( """Frame.tap This method taps an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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. @@ -3765,7 +3791,7 @@ async def focus(self, selector: str, *, timeout: float = None) -> NoneType: async def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Frame.text_content Returns `element.textContent`. @@ -3845,7 +3871,7 @@ async def inner_html(self, selector: str, *, timeout: float = None) -> str: async def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Frame.get_attribute Returns element attribute value. @@ -3879,7 +3905,7 @@ async def hover( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3889,15 +3915,15 @@ async def hover( """Frame.hover This method hovers over an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -4165,6 +4191,7 @@ async def check( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -4172,24 +4199,27 @@ async def check( """Frame.check This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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 element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4206,6 +4236,7 @@ async def check( "frame.check", self._impl_obj.check( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -4217,6 +4248,7 @@ async def uncheck( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -4224,24 +4256,27 @@ async def uncheck( """Frame.uncheck This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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 element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4258,6 +4293,7 @@ async def uncheck( "frame.uncheck", self._impl_obj.uncheck( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -4674,7 +4710,7 @@ async def delete(self) -> NoneType: await self._async("download.delete", self._impl_obj.delete()) ) - async def failure(self) -> typing.Optional[str]: + async def failure(self) -> typing.Union[str, NoneType]: """Download.failure Returns download error if any. Will wait for the download to finish if necessary. @@ -4688,7 +4724,7 @@ async def failure(self) -> typing.Optional[str]: await self._async("download.failure", self._impl_obj.failure()) ) - async def path(self) -> typing.Optional[pathlib.Path]: + async def path(self) -> typing.Union[pathlib.Path, NoneType]: """Download.path Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if @@ -4864,7 +4900,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def viewport_size(self) -> typing.Optional[ViewportSize]: + def viewport_size(self) -> typing.Union[ViewportSize, NoneType]: """Page.viewport_size Returns @@ -4889,7 +4925,7 @@ def workers(self) -> typing.List["Worker"]: return mapping.from_impl_list(self._impl_obj.workers) @property - def video(self) -> typing.Optional["Video"]: + def video(self) -> typing.Union["Video", NoneType]: """Page.video Video object associated with this page. @@ -4900,7 +4936,7 @@ def video(self) -> typing.Optional["Video"]: """ return mapping.from_impl_nullable(self._impl_obj.video) - async def opener(self) -> typing.Optional["Page"]: + async def opener(self) -> typing.Union["Page", NoneType]: """Page.opener Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`. @@ -4919,7 +4955,7 @@ def frame( name: str = None, *, url: typing.Union[str, typing.Pattern, typing.Callable[[str], bool]] = None - ) -> typing.Optional["Frame"]: + ) -> typing.Union["Frame", NoneType]: """Page.frame Returns frame matching the specified criteria. Either `name` or `url` must be specified. @@ -4990,7 +5026,9 @@ def set_default_timeout(self, timeout: float) -> NoneType: self._impl_obj.set_default_timeout(timeout=timeout) ) - async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + async def query_selector( + self, selector: str + ) -> typing.Union["ElementHandle", NoneType]: """Page.query_selector The method finds an element matching the specified selector within the page. If no elements match the selector, the @@ -5045,7 +5083,7 @@ async def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """Page.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -5826,7 +5864,7 @@ async def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -5887,7 +5925,7 @@ async def reload( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.reload Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6054,7 +6092,7 @@ async def go_back( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.go_back Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6092,7 +6130,7 @@ async def go_forward( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.go_forward Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6453,7 +6491,7 @@ async def click( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6467,15 +6505,15 @@ async def click( """Page.click This method clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.click()`. @@ -6528,7 +6566,7 @@ async def dblclick( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6541,16 +6579,16 @@ async def dblclick( """Page.dblclick This method double clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event. @@ -6602,7 +6640,7 @@ async def tap( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6613,15 +6651,15 @@ async def tap( """Page.tap This method taps an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `page.tap()` requires that the `hasTouch` option of the browser context be set to true. @@ -6737,7 +6775,7 @@ async def focus(self, selector: str, *, timeout: float = None) -> NoneType: async def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Page.text_content Returns `element.textContent`. @@ -6817,7 +6855,7 @@ async def inner_html(self, selector: str, *, timeout: float = None) -> str: async def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Page.get_attribute Returns element attribute value. @@ -6851,7 +6889,7 @@ async def hover( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6861,15 +6899,15 @@ async def hover( """Page.hover This method hovers over an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.hover()`. @@ -7158,6 +7196,7 @@ async def check( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -7165,18 +7204,18 @@ async def check( """Page.check This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.check()`. @@ -7185,6 +7224,9 @@ async def check( selector : str A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -7201,6 +7243,7 @@ async def check( "page.check", self._impl_obj.check( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -7212,6 +7255,7 @@ async def uncheck( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -7219,18 +7263,18 @@ async def uncheck( """Page.uncheck This method unchecks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.uncheck()`. @@ -7239,6 +7283,9 @@ async def uncheck( selector : str A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -7255,6 +7302,7 @@ async def uncheck( "page.uncheck", self._impl_obj.uncheck( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -7544,13 +7592,13 @@ def expect_event( def expect_console_message( self, - predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None, + predicate: typing.Union[typing.Callable[["ConsoleMessage"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["ConsoleMessage"]: """Page.expect_console_message - Performs action and waits for a [ConoleMessage] to be logged by in the page. If predicate is provided, it passes + Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will throw an error if the page is closed before the console event is fired. @@ -7575,7 +7623,7 @@ def expect_console_message( def expect_download( self, - predicate: typing.Optional[typing.Callable[["Download"], bool]] = None, + predicate: typing.Union[typing.Callable[["Download"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Download"]: @@ -7606,7 +7654,7 @@ def expect_download( def expect_file_chooser( self, - predicate: typing.Optional[typing.Callable[["FileChooser"], bool]] = None, + predicate: typing.Union[typing.Callable[["FileChooser"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["FileChooser"]: @@ -7691,7 +7739,7 @@ def expect_navigation( def expect_popup( self, - predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, + predicate: typing.Union[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Page"]: @@ -7807,7 +7855,7 @@ def expect_response( def expect_worker( self, - predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None, + predicate: typing.Union[typing.Callable[["Worker"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Worker"]: @@ -7857,7 +7905,7 @@ def pages(self) -> typing.List["Page"]: return mapping.from_impl_list(self._impl_obj.pages) @property - def browser(self) -> typing.Optional["Browser"]: + def browser(self) -> typing.Union["Browser", NoneType]: """BrowserContext.browser Returns the browser instance of the context. If it was launched as a persistent context null gets returned. @@ -8511,7 +8559,7 @@ async def wait_for_event( def expect_page( self, - predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, + predicate: typing.Union[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Page"]: @@ -8670,7 +8718,7 @@ async def new_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -8820,7 +8868,7 @@ async def new_page( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -9023,10 +9071,7 @@ async def start_tracing( await self._async( "browser.start_tracing", self._impl_obj.start_tracing( - page=page._impl_obj if page else None, - path=path, - screenshots=screenshots, - categories=categories, + page=page, path=path, screenshots=screenshots, categories=categories ), ) ) @@ -9099,14 +9144,14 @@ async def launch( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloads_path: typing.Union[str, pathlib.Path] = None, slow_mo: float = None, chromium_sandbox: bool = None, - firefox_user_prefs: typing.Optional[ + firefox_user_prefs: typing.Union[ typing.Dict[str, typing.Union[str, float, bool]] ] = None ) -> "Browser": @@ -9234,7 +9279,7 @@ async def launch_persistent_context( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, @@ -9251,7 +9296,7 @@ async def launch_persistent_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index 33b1d02f3..0ba2791c8 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -108,7 +108,7 @@ def method(self) -> str: return mapping.from_maybe_impl(self._impl_obj.method) @property - def post_data(self) -> typing.Optional[str]: + def post_data(self) -> typing.Union[str, NoneType]: """Request.post_data Request's post body, if any. @@ -120,7 +120,7 @@ def post_data(self) -> typing.Optional[str]: return mapping.from_maybe_impl(self._impl_obj.post_data) @property - def post_data_json(self) -> typing.Optional[typing.Any]: + def post_data_json(self) -> typing.Union[typing.Any, NoneType]: """Request.post_data_json Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. @@ -135,7 +135,7 @@ def post_data_json(self) -> typing.Optional[typing.Any]: return mapping.from_maybe_impl(self._impl_obj.post_data_json) @property - def post_data_buffer(self) -> typing.Optional[bytes]: + def post_data_buffer(self) -> typing.Union[bytes, NoneType]: """Request.post_data_buffer Request's post body in a binary form, if any. @@ -171,7 +171,7 @@ def frame(self) -> "Frame": return mapping.from_impl(self._impl_obj.frame) @property - def redirected_from(self) -> typing.Optional["Request"]: + def redirected_from(self) -> typing.Union["Request", NoneType]: """Request.redirected_from Request that was redirected by the server to this one, if any. @@ -201,7 +201,7 @@ def redirected_from(self) -> typing.Optional["Request"]: return mapping.from_impl_nullable(self._impl_obj.redirected_from) @property - def redirected_to(self) -> typing.Optional["Request"]: + def redirected_to(self) -> typing.Union["Request", NoneType]: """Request.redirected_to New request issued by the browser if the server responded with redirect. @@ -219,7 +219,7 @@ def redirected_to(self) -> typing.Optional["Request"]: return mapping.from_impl_nullable(self._impl_obj.redirected_to) @property - def failure(self) -> typing.Optional[str]: + def failure(self) -> typing.Union[str, NoneType]: """Request.failure The method returns `null` unless this request has failed, as reported by `requestfailed` event. @@ -257,7 +257,7 @@ def timing(self) -> ResourceTiming: """ return mapping.from_impl(self._impl_obj.timing) - def response(self) -> typing.Optional["Response"]: + def response(self) -> typing.Union["Response", NoneType]: """Request.response Returns the matching `Response` object, or `null` if the response was not received due to error. @@ -375,7 +375,7 @@ def frame(self) -> "Frame": """ return mapping.from_impl(self._impl_obj.frame) - def finished(self) -> typing.Optional[str]: + def finished(self) -> typing.Union[str, NoneType]: """Response.finished Waits for this response to finish, returns failure error if request failed. @@ -488,7 +488,7 @@ def fulfill( self, *, status: int = None, - headers: typing.Optional[typing.Dict[str, str]] = None, + headers: typing.Union[typing.Dict[str, str]] = None, body: typing.Union[str, bytes] = None, path: typing.Union[str, pathlib.Path] = None, content_type: str = None @@ -545,7 +545,7 @@ def continue_( *, url: str = None, method: str = None, - headers: typing.Optional[typing.Dict[str, str]] = None, + headers: typing.Union[typing.Dict[str, str]] = None, post_data: typing.Union[str, bytes] = None ) -> NoneType: """Route.continue_ @@ -1128,7 +1128,7 @@ def get_properties(self) -> typing.Dict[str, "JSHandle"]: self._sync("js_handle.get_properties", self._impl_obj.get_properties()) ) - def as_element(self) -> typing.Optional["ElementHandle"]: + def as_element(self) -> typing.Union["ElementHandle", NoneType]: """JSHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1175,7 +1175,7 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) - def as_element(self) -> typing.Optional["ElementHandle"]: + def as_element(self) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1187,7 +1187,7 @@ def as_element(self) -> typing.Optional["ElementHandle"]: return mapping.from_impl_nullable(self._impl_obj.as_element()) - def owner_frame(self) -> typing.Optional["Frame"]: + def owner_frame(self) -> typing.Union["Frame", NoneType]: """ElementHandle.owner_frame Returns the frame containing the given element. @@ -1201,7 +1201,7 @@ def owner_frame(self) -> typing.Optional["Frame"]: self._sync("element_handle.owner_frame", self._impl_obj.owner_frame()) ) - def content_frame(self) -> typing.Optional["Frame"]: + def content_frame(self) -> typing.Union["Frame", NoneType]: """ElementHandle.content_frame Returns the content frame for element handles referencing iframe nodes, or `null` otherwise @@ -1215,7 +1215,7 @@ def content_frame(self) -> typing.Optional["Frame"]: self._sync("element_handle.content_frame", self._impl_obj.content_frame()) ) - def get_attribute(self, name: str) -> typing.Optional[str]: + def get_attribute(self, name: str) -> typing.Union[str, NoneType]: """ElementHandle.get_attribute Returns element attribute value. @@ -1236,7 +1236,7 @@ def get_attribute(self, name: str) -> typing.Optional[str]: ) ) - def text_content(self) -> typing.Optional[str]: + def text_content(self) -> typing.Union[str, NoneType]: """ElementHandle.text_content Returns the `node.textContent`. @@ -1437,7 +1437,7 @@ def scroll_into_view_if_needed(self, *, timeout: float = None) -> NoneType: def hover( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1452,10 +1452,10 @@ def hover( 1. Use `page.mouse` to hover over the center of the element, or the specified `position`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -1484,7 +1484,7 @@ def hover( def click( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1503,10 +1503,10 @@ def click( 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. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -1552,7 +1552,7 @@ def click( def dblclick( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1569,12 +1569,12 @@ def dblclick( 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + first click of the `dblclick()` triggers a navigation event, this method will throw. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event. @@ -1697,7 +1697,7 @@ def select_option( def tap( self, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1713,10 +1713,10 @@ def tap( 1. Use `page.touchscreen` to tap the center of the element, or the specified `position`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true. @@ -1962,26 +1962,34 @@ def press( ) def check( - self, *, timeout: float = None, force: bool = None, no_wait_after: bool = None + self, + *, + position: Position = None, + timeout: float = None, + force: bool = None, + no_wait_after: bool = None ) -> NoneType: """ElementHandle.check This method checks the element by performing the following steps: - 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already - checked, this method returns immediately. + 1. Ensure that 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](./actionability.md) checks on the element, unless `force` option is set. 1. Scroll the element into view if needed. 1. Use `page.mouse` to click in the center of the element. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 1. Ensure that the element is now checked. If not, this method throws. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -1997,32 +2005,43 @@ def check( self._sync( "element_handle.check", self._impl_obj.check( - timeout=timeout, force=force, noWaitAfter=no_wait_after + position=position, + timeout=timeout, + force=force, + noWaitAfter=no_wait_after, ), ) ) def uncheck( - self, *, timeout: float = None, force: bool = None, no_wait_after: bool = None + self, + *, + position: Position = None, + timeout: float = None, + force: bool = None, + no_wait_after: bool = None ) -> NoneType: """ElementHandle.uncheck This method checks the element by performing the following steps: - 1. Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already + 1. Ensure that 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](./actionability.md) checks on the element, unless `force` option is set. 1. Scroll the element into view if needed. 1. Use `page.mouse` to click in the center of the element. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 1. Ensure that the element is now unchecked. If not, this method throws. - If the element is detached from the DOM at any moment during the action, this method rejects. + If the element is detached from the DOM at any moment during the action, this method throws. - When all steps combined have not finished during the specified `timeout`, this method rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -2038,12 +2057,15 @@ def uncheck( self._sync( "element_handle.uncheck", self._impl_obj.uncheck( - timeout=timeout, force=force, noWaitAfter=no_wait_after + position=position, + timeout=timeout, + force=force, + noWaitAfter=no_wait_after, ), ) ) - def bounding_box(self) -> typing.Optional[FloatRect]: + def bounding_box(self) -> typing.Union[FloatRect, NoneType]: """ElementHandle.bounding_box This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is @@ -2124,7 +2146,7 @@ def screenshot( ) ) - def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.query_selector The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See @@ -2314,7 +2336,7 @@ def wait_for_selector( *, state: Literal["attached", "detached", "hidden", "visible"] = None, timeout: float = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """ElementHandle.wait_for_selector Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -2374,7 +2396,7 @@ def __init__(self, obj: AccessibilityImpl): def snapshot( self, *, interesting_only: bool = None, root: "ElementHandle" = None - ) -> typing.Optional[typing.Dict]: + ) -> typing.Union[typing.Dict, NoneType]: """Accessibility.snapshot Captures the current state of the accessibility tree. The returned object represents the root accessible node of the @@ -2560,7 +2582,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def parent_frame(self) -> typing.Optional["Frame"]: + def parent_frame(self) -> typing.Union["Frame", NoneType]: """Frame.parent_frame Parent frame, if any. Detached frames and main frames return `null`. @@ -2588,7 +2610,7 @@ def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Frame.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -2907,7 +2929,7 @@ def evaluate_handle(self, expression: str, arg: typing.Any = None) -> "JSHandle" ) ) - def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: """Frame.query_selector Returns the ElementHandle pointing to the frame element. @@ -2962,7 +2984,7 @@ def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """Frame.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -3473,7 +3495,7 @@ def click( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3487,15 +3509,15 @@ def click( """Frame.click This method clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -3546,7 +3568,7 @@ def dblclick( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3559,16 +3581,16 @@ def dblclick( """Frame.dblclick This method double clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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. @@ -3618,7 +3640,7 @@ def tap( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3629,15 +3651,15 @@ def tap( """Frame.tap This method taps an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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. @@ -3747,7 +3769,7 @@ def focus(self, selector: str, *, timeout: float = None) -> NoneType: def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Frame.text_content Returns `element.textContent`. @@ -3827,7 +3849,7 @@ def inner_html(self, selector: str, *, timeout: float = None) -> str: def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Frame.get_attribute Returns element attribute value. @@ -3861,7 +3883,7 @@ def hover( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3871,15 +3893,15 @@ def hover( """Frame.hover This method hovers over an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Parameters ---------- @@ -4147,6 +4169,7 @@ def check( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -4154,24 +4177,27 @@ def check( """Frame.check This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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 element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4188,6 +4214,7 @@ def check( "frame.check", self._impl_obj.check( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -4199,6 +4226,7 @@ def uncheck( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -4206,24 +4234,27 @@ def uncheck( """Frame.uncheck This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + 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 element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4240,6 +4271,7 @@ def uncheck( "frame.uncheck", self._impl_obj.uncheck( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -4649,7 +4681,7 @@ def delete(self) -> NoneType: self._sync("download.delete", self._impl_obj.delete()) ) - def failure(self) -> typing.Optional[str]: + def failure(self) -> typing.Union[str, NoneType]: """Download.failure Returns download error if any. Will wait for the download to finish if necessary. @@ -4663,7 +4695,7 @@ def failure(self) -> typing.Optional[str]: self._sync("download.failure", self._impl_obj.failure()) ) - def path(self) -> typing.Optional[pathlib.Path]: + def path(self) -> typing.Union[pathlib.Path, NoneType]: """Download.path Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if @@ -4837,7 +4869,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def viewport_size(self) -> typing.Optional[ViewportSize]: + def viewport_size(self) -> typing.Union[ViewportSize, NoneType]: """Page.viewport_size Returns @@ -4862,7 +4894,7 @@ def workers(self) -> typing.List["Worker"]: return mapping.from_impl_list(self._impl_obj.workers) @property - def video(self) -> typing.Optional["Video"]: + def video(self) -> typing.Union["Video", NoneType]: """Page.video Video object associated with this page. @@ -4873,7 +4905,7 @@ def video(self) -> typing.Optional["Video"]: """ return mapping.from_impl_nullable(self._impl_obj.video) - def opener(self) -> typing.Optional["Page"]: + def opener(self) -> typing.Union["Page", NoneType]: """Page.opener Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`. @@ -4892,7 +4924,7 @@ def frame( name: str = None, *, url: typing.Union[str, typing.Pattern, typing.Callable[[str], bool]] = None - ) -> typing.Optional["Frame"]: + ) -> typing.Union["Frame", NoneType]: """Page.frame Returns frame matching the specified criteria. Either `name` or `url` must be specified. @@ -4963,7 +4995,7 @@ def set_default_timeout(self, timeout: float) -> NoneType: self._impl_obj.set_default_timeout(timeout=timeout) ) - def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: + def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: """Page.query_selector The method finds an element matching the specified selector within the page. If no elements match the selector, the @@ -5018,7 +5050,7 @@ def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Optional["ElementHandle"]: + ) -> typing.Union["ElementHandle", NoneType]: """Page.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -5788,7 +5820,7 @@ def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -5849,7 +5881,7 @@ def reload( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.reload Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6016,7 +6048,7 @@ def go_back( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.go_back Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6054,7 +6086,7 @@ def go_forward( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Optional["Response"]: + ) -> typing.Union["Response", NoneType]: """Page.go_forward Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6412,7 +6444,7 @@ def click( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6426,15 +6458,15 @@ def click( """Page.click This method clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.click()`. @@ -6487,7 +6519,7 @@ def dblclick( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6500,16 +6532,16 @@ def dblclick( """Page.dblclick This method double clicks an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the - first click of the `dblclick()` triggers a navigation event, this method will reject. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event. @@ -6561,7 +6593,7 @@ def tap( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6572,15 +6604,15 @@ def tap( """Page.tap This method taps an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. > NOTE: `page.tap()` requires that the `hasTouch` option of the browser context be set to true. @@ -6696,7 +6728,7 @@ def focus(self, selector: str, *, timeout: float = None) -> NoneType: def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Page.text_content Returns `element.textContent`. @@ -6776,7 +6808,7 @@ def inner_html(self, selector: str, *, timeout: float = None) -> str: def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Optional[str]: + ) -> typing.Union[str, NoneType]: """Page.get_attribute Returns element attribute value. @@ -6810,7 +6842,7 @@ def hover( self, selector: str, *, - modifiers: typing.Optional[ + modifiers: typing.Union[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6820,15 +6852,15 @@ def hover( """Page.hover This method hovers over an element matching `selector` by performing the following steps: - 1. Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM. + 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM. 1. Wait for [actionability](./actionability.md) 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`. 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.hover()`. @@ -7117,6 +7149,7 @@ def check( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -7124,18 +7157,18 @@ def check( """Page.check This method checks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now checked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.check()`. @@ -7144,6 +7177,9 @@ def check( selector : str A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -7160,6 +7196,7 @@ def check( "page.check", self._impl_obj.check( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -7171,6 +7208,7 @@ def uncheck( self, selector: str, *, + position: Position = None, timeout: float = None, force: bool = None, no_wait_after: bool = None @@ -7178,18 +7216,18 @@ def uncheck( """Page.uncheck This method unchecks an element matching `selector` by performing the following steps: - 1. Find an element match 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 rejects. If the element is already + 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](./actionability.md) 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. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. - 1. Ensure that the element is now unchecked. If not, this method rejects. + 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 rejects with a `TimeoutError`. - Passing zero timeout disables this. + When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing + zero timeout disables this. Shortcut for main frame's `frame.uncheck()`. @@ -7198,6 +7236,9 @@ def uncheck( selector : str A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](./selectors.md) for more details. + position : Union[{x: float, y: float}, NoneType] + 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, NoneType] Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -7214,6 +7255,7 @@ def uncheck( "page.uncheck", self._impl_obj.uncheck( selector=selector, + position=position, timeout=timeout, force=force, noWaitAfter=no_wait_after, @@ -7498,13 +7540,13 @@ def expect_event( def expect_console_message( self, - predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None, + predicate: typing.Union[typing.Callable[["ConsoleMessage"], bool]] = None, *, timeout: float = None ) -> EventContextManager["ConsoleMessage"]: """Page.expect_console_message - Performs action and waits for a [ConoleMessage] to be logged by in the page. If predicate is provided, it passes + Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will throw an error if the page is closed before the console event is fired. @@ -7529,7 +7571,7 @@ def expect_console_message( def expect_download( self, - predicate: typing.Optional[typing.Callable[["Download"], bool]] = None, + predicate: typing.Union[typing.Callable[["Download"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Download"]: @@ -7560,7 +7602,7 @@ def expect_download( def expect_file_chooser( self, - predicate: typing.Optional[typing.Callable[["FileChooser"], bool]] = None, + predicate: typing.Union[typing.Callable[["FileChooser"], bool]] = None, *, timeout: float = None ) -> EventContextManager["FileChooser"]: @@ -7645,7 +7687,7 @@ def expect_navigation( def expect_popup( self, - predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, + predicate: typing.Union[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Page"]: @@ -7761,7 +7803,7 @@ def expect_response( def expect_worker( self, - predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None, + predicate: typing.Union[typing.Callable[["Worker"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Worker"]: @@ -7811,7 +7853,7 @@ def pages(self) -> typing.List["Page"]: return mapping.from_impl_list(self._impl_obj.pages) @property - def browser(self) -> typing.Optional["Browser"]: + def browser(self) -> typing.Union["Browser", NoneType]: """BrowserContext.browser Returns the browser instance of the context. If it was launched as a persistent context null gets returned. @@ -8457,7 +8499,7 @@ def wait_for_event( def expect_page( self, - predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, + predicate: typing.Union[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Page"]: @@ -8616,7 +8658,7 @@ def new_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -8766,7 +8808,7 @@ def new_page( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -8969,10 +9011,7 @@ def start_tracing( self._sync( "browser.start_tracing", self._impl_obj.start_tracing( - page=page._impl_obj if page else None, - path=path, - screenshots=screenshots, - categories=categories, + page=page, path=path, screenshots=screenshots, categories=categories ), ) ) @@ -9045,14 +9084,14 @@ def launch( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloads_path: typing.Union[str, pathlib.Path] = None, slow_mo: float = None, chromium_sandbox: bool = None, - firefox_user_prefs: typing.Optional[ + firefox_user_prefs: typing.Union[ typing.Dict[str, typing.Union[str, float, bool]] ] = None ) -> "Browser": @@ -9180,7 +9219,7 @@ def launch_persistent_context( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, @@ -9197,7 +9236,7 @@ def launch_persistent_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, + extra_http_headers: typing.Union[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, diff --git a/setup.py b/setup.py index 7248edf15..a403456f4 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ from auditwheel.wheeltools import InWheel from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand -driver_version = "1.11.0-next-1617404897000" +driver_version = "1.11.0-next-1618513089000" def extractall(zip: zipfile.ZipFile, path: str) -> None: From e991831709861dc41510ad56861da098f8e55731 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 16 Apr 2021 19:52:16 +0200 Subject: [PATCH 2/3] generate with Python 3.9 --- playwright/async_api/_generated.py | 141 ++++++++++++++--------------- playwright/sync_api/_generated.py | 135 +++++++++++++-------------- 2 files changed, 138 insertions(+), 138 deletions(-) diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index f80b6df83..4cc37efbc 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -108,7 +108,7 @@ def method(self) -> str: return mapping.from_maybe_impl(self._impl_obj.method) @property - def post_data(self) -> typing.Union[str, NoneType]: + def post_data(self) -> typing.Optional[str]: """Request.post_data Request's post body, if any. @@ -120,7 +120,7 @@ def post_data(self) -> typing.Union[str, NoneType]: return mapping.from_maybe_impl(self._impl_obj.post_data) @property - def post_data_json(self) -> typing.Union[typing.Any, NoneType]: + def post_data_json(self) -> typing.Optional[typing.Any]: """Request.post_data_json Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. @@ -135,7 +135,7 @@ def post_data_json(self) -> typing.Union[typing.Any, NoneType]: return mapping.from_maybe_impl(self._impl_obj.post_data_json) @property - def post_data_buffer(self) -> typing.Union[bytes, NoneType]: + def post_data_buffer(self) -> typing.Optional[bytes]: """Request.post_data_buffer Request's post body in a binary form, if any. @@ -171,7 +171,7 @@ def frame(self) -> "Frame": return mapping.from_impl(self._impl_obj.frame) @property - def redirected_from(self) -> typing.Union["Request", NoneType]: + def redirected_from(self) -> typing.Optional["Request"]: """Request.redirected_from Request that was redirected by the server to this one, if any. @@ -201,7 +201,7 @@ def redirected_from(self) -> typing.Union["Request", NoneType]: return mapping.from_impl_nullable(self._impl_obj.redirected_from) @property - def redirected_to(self) -> typing.Union["Request", NoneType]: + def redirected_to(self) -> typing.Optional["Request"]: """Request.redirected_to New request issued by the browser if the server responded with redirect. @@ -219,7 +219,7 @@ def redirected_to(self) -> typing.Union["Request", NoneType]: return mapping.from_impl_nullable(self._impl_obj.redirected_to) @property - def failure(self) -> typing.Union[str, NoneType]: + def failure(self) -> typing.Optional[str]: """Request.failure The method returns `null` unless this request has failed, as reported by `requestfailed` event. @@ -257,7 +257,7 @@ def timing(self) -> ResourceTiming: """ return mapping.from_impl(self._impl_obj.timing) - async def response(self) -> typing.Union["Response", NoneType]: + async def response(self) -> typing.Optional["Response"]: """Request.response Returns the matching `Response` object, or `null` if the response was not received due to error. @@ -375,7 +375,7 @@ def frame(self) -> "Frame": """ return mapping.from_impl(self._impl_obj.frame) - async def finished(self) -> typing.Union[str, NoneType]: + async def finished(self) -> typing.Optional[str]: """Response.finished Waits for this response to finish, returns failure error if request failed. @@ -488,7 +488,7 @@ async def fulfill( self, *, status: int = None, - headers: typing.Union[typing.Dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, body: typing.Union[str, bytes] = None, path: typing.Union[str, pathlib.Path] = None, content_type: str = None @@ -545,7 +545,7 @@ async def continue_( *, url: str = None, method: str = None, - headers: typing.Union[typing.Dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, post_data: typing.Union[str, bytes] = None ) -> NoneType: """Route.continue_ @@ -1138,7 +1138,7 @@ async def get_properties(self) -> typing.Dict[str, "JSHandle"]: ) ) - def as_element(self) -> typing.Union["ElementHandle", NoneType]: + def as_element(self) -> typing.Optional["ElementHandle"]: """JSHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1185,7 +1185,7 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) - def as_element(self) -> typing.Union["ElementHandle", NoneType]: + def as_element(self) -> typing.Optional["ElementHandle"]: """ElementHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1197,7 +1197,7 @@ def as_element(self) -> typing.Union["ElementHandle", NoneType]: return mapping.from_impl_nullable(self._impl_obj.as_element()) - async def owner_frame(self) -> typing.Union["Frame", NoneType]: + async def owner_frame(self) -> typing.Optional["Frame"]: """ElementHandle.owner_frame Returns the frame containing the given element. @@ -1213,7 +1213,7 @@ async def owner_frame(self) -> typing.Union["Frame", NoneType]: ) ) - async def content_frame(self) -> typing.Union["Frame", NoneType]: + async def content_frame(self) -> typing.Optional["Frame"]: """ElementHandle.content_frame Returns the content frame for element handles referencing iframe nodes, or `null` otherwise @@ -1229,7 +1229,7 @@ async def content_frame(self) -> typing.Union["Frame", NoneType]: ) ) - async def get_attribute(self, name: str) -> typing.Union[str, NoneType]: + async def get_attribute(self, name: str) -> typing.Optional[str]: """ElementHandle.get_attribute Returns element attribute value. @@ -1250,7 +1250,7 @@ async def get_attribute(self, name: str) -> typing.Union[str, NoneType]: ) ) - async def text_content(self) -> typing.Union[str, NoneType]: + async def text_content(self) -> typing.Optional[str]: """ElementHandle.text_content Returns the `node.textContent`. @@ -1459,7 +1459,7 @@ async def scroll_into_view_if_needed(self, *, timeout: float = None) -> NoneType async def hover( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1506,7 +1506,7 @@ async def hover( async def click( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1574,7 +1574,7 @@ async def click( async def dblclick( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1708,7 +1708,7 @@ async def select_option( async def tap( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -2076,7 +2076,7 @@ async def uncheck( ) ) - async def bounding_box(self) -> typing.Union[FloatRect, NoneType]: + async def bounding_box(self) -> typing.Optional[FloatRect]: """ElementHandle.bounding_box This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is @@ -2159,9 +2159,7 @@ async def screenshot( ) ) - async def query_selector( - self, selector: str - ) -> typing.Union["ElementHandle", NoneType]: + async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """ElementHandle.query_selector The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See @@ -2351,7 +2349,7 @@ async def wait_for_selector( *, state: Literal["attached", "detached", "hidden", "visible"] = None, timeout: float = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """ElementHandle.wait_for_selector Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -2411,7 +2409,7 @@ def __init__(self, obj: AccessibilityImpl): async def snapshot( self, *, interesting_only: bool = None, root: "ElementHandle" = None - ) -> typing.Union[typing.Dict, NoneType]: + ) -> typing.Optional[typing.Dict]: """Accessibility.snapshot Captures the current state of the accessibility tree. The returned object represents the root accessible node of the @@ -2597,7 +2595,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def parent_frame(self) -> typing.Union["Frame", NoneType]: + def parent_frame(self) -> typing.Optional["Frame"]: """Frame.parent_frame Parent frame, if any. Detached frames and main frames return `null`. @@ -2625,7 +2623,7 @@ async def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Frame.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -2946,9 +2944,7 @@ async def evaluate_handle( ) ) - async def query_selector( - self, selector: str - ) -> typing.Union["ElementHandle", NoneType]: + async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """Frame.query_selector Returns the ElementHandle pointing to the frame element. @@ -3003,7 +2999,7 @@ async def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """Frame.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -3517,7 +3513,7 @@ async def click( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3590,7 +3586,7 @@ async def dblclick( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3662,7 +3658,7 @@ async def tap( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3791,7 +3787,7 @@ async def focus(self, selector: str, *, timeout: float = None) -> NoneType: async def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Frame.text_content Returns `element.textContent`. @@ -3871,7 +3867,7 @@ async def inner_html(self, selector: str, *, timeout: float = None) -> str: async def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Frame.get_attribute Returns element attribute value. @@ -3905,7 +3901,7 @@ async def hover( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -4710,7 +4706,7 @@ async def delete(self) -> NoneType: await self._async("download.delete", self._impl_obj.delete()) ) - async def failure(self) -> typing.Union[str, NoneType]: + async def failure(self) -> typing.Optional[str]: """Download.failure Returns download error if any. Will wait for the download to finish if necessary. @@ -4724,7 +4720,7 @@ async def failure(self) -> typing.Union[str, NoneType]: await self._async("download.failure", self._impl_obj.failure()) ) - async def path(self) -> typing.Union[pathlib.Path, NoneType]: + async def path(self) -> typing.Optional[pathlib.Path]: """Download.path Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if @@ -4900,7 +4896,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def viewport_size(self) -> typing.Union[ViewportSize, NoneType]: + def viewport_size(self) -> typing.Optional[ViewportSize]: """Page.viewport_size Returns @@ -4925,7 +4921,7 @@ def workers(self) -> typing.List["Worker"]: return mapping.from_impl_list(self._impl_obj.workers) @property - def video(self) -> typing.Union["Video", NoneType]: + def video(self) -> typing.Optional["Video"]: """Page.video Video object associated with this page. @@ -4936,7 +4932,7 @@ def video(self) -> typing.Union["Video", NoneType]: """ return mapping.from_impl_nullable(self._impl_obj.video) - async def opener(self) -> typing.Union["Page", NoneType]: + async def opener(self) -> typing.Optional["Page"]: """Page.opener Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`. @@ -4955,7 +4951,7 @@ def frame( name: str = None, *, url: typing.Union[str, typing.Pattern, typing.Callable[[str], bool]] = None - ) -> typing.Union["Frame", NoneType]: + ) -> typing.Optional["Frame"]: """Page.frame Returns frame matching the specified criteria. Either `name` or `url` must be specified. @@ -5026,9 +5022,7 @@ def set_default_timeout(self, timeout: float) -> NoneType: self._impl_obj.set_default_timeout(timeout=timeout) ) - async def query_selector( - self, selector: str - ) -> typing.Union["ElementHandle", NoneType]: + async def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """Page.query_selector The method finds an element matching the specified selector within the page. If no elements match the selector, the @@ -5083,7 +5077,7 @@ async def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """Page.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -5864,7 +5858,7 @@ async def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -5925,7 +5919,7 @@ async def reload( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.reload Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6092,7 +6086,7 @@ async def go_back( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.go_back Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6130,7 +6124,7 @@ async def go_forward( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.go_forward Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6491,7 +6485,7 @@ async def click( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6566,7 +6560,7 @@ async def dblclick( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6640,7 +6634,7 @@ async def tap( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6775,7 +6769,7 @@ async def focus(self, selector: str, *, timeout: float = None) -> NoneType: async def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Page.text_content Returns `element.textContent`. @@ -6855,7 +6849,7 @@ async def inner_html(self, selector: str, *, timeout: float = None) -> str: async def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Page.get_attribute Returns element attribute value. @@ -6889,7 +6883,7 @@ async def hover( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -7592,7 +7586,7 @@ def expect_event( def expect_console_message( self, - predicate: typing.Union[typing.Callable[["ConsoleMessage"], bool]] = None, + predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["ConsoleMessage"]: @@ -7623,7 +7617,7 @@ def expect_console_message( def expect_download( self, - predicate: typing.Union[typing.Callable[["Download"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Download"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Download"]: @@ -7654,7 +7648,7 @@ def expect_download( def expect_file_chooser( self, - predicate: typing.Union[typing.Callable[["FileChooser"], bool]] = None, + predicate: typing.Optional[typing.Callable[["FileChooser"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["FileChooser"]: @@ -7739,7 +7733,7 @@ def expect_navigation( def expect_popup( self, - predicate: typing.Union[typing.Callable[["Page"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Page"]: @@ -7855,7 +7849,7 @@ def expect_response( def expect_worker( self, - predicate: typing.Union[typing.Callable[["Worker"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Worker"]: @@ -7905,7 +7899,7 @@ def pages(self) -> typing.List["Page"]: return mapping.from_impl_list(self._impl_obj.pages) @property - def browser(self) -> typing.Union["Browser", NoneType]: + def browser(self) -> typing.Optional["Browser"]: """BrowserContext.browser Returns the browser instance of the context. If it was launched as a persistent context null gets returned. @@ -8559,7 +8553,7 @@ async def wait_for_event( def expect_page( self, - predicate: typing.Union[typing.Callable[["Page"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> AsyncEventContextManager["Page"]: @@ -8718,7 +8712,7 @@ async def new_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -8868,7 +8862,7 @@ async def new_page( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -9071,7 +9065,10 @@ async def start_tracing( await self._async( "browser.start_tracing", self._impl_obj.start_tracing( - page=page, path=path, screenshots=screenshots, categories=categories + page=page._impl_obj if page else None, + path=path, + screenshots=screenshots, + categories=categories, ), ) ) @@ -9144,14 +9141,14 @@ async def launch( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloads_path: typing.Union[str, pathlib.Path] = None, slow_mo: float = None, chromium_sandbox: bool = None, - firefox_user_prefs: typing.Union[ + firefox_user_prefs: typing.Optional[ typing.Dict[str, typing.Union[str, float, bool]] ] = None ) -> "Browser": @@ -9279,7 +9276,7 @@ async def launch_persistent_context( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, @@ -9296,7 +9293,7 @@ async def launch_persistent_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index 0ba2791c8..502b9dd99 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -108,7 +108,7 @@ def method(self) -> str: return mapping.from_maybe_impl(self._impl_obj.method) @property - def post_data(self) -> typing.Union[str, NoneType]: + def post_data(self) -> typing.Optional[str]: """Request.post_data Request's post body, if any. @@ -120,7 +120,7 @@ def post_data(self) -> typing.Union[str, NoneType]: return mapping.from_maybe_impl(self._impl_obj.post_data) @property - def post_data_json(self) -> typing.Union[typing.Any, NoneType]: + def post_data_json(self) -> typing.Optional[typing.Any]: """Request.post_data_json Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. @@ -135,7 +135,7 @@ def post_data_json(self) -> typing.Union[typing.Any, NoneType]: return mapping.from_maybe_impl(self._impl_obj.post_data_json) @property - def post_data_buffer(self) -> typing.Union[bytes, NoneType]: + def post_data_buffer(self) -> typing.Optional[bytes]: """Request.post_data_buffer Request's post body in a binary form, if any. @@ -171,7 +171,7 @@ def frame(self) -> "Frame": return mapping.from_impl(self._impl_obj.frame) @property - def redirected_from(self) -> typing.Union["Request", NoneType]: + def redirected_from(self) -> typing.Optional["Request"]: """Request.redirected_from Request that was redirected by the server to this one, if any. @@ -201,7 +201,7 @@ def redirected_from(self) -> typing.Union["Request", NoneType]: return mapping.from_impl_nullable(self._impl_obj.redirected_from) @property - def redirected_to(self) -> typing.Union["Request", NoneType]: + def redirected_to(self) -> typing.Optional["Request"]: """Request.redirected_to New request issued by the browser if the server responded with redirect. @@ -219,7 +219,7 @@ def redirected_to(self) -> typing.Union["Request", NoneType]: return mapping.from_impl_nullable(self._impl_obj.redirected_to) @property - def failure(self) -> typing.Union[str, NoneType]: + def failure(self) -> typing.Optional[str]: """Request.failure The method returns `null` unless this request has failed, as reported by `requestfailed` event. @@ -257,7 +257,7 @@ def timing(self) -> ResourceTiming: """ return mapping.from_impl(self._impl_obj.timing) - def response(self) -> typing.Union["Response", NoneType]: + def response(self) -> typing.Optional["Response"]: """Request.response Returns the matching `Response` object, or `null` if the response was not received due to error. @@ -375,7 +375,7 @@ def frame(self) -> "Frame": """ return mapping.from_impl(self._impl_obj.frame) - def finished(self) -> typing.Union[str, NoneType]: + def finished(self) -> typing.Optional[str]: """Response.finished Waits for this response to finish, returns failure error if request failed. @@ -488,7 +488,7 @@ def fulfill( self, *, status: int = None, - headers: typing.Union[typing.Dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, body: typing.Union[str, bytes] = None, path: typing.Union[str, pathlib.Path] = None, content_type: str = None @@ -545,7 +545,7 @@ def continue_( *, url: str = None, method: str = None, - headers: typing.Union[typing.Dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, post_data: typing.Union[str, bytes] = None ) -> NoneType: """Route.continue_ @@ -1128,7 +1128,7 @@ def get_properties(self) -> typing.Dict[str, "JSHandle"]: self._sync("js_handle.get_properties", self._impl_obj.get_properties()) ) - def as_element(self) -> typing.Union["ElementHandle", NoneType]: + def as_element(self) -> typing.Optional["ElementHandle"]: """JSHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1175,7 +1175,7 @@ class ElementHandle(JSHandle): def __init__(self, obj: ElementHandleImpl): super().__init__(obj) - def as_element(self) -> typing.Union["ElementHandle", NoneType]: + def as_element(self) -> typing.Optional["ElementHandle"]: """ElementHandle.as_element Returns either `null` or the object handle itself, if the object handle is an instance of `ElementHandle`. @@ -1187,7 +1187,7 @@ def as_element(self) -> typing.Union["ElementHandle", NoneType]: return mapping.from_impl_nullable(self._impl_obj.as_element()) - def owner_frame(self) -> typing.Union["Frame", NoneType]: + def owner_frame(self) -> typing.Optional["Frame"]: """ElementHandle.owner_frame Returns the frame containing the given element. @@ -1201,7 +1201,7 @@ def owner_frame(self) -> typing.Union["Frame", NoneType]: self._sync("element_handle.owner_frame", self._impl_obj.owner_frame()) ) - def content_frame(self) -> typing.Union["Frame", NoneType]: + def content_frame(self) -> typing.Optional["Frame"]: """ElementHandle.content_frame Returns the content frame for element handles referencing iframe nodes, or `null` otherwise @@ -1215,7 +1215,7 @@ def content_frame(self) -> typing.Union["Frame", NoneType]: self._sync("element_handle.content_frame", self._impl_obj.content_frame()) ) - def get_attribute(self, name: str) -> typing.Union[str, NoneType]: + def get_attribute(self, name: str) -> typing.Optional[str]: """ElementHandle.get_attribute Returns element attribute value. @@ -1236,7 +1236,7 @@ def get_attribute(self, name: str) -> typing.Union[str, NoneType]: ) ) - def text_content(self) -> typing.Union[str, NoneType]: + def text_content(self) -> typing.Optional[str]: """ElementHandle.text_content Returns the `node.textContent`. @@ -1437,7 +1437,7 @@ def scroll_into_view_if_needed(self, *, timeout: float = None) -> NoneType: def hover( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1484,7 +1484,7 @@ def hover( def click( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1552,7 +1552,7 @@ def click( def dblclick( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -1697,7 +1697,7 @@ def select_option( def tap( self, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -2065,7 +2065,7 @@ def uncheck( ) ) - def bounding_box(self) -> typing.Union[FloatRect, NoneType]: + def bounding_box(self) -> typing.Optional[FloatRect]: """ElementHandle.bounding_box This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is @@ -2146,7 +2146,7 @@ def screenshot( ) ) - def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: + def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """ElementHandle.query_selector The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See @@ -2336,7 +2336,7 @@ def wait_for_selector( *, state: Literal["attached", "detached", "hidden", "visible"] = None, timeout: float = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """ElementHandle.wait_for_selector Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -2396,7 +2396,7 @@ def __init__(self, obj: AccessibilityImpl): def snapshot( self, *, interesting_only: bool = None, root: "ElementHandle" = None - ) -> typing.Union[typing.Dict, NoneType]: + ) -> typing.Optional[typing.Dict]: """Accessibility.snapshot Captures the current state of the accessibility tree. The returned object represents the root accessible node of the @@ -2582,7 +2582,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def parent_frame(self) -> typing.Union["Frame", NoneType]: + def parent_frame(self) -> typing.Optional["Frame"]: """Frame.parent_frame Parent frame, if any. Detached frames and main frames return `null`. @@ -2610,7 +2610,7 @@ def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Frame.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -2929,7 +2929,7 @@ def evaluate_handle(self, expression: str, arg: typing.Any = None) -> "JSHandle" ) ) - def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: + def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """Frame.query_selector Returns the ElementHandle pointing to the frame element. @@ -2984,7 +2984,7 @@ def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """Frame.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -3495,7 +3495,7 @@ def click( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3568,7 +3568,7 @@ def dblclick( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3640,7 +3640,7 @@ def tap( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -3769,7 +3769,7 @@ def focus(self, selector: str, *, timeout: float = None) -> NoneType: def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Frame.text_content Returns `element.textContent`. @@ -3849,7 +3849,7 @@ def inner_html(self, selector: str, *, timeout: float = None) -> str: def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Frame.get_attribute Returns element attribute value. @@ -3883,7 +3883,7 @@ def hover( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -4681,7 +4681,7 @@ def delete(self) -> NoneType: self._sync("download.delete", self._impl_obj.delete()) ) - def failure(self) -> typing.Union[str, NoneType]: + def failure(self) -> typing.Optional[str]: """Download.failure Returns download error if any. Will wait for the download to finish if necessary. @@ -4695,7 +4695,7 @@ def failure(self) -> typing.Union[str, NoneType]: self._sync("download.failure", self._impl_obj.failure()) ) - def path(self) -> typing.Union[pathlib.Path, NoneType]: + def path(self) -> typing.Optional[pathlib.Path]: """Download.path Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if @@ -4869,7 +4869,7 @@ def url(self) -> str: return mapping.from_maybe_impl(self._impl_obj.url) @property - def viewport_size(self) -> typing.Union[ViewportSize, NoneType]: + def viewport_size(self) -> typing.Optional[ViewportSize]: """Page.viewport_size Returns @@ -4894,7 +4894,7 @@ def workers(self) -> typing.List["Worker"]: return mapping.from_impl_list(self._impl_obj.workers) @property - def video(self) -> typing.Union["Video", NoneType]: + def video(self) -> typing.Optional["Video"]: """Page.video Video object associated with this page. @@ -4905,7 +4905,7 @@ def video(self) -> typing.Union["Video", NoneType]: """ return mapping.from_impl_nullable(self._impl_obj.video) - def opener(self) -> typing.Union["Page", NoneType]: + def opener(self) -> typing.Optional["Page"]: """Page.opener Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`. @@ -4924,7 +4924,7 @@ def frame( name: str = None, *, url: typing.Union[str, typing.Pattern, typing.Callable[[str], bool]] = None - ) -> typing.Union["Frame", NoneType]: + ) -> typing.Optional["Frame"]: """Page.frame Returns frame matching the specified criteria. Either `name` or `url` must be specified. @@ -4995,7 +4995,7 @@ def set_default_timeout(self, timeout: float) -> NoneType: self._impl_obj.set_default_timeout(timeout=timeout) ) - def query_selector(self, selector: str) -> typing.Union["ElementHandle", NoneType]: + def query_selector(self, selector: str) -> typing.Optional["ElementHandle"]: """Page.query_selector The method finds an element matching the specified selector within the page. If no elements match the selector, the @@ -5050,7 +5050,7 @@ def wait_for_selector( *, timeout: float = None, state: Literal["attached", "detached", "hidden", "visible"] = None - ) -> typing.Union["ElementHandle", NoneType]: + ) -> typing.Optional["ElementHandle"]: """Page.wait_for_selector Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or @@ -5820,7 +5820,7 @@ def goto( timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None, referer: str = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.goto Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -5881,7 +5881,7 @@ def reload( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.reload Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6048,7 +6048,7 @@ def go_back( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.go_back Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6086,7 +6086,7 @@ def go_forward( *, timeout: float = None, wait_until: Literal["domcontentloaded", "load", "networkidle"] = None - ) -> typing.Union["Response", NoneType]: + ) -> typing.Optional["Response"]: """Page.go_forward Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the @@ -6444,7 +6444,7 @@ def click( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6519,7 +6519,7 @@ def dblclick( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6593,7 +6593,7 @@ def tap( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -6728,7 +6728,7 @@ def focus(self, selector: str, *, timeout: float = None) -> NoneType: def text_content( self, selector: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Page.text_content Returns `element.textContent`. @@ -6808,7 +6808,7 @@ def inner_html(self, selector: str, *, timeout: float = None) -> str: def get_attribute( self, selector: str, name: str, *, timeout: float = None - ) -> typing.Union[str, NoneType]: + ) -> typing.Optional[str]: """Page.get_attribute Returns element attribute value. @@ -6842,7 +6842,7 @@ def hover( self, selector: str, *, - modifiers: typing.Union[ + modifiers: typing.Optional[ typing.List[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: Position = None, @@ -7540,7 +7540,7 @@ def expect_event( def expect_console_message( self, - predicate: typing.Union[typing.Callable[["ConsoleMessage"], bool]] = None, + predicate: typing.Optional[typing.Callable[["ConsoleMessage"], bool]] = None, *, timeout: float = None ) -> EventContextManager["ConsoleMessage"]: @@ -7571,7 +7571,7 @@ def expect_console_message( def expect_download( self, - predicate: typing.Union[typing.Callable[["Download"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Download"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Download"]: @@ -7602,7 +7602,7 @@ def expect_download( def expect_file_chooser( self, - predicate: typing.Union[typing.Callable[["FileChooser"], bool]] = None, + predicate: typing.Optional[typing.Callable[["FileChooser"], bool]] = None, *, timeout: float = None ) -> EventContextManager["FileChooser"]: @@ -7687,7 +7687,7 @@ def expect_navigation( def expect_popup( self, - predicate: typing.Union[typing.Callable[["Page"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Page"]: @@ -7803,7 +7803,7 @@ def expect_response( def expect_worker( self, - predicate: typing.Union[typing.Callable[["Worker"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Worker"]: @@ -7853,7 +7853,7 @@ def pages(self) -> typing.List["Page"]: return mapping.from_impl_list(self._impl_obj.pages) @property - def browser(self) -> typing.Union["Browser", NoneType]: + def browser(self) -> typing.Optional["Browser"]: """BrowserContext.browser Returns the browser instance of the context. If it was launched as a persistent context null gets returned. @@ -8499,7 +8499,7 @@ def wait_for_event( def expect_page( self, - predicate: typing.Union[typing.Callable[["Page"], bool]] = None, + predicate: typing.Optional[typing.Callable[["Page"], bool]] = None, *, timeout: float = None ) -> EventContextManager["Page"]: @@ -8658,7 +8658,7 @@ def new_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -8808,7 +8808,7 @@ def new_page( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, @@ -9011,7 +9011,10 @@ def start_tracing( self._sync( "browser.start_tracing", self._impl_obj.start_tracing( - page=page, path=path, screenshots=screenshots, categories=categories + page=page._impl_obj if page else None, + path=path, + screenshots=screenshots, + categories=categories, ), ) ) @@ -9084,14 +9087,14 @@ def launch( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, downloads_path: typing.Union[str, pathlib.Path] = None, slow_mo: float = None, chromium_sandbox: bool = None, - firefox_user_prefs: typing.Union[ + firefox_user_prefs: typing.Optional[ typing.Dict[str, typing.Union[str, float, bool]] ] = None ) -> "Browser": @@ -9219,7 +9222,7 @@ def launch_persistent_context( handle_sigterm: bool = None, handle_sighup: bool = None, timeout: float = None, - env: typing.Union[typing.Dict[str, typing.Union[str, float, bool]]] = None, + env: typing.Optional[typing.Dict[str, typing.Union[str, float, bool]]] = None, headless: bool = None, devtools: bool = None, proxy: ProxySettings = None, @@ -9236,7 +9239,7 @@ def launch_persistent_context( timezone_id: str = None, geolocation: Geolocation = None, permissions: typing.List[str] = None, - extra_http_headers: typing.Union[typing.Dict[str, str]] = None, + extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: bool = None, http_credentials: HttpCredentials = None, device_scale_factor: float = None, From 19a8525f28e59fc3dc288eb7d601ece6b3674bd5 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 16 Apr 2021 19:52:57 +0200 Subject: [PATCH 3/3] ensure >= Python 3.9 is used for generation --- scripts/generate_sync_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/generate_sync_api.py b/scripts/generate_sync_api.py index d6500016a..5f1d640cb 100755 --- a/scripts/generate_sync_api.py +++ b/scripts/generate_sync_api.py @@ -15,6 +15,7 @@ import inspect import re +import sys from types import FunctionType from typing import Any, get_type_hints # type: ignore @@ -118,6 +119,8 @@ def generate(t: Any) -> None: def main() -> None: + assert sys.version_info >= (3, 9) + print(header) print( "from playwright._impl._sync_base import EventContextManager, SyncBase, mapping"