diff --git a/python/docs/api/class-apiresponse.mdx b/python/docs/api/class-apiresponse.mdx index b80b4f633c5..28c5bcc1abb 100644 --- a/python/docs/api/class-apiresponse.mdx +++ b/python/docs/api/class-apiresponse.mdx @@ -95,6 +95,44 @@ api_response.dispose() --- +### json {#api-response-json} + +Added in: v1.16apiResponse.json + +Returns the JSON representation of response body. + +This method will throw if the response body is not parsable via `JSON.parse`. + +**Usage** + +```python +api_response.json() +``` + +**Returns** +- [Serializable]# + +--- + +### text {#api-response-text} + +Added in: v1.16apiResponse.text + +Returns the text representation of response body. + +**Usage** + +```python +api_response.text() +``` + +**Returns** +- [str]# + +--- + +## Properties + ### headers {#api-response-headers} Added in: v1.16apiResponse.headers @@ -135,25 +173,6 @@ api_response.headers_array --- -### json {#api-response-json} - -Added in: v1.16apiResponse.json - -Returns the JSON representation of response body. - -This method will throw if the response body is not parsable via `JSON.parse`. - -**Usage** - -```python -api_response.json() -``` - -**Returns** -- [Serializable]# - ---- - ### ok {#api-response-ok} Added in: v1.16apiResponse.ok @@ -205,23 +224,6 @@ api_response.status_text --- -### text {#api-response-text} - -Added in: v1.16apiResponse.text - -Returns the text representation of response body. - -**Usage** - -```python -api_response.text() -``` - -**Returns** -- [str]# - ---- - ### url {#api-response-url} Added in: v1.16apiResponse.url diff --git a/python/docs/api/class-browser.mdx b/python/docs/api/class-browser.mdx index d4ad0f50974..91f2edd251f 100644 --- a/python/docs/api/class-browser.mdx +++ b/python/docs/api/class-browser.mdx @@ -62,23 +62,6 @@ asyncio.run(main()) ## Methods -### browser_type {#browser-browser-type} - -Added in: v1.23browser.browser_type - -Get the browser type (chromium, firefox or webkit) that the browser belongs to. - -**Usage** - -```python -browser.browser_type -``` - -**Returns** -- [BrowserType]# - ---- - ### close {#browser-close} Added in: v1.8browser.close @@ -101,66 +84,6 @@ browser.close() --- -### contexts {#browser-contexts} - -Added in: v1.8browser.contexts - -Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts. - -**Usage** - - - - -```py -browser = pw.webkit.launch() -print(len(browser.contexts())) # prints `0` -context = browser.new_context() -print(len(browser.contexts())) # prints `1` -``` - - - - -```py -browser = await pw.webkit.launch() -print(len(browser.contexts())) # prints `0` -context = await browser.new_context() -print(len(browser.contexts())) # prints `1` -``` - - - - -**Returns** -- [List]\[[BrowserContext]\]# - ---- - -### is_connected {#browser-is-connected} - -Added in: v1.8browser.is_connected - -Indicates that the browser is connected. - -**Usage** - -```python -browser.is_connected() -``` - -**Returns** -- [bool]# - ---- - ### new_browser_cdp_session {#browser-new-browser-cdp-session} Added in: v1.11browser.new_browser_cdp_session @@ -732,6 +655,85 @@ browser.stop_tracing() --- +## Properties + +### browser_type {#browser-browser-type} + +Added in: v1.23browser.browser_type + +Get the browser type (chromium, firefox or webkit) that the browser belongs to. + +**Usage** + +```python +browser.browser_type +``` + +**Returns** +- [BrowserType]# + +--- + +### contexts {#browser-contexts} + +Added in: v1.8browser.contexts + +Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts. + +**Usage** + + + + +```py +browser = pw.webkit.launch() +print(len(browser.contexts())) # prints `0` +context = browser.new_context() +print(len(browser.contexts())) # prints `1` +``` + + + + +```py +browser = await pw.webkit.launch() +print(len(browser.contexts())) # prints `0` +context = await browser.new_context() +print(len(browser.contexts())) # prints `1` +``` + + + + +**Returns** +- [List]\[[BrowserContext]\]# + +--- + +### is_connected {#browser-is-connected} + +Added in: v1.8browser.is_connected + +Indicates that the browser is connected. + +**Usage** + +```python +browser.is_connected() +``` + +**Returns** +- [bool]# + +--- + ### version {#browser-version} Added in: v1.8browser.version diff --git a/python/docs/api/class-browsercontext.mdx b/python/docs/api/class-browsercontext.mdx index 95fcc703d54..8673dd2d536 100644 --- a/python/docs/api/class-browsercontext.mdx +++ b/python/docs/api/class-browsercontext.mdx @@ -182,44 +182,6 @@ The order of evaluation of multiple scripts installed via [browser_context.add_i --- -### background_pages {#browser-context-background-pages} - -Added in: v1.11browserContext.background_pages - -:::note -Background pages are only supported on Chromium-based browsers. -::: - -All existing background pages in the context. - -**Usage** - -```python -browser_context.background_pages -``` - -**Returns** -- [List]\[[Page]\]# - ---- - -### browser {#browser-context-browser} - -Added in: v1.8browserContext.browser - -Returns the browser instance of the context. If it was launched as a persistent context null gets returned. - -**Usage** - -```python -browser_context.browser -``` - -**Returns** -- [NoneType]|[Browser]# - ---- - ### clear_cookies {#browser-context-clear-cookies} Added in: v1.8browserContext.clear_cookies @@ -768,23 +730,6 @@ browser_context.new_page() --- -### pages {#browser-context-pages} - -Added in: v1.8browserContext.pages - -Returns all open pages in the context. - -**Usage** - -```python -browser_context.pages -``` - -**Returns** -- [List]\[[Page]\]# - ---- - ### route {#browser-context-route} Added in: v1.8browserContext.route @@ -964,27 +909,6 @@ browser_context.route_from_har(har, **kwargs) --- -### service_workers {#browser-context-service-workers} - -Added in: v1.11browserContext.service_workers - -:::note -Service workers are only supported on Chromium-based browsers. -::: - -All existing service workers in the context. - -**Usage** - -```python -browser_context.service_workers -``` - -**Returns** -- [List]\[[Worker]\]# - ---- - ### set_default_navigation_timeout {#browser-context-set-default-navigation-timeout} Added in: v1.8browserContext.set_default_navigation_timeout @@ -1246,6 +1170,61 @@ browser_context.wait_for_event(event, **kwargs) ## Properties +### background_pages {#browser-context-background-pages} + +Added in: v1.11browserContext.background_pages + +:::note +Background pages are only supported on Chromium-based browsers. +::: + +All existing background pages in the context. + +**Usage** + +```python +browser_context.background_pages +``` + +**Returns** +- [List]\[[Page]\]# + +--- + +### browser {#browser-context-browser} + +Added in: v1.8browserContext.browser + +Returns the browser instance of the context. If it was launched as a persistent context null gets returned. + +**Usage** + +```python +browser_context.browser +``` + +**Returns** +- [NoneType]|[Browser]# + +--- + +### pages {#browser-context-pages} + +Added in: v1.8browserContext.pages + +Returns all open pages in the context. + +**Usage** + +```python +browser_context.pages +``` + +**Returns** +- [List]\[[Page]\]# + +--- + ### request {#browser-context-request} Added in: v1.16browserContext.request @@ -1263,6 +1242,27 @@ browser_context.request --- +### service_workers {#browser-context-service-workers} + +Added in: v1.11browserContext.service_workers + +:::note +Service workers are only supported on Chromium-based browsers. +::: + +All existing service workers in the context. + +**Usage** + +```python +browser_context.service_workers +``` + +**Returns** +- [List]\[[Worker]\]# + +--- + ### tracing {#browser-context-tracing} Added in: v1.12browserContext.tracing diff --git a/python/docs/api/class-browsertype.mdx b/python/docs/api/class-browsertype.mdx index c92abfb203d..0e69588b8d0 100644 --- a/python/docs/api/class-browsertype.mdx +++ b/python/docs/api/class-browsertype.mdx @@ -169,23 +169,6 @@ page = default_context.pages[0] --- -### executable_path {#browser-type-executable-path} - -Added in: v1.8browserType.executable_path - -A path where Playwright expects to find a bundled browser executable. - -**Usage** - -```python -browser_type.executable_path -``` - -**Returns** -- [str]# - ---- - ### launch {#browser-type-launch} Added in: v1.8browserType.launch @@ -515,6 +498,25 @@ browser_type.launch_persistent_context(user_data_dir, **kwargs) --- +## Properties + +### executable_path {#browser-type-executable-path} + +Added in: v1.8browserType.executable_path + +A path where Playwright expects to find a bundled browser executable. + +**Usage** + +```python +browser_type.executable_path +``` + +**Returns** +- [str]# + +--- + ### name {#browser-type-name} Added in: v1.8browserType.name diff --git a/python/docs/api/class-consolemessage.mdx b/python/docs/api/class-consolemessage.mdx index b6693a581b1..2c39612ba3a 100644 --- a/python/docs/api/class-consolemessage.mdx +++ b/python/docs/api/class-consolemessage.mdx @@ -64,7 +64,7 @@ await msg.args[1].json_value() # 42 --- -## Methods +## Properties ### args {#console-message-args} diff --git a/python/docs/api/class-dialog.mdx b/python/docs/api/class-dialog.mdx index 24f0a95a6e6..a45b7101678 100644 --- a/python/docs/api/class-dialog.mdx +++ b/python/docs/api/class-dialog.mdx @@ -97,35 +97,37 @@ dialog.accept(**kwargs) --- -### default_value {#dialog-default-value} +### dismiss {#dialog-dismiss} -Added in: v1.8dialog.default_value +Added in: v1.8dialog.dismiss -If dialog is prompt, returns default prompt value. Otherwise, returns empty string. +Returns when the dialog has been dismissed. **Usage** ```python -dialog.default_value +dialog.dismiss() ``` -**Returns** -- [str]# - --- -### dismiss {#dialog-dismiss} +## Properties -Added in: v1.8dialog.dismiss +### default_value {#dialog-default-value} -Returns when the dialog has been dismissed. +Added in: v1.8dialog.default_value + +If dialog is prompt, returns default prompt value. Otherwise, returns empty string. **Usage** ```python -dialog.dismiss() +dialog.default_value ``` +**Returns** +- [str]# + --- ### message {#dialog-message} diff --git a/python/docs/api/class-download.mdx b/python/docs/api/class-download.mdx index ede17e0677b..0dbd2aa6947 100644 --- a/python/docs/api/class-download.mdx +++ b/python/docs/api/class-download.mdx @@ -95,23 +95,6 @@ download.failure() --- -### page {#download-page} - -Added in: v1.12download.page - -Get the page that the download belongs to. - -**Usage** - -```python -download.page -``` - -**Returns** -- [Page]# - ---- - ### path {#download-path} Added in: v1.8download.path @@ -150,6 +133,25 @@ download.save_as(path) --- +## Properties + +### page {#download-page} + +Added in: v1.12download.page + +Get the page that the download belongs to. + +**Usage** + +```python +download.page +``` + +**Returns** +- [Page]# + +--- + ### suggested_filename {#download-suggested-filename} Added in: v1.8download.suggested_filename diff --git a/python/docs/api/class-filechooser.mdx b/python/docs/api/class-filechooser.mdx index 6d7b17524c3..73a1943c75d 100644 --- a/python/docs/api/class-filechooser.mdx +++ b/python/docs/api/class-filechooser.mdx @@ -44,6 +44,41 @@ await file_chooser.set_files("myfile.pdf") ## Methods +### set_files {#file-chooser-set-files} + +Added in: v1.8fileChooser.set_files + +Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files. + +**Usage** + +```python +file_chooser.set_files(files) +file_chooser.set_files(files, **kwargs) +``` + +**Arguments** +- `files` [Union]\[[str], [pathlib.Path]\]|[List]\[[Union]\[[str], [pathlib.Path]\]\]|[Dict]|[List]\[[Dict]\]# + - `name` [str] + + File name + - `mimeType` [str] + + File type + - `buffer` [bytes] + + File content +- `no_wait_after` [bool] *(optional)*# + + Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`. +- `timeout` [float] *(optional)*# + + Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browser_context.set_default_timeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout) or [page.set_default_timeout()](/api/class-page.mdx#page-set-default-timeout) methods. + +--- + +## Properties + ### element {#file-chooser-element} Added in: v1.8fileChooser.element @@ -93,39 +128,6 @@ file_chooser.page **Returns** - [Page]# ---- - -### set_files {#file-chooser-set-files} - -Added in: v1.8fileChooser.set_files - -Sets the value of the file input this chooser is associated with. If some of the `filePaths` are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files. - -**Usage** - -```python -file_chooser.set_files(files) -file_chooser.set_files(files, **kwargs) -``` - -**Arguments** -- `files` [Union]\[[str], [pathlib.Path]\]|[List]\[[Union]\[[str], [pathlib.Path]\]\]|[Dict]|[List]\[[Dict]\]# - - `name` [str] - - File name - - `mimeType` [str] - - File type - - `buffer` [bytes] - - File content -- `no_wait_after` [bool] *(optional)*# - - Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults to `false`. -- `timeout` [float] *(optional)*# - - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browser_context.set_default_timeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout) or [page.set_default_timeout()](/api/class-page.mdx#page-set-default-timeout) methods. - [Accessibility]: /api/class-accessibility.mdx "Accessibility" [APIRequest]: /api/class-apirequest.mdx "APIRequest" diff --git a/python/docs/api/class-frame.mdx b/python/docs/api/class-frame.mdx index cce2cbabeec..c7182ee821c 100644 --- a/python/docs/api/class-frame.mdx +++ b/python/docs/api/class-frame.mdx @@ -145,21 +145,6 @@ frame.add_style_tag(**kwargs) --- -### child_frames {#frame-child-frames} - -Added in: v1.8frame.child_frames - -**Usage** - -```python -frame.child_frames -``` - -**Returns** -- [List]\[[Frame]\]# - ---- - ### content {#frame-content} Added in: v1.8frame.content @@ -1062,23 +1047,6 @@ frame.goto(url, **kwargs) --- -### is_detached {#frame-is-detached} - -Added in: v1.8frame.is_detached - -Returns `true` if the frame has been detached, or `false` otherwise. - -**Usage** - -```python -frame.is_detached() -``` - -**Returns** -- [bool]# - ---- - ### is_enabled {#frame-is-enabled} Added in: v1.8frame.is_enabled @@ -1151,63 +1119,6 @@ frame.locator(selector, **kwargs) --- -### name {#frame-name} - -Added in: v1.8frame.name - -Returns frame's name attribute as specified in the tag. - -If the name is empty, returns the id attribute instead. - -:::note -This value is calculated once when the frame is created, and will not update if the attribute is changed later. -::: - -**Usage** - -```python -frame.name -``` - -**Returns** -- [str]# - ---- - -### page {#frame-page} - -Added in: v1.8frame.page - -Returns the page containing this frame. - -**Usage** - -```python -frame.page -``` - -**Returns** -- [Page]# - ---- - -### parent_frame {#frame-parent-frame} - -Added in: v1.8frame.parent_frame - -Parent frame, if any. Detached frames and main frames return `null`. - -**Usage** - -```python -frame.parent_frame -``` - -**Returns** -- [NoneType]|[Frame]# - ---- - ### set_content {#frame-set-content} Added in: v1.8frame.set_content @@ -1253,23 +1164,6 @@ frame.title() --- -### url {#frame-url} - -Added in: v1.8frame.url - -Returns frame's url. - -**Usage** - -```python -frame.url -``` - -**Returns** -- [str]# - ---- - ### wait_for_function {#frame-wait-for-function} Added in: v1.8frame.wait_for_function @@ -1476,6 +1370,114 @@ await frame.wait_for_url("**/target.html") --- +## Properties + +### child_frames {#frame-child-frames} + +Added in: v1.8frame.child_frames + +**Usage** + +```python +frame.child_frames +``` + +**Returns** +- [List]\[[Frame]\]# + +--- + +### is_detached {#frame-is-detached} + +Added in: v1.8frame.is_detached + +Returns `true` if the frame has been detached, or `false` otherwise. + +**Usage** + +```python +frame.is_detached() +``` + +**Returns** +- [bool]# + +--- + +### name {#frame-name} + +Added in: v1.8frame.name + +Returns frame's name attribute as specified in the tag. + +If the name is empty, returns the id attribute instead. + +:::note +This value is calculated once when the frame is created, and will not update if the attribute is changed later. +::: + +**Usage** + +```python +frame.name +``` + +**Returns** +- [str]# + +--- + +### page {#frame-page} + +Added in: v1.8frame.page + +Returns the page containing this frame. + +**Usage** + +```python +frame.page +``` + +**Returns** +- [Page]# + +--- + +### parent_frame {#frame-parent-frame} + +Added in: v1.8frame.parent_frame + +Parent frame, if any. Detached frames and main frames return `null`. + +**Usage** + +```python +frame.parent_frame +``` + +**Returns** +- [NoneType]|[Frame]# + +--- + +### url {#frame-url} + +Added in: v1.8frame.url + +Returns frame's url. + +**Usage** + +```python +frame.url +``` + +**Returns** +- [str]# + +--- + ## Deprecated ### check {#frame-check} diff --git a/python/docs/api/class-framelocator.mdx b/python/docs/api/class-framelocator.mdx index 5f96690794e..e62bbc3c537 100644 --- a/python/docs/api/class-framelocator.mdx +++ b/python/docs/api/class-framelocator.mdx @@ -104,23 +104,6 @@ frameLocator = locator.frame_locator(":scope") ## Methods -### first {#frame-locator-first} - -Added in: v1.17frameLocator.first - -Returns locator to the first matching frame. - -**Usage** - -```python -frame_locator.first -``` - -**Returns** -- [FrameLocator]# - ---- - ### frame_locator {#frame-locator-frame-locator} Added in: v1.17frameLocator.frame_locator @@ -612,23 +595,6 @@ await expect(page.get_by_title("Issues count")).to_have_text("25 issues") --- -### last {#frame-locator-last} - -Added in: v1.17frameLocator.last - -Returns locator to the last matching frame. - -**Usage** - -```python -frame_locator.last -``` - -**Returns** -- [FrameLocator]# - ---- - ### locator {#frame-locator-locator} Added in: v1.17frameLocator.locator @@ -688,6 +654,42 @@ frame_locator.nth(index) **Returns** - [FrameLocator]# +--- + +## Properties + +### first {#frame-locator-first} + +Added in: v1.17frameLocator.first + +Returns locator to the first matching frame. + +**Usage** + +```python +frame_locator.first +``` + +**Returns** +- [FrameLocator]# + +--- + +### last {#frame-locator-last} + +Added in: v1.17frameLocator.last + +Returns locator to the last matching frame. + +**Usage** + +```python +frame_locator.last +``` + +**Returns** +- [FrameLocator]# + [Accessibility]: /api/class-accessibility.mdx "Accessibility" [APIRequest]: /api/class-apirequest.mdx "APIRequest" diff --git a/python/docs/api/class-jshandle.mdx b/python/docs/api/class-jshandle.mdx index 52896067284..79c66074394 100644 --- a/python/docs/api/class-jshandle.mdx +++ b/python/docs/api/class-jshandle.mdx @@ -44,23 +44,6 @@ JSHandle instances can be used as an argument in [page.eval_on_selector()](/api/ ## Methods -### as_element {#js-handle-as-element} - -Added in: v1.8jsHandle.as_element - -Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle]. - -**Usage** - -```python -js_handle.as_element() -``` - -**Returns** -- [NoneType]|[ElementHandle]# - ---- - ### dispose {#js-handle-dispose} Added in: v1.8jsHandle.dispose @@ -246,6 +229,25 @@ js_handle.json_value() **Returns** - [Serializable]# +--- + +## Properties + +### as_element {#js-handle-as-element} + +Added in: v1.8jsHandle.as_element + +Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle]. + +**Usage** + +```python +js_handle.as_element() +``` + +**Returns** +- [NoneType]|[ElementHandle]# + [Accessibility]: /api/class-accessibility.mdx "Accessibility" [APIRequest]: /api/class-apirequest.mdx "APIRequest" diff --git a/python/docs/api/class-locator.mdx b/python/docs/api/class-locator.mdx index 1cad7f1d368..6af9395b29a 100644 --- a/python/docs/api/class-locator.mdx +++ b/python/docs/api/class-locator.mdx @@ -1046,23 +1046,6 @@ await row_locator.filter(has_text="text in column 1").filter( --- -### first {#locator-first} - -Added in: v1.14locator.first - -Returns locator to the first matching element. - -**Usage** - -```python -locator.first -``` - -**Returns** -- [Locator]# - ---- - ### focus {#locator-focus} Added in: v1.14locator.focus @@ -2057,43 +2040,6 @@ visible = await page.get_by_role("button").is_visible() --- -### last {#locator-last} - -Added in: v1.14locator.last - -Returns locator to the last matching element. - -**Usage** - - - - -```py -banana = page.get_by_role("listitem").last -``` - - - - -```py -banana = await page.get_by_role("listitem").last -``` - - - - -**Returns** -- [Locator]# - ---- - ### locator {#locator-locator} Added in: v1.14locator.locator @@ -2229,23 +2175,6 @@ await new_email.click() --- -### page {#locator-page} - -Added in: v1.19locator.page - -A page this locator belongs to. - -**Usage** - -```python -locator.page -``` - -**Returns** -- [Page]# - ---- - ### press {#locator-press} Added in: v1.14locator.press @@ -2991,6 +2920,79 @@ await order_sent.wait_for() --- +## Properties + +### first {#locator-first} + +Added in: v1.14locator.first + +Returns locator to the first matching element. + +**Usage** + +```python +locator.first +``` + +**Returns** +- [Locator]# + +--- + +### last {#locator-last} + +Added in: v1.14locator.last + +Returns locator to the last matching element. + +**Usage** + + + + +```py +banana = page.get_by_role("listitem").last +``` + + + + +```py +banana = await page.get_by_role("listitem").last +``` + + + + +**Returns** +- [Locator]# + +--- + +### page {#locator-page} + +Added in: v1.19locator.page + +A page this locator belongs to. + +**Usage** + +```python +locator.page +``` + +**Returns** +- [Page]# + +--- + ## Deprecated ### element_handle {#locator-element-handle} diff --git a/python/docs/api/class-page.mdx b/python/docs/api/class-page.mdx index 55201b739a6..81c7793adec 100644 --- a/python/docs/api/class-page.mdx +++ b/python/docs/api/class-page.mdx @@ -263,23 +263,6 @@ page.content() --- -### context {#page-context} - -Added in: v1.8page.context - -Get the browser context that the page belongs to. - -**Usage** - -```python -page.context -``` - -**Returns** -- [BrowserContext]# - ---- - ### drag_and_drop {#page-drag-and-drop} Added in: v1.13page.drag_and_drop @@ -1382,23 +1365,6 @@ await locator.click() --- -### frames {#page-frames} - -Added in: v1.8page.frames - -An array of all frames attached to the page. - -**Usage** - -```python -page.frames -``` - -**Returns** -- [List]\[[Frame]\]# - ---- - ### get_by_alt_text {#page-get-by-alt-text} Added in: v1.27page.get_by_alt_text @@ -1985,23 +1951,6 @@ page.goto(url, **kwargs) --- -### is_closed {#page-is-closed} - -Added in: v1.8page.is_closed - -Indicates that the page has been closed. - -**Usage** - -```python -page.is_closed() -``` - -**Returns** -- [bool]# - ---- - ### locator {#page-locator} Added in: v1.14page.locator @@ -2043,23 +1992,6 @@ page.locator(selector, **kwargs) --- -### main_frame {#page-main-frame} - -Added in: v1.8page.main_frame - -The page's main frame. Page is guaranteed to have a main frame which persists during navigations. - -**Usage** - -```python -page.main_frame -``` - -**Returns** -- [Frame]# - ---- - ### opener {#page-opener} Added in: v1.8page.opener @@ -2711,59 +2643,6 @@ page.unroute(url, **kwargs) --- -### url {#page-url} - -Added in: v1.8page.url - -**Usage** - -```python -page.url -``` - -**Returns** -- [str]# - ---- - -### video {#page-video} - -Added in: v1.8page.video - -Video object associated with this page. - -**Usage** - -```python -page.video -``` - -**Returns** -- [NoneType]|[Video]# - ---- - -### viewport_size {#page-viewport-size} - -Added in: v1.8page.viewport_size - -**Usage** - -```python -page.viewport_size -``` - -**Returns** -- [NoneType]|[Dict]# - - `width` [int] - - page width in pixels. - - `height` [int] - - page height in pixels. - ---- - ### wait_for_event {#page-wait-for-event-2} Added in: v1.8page.wait_for_event @@ -3037,28 +2916,58 @@ await page.wait_for_url("**/target.html") --- -### workers {#page-workers} +## Properties -Added in: v1.8page.workers +### context {#page-context} -This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) associated with the page. +Added in: v1.8page.context -:::note -This does not contain ServiceWorkers -::: +Get the browser context that the page belongs to. **Usage** ```python -page.workers +page.context ``` **Returns** -- [List]\[[Worker]\]# +- [BrowserContext]# --- -## Properties +### frames {#page-frames} + +Added in: v1.8page.frames + +An array of all frames attached to the page. + +**Usage** + +```python +page.frames +``` + +**Returns** +- [List]\[[Frame]\]# + +--- + +### is_closed {#page-is-closed} + +Added in: v1.8page.is_closed + +Indicates that the page has been closed. + +**Usage** + +```python +page.is_closed() +``` + +**Returns** +- [bool]# + +--- ### keyboard {#page-keyboard} @@ -3075,6 +2984,23 @@ page.keyboard --- +### main_frame {#page-main-frame} + +Added in: v1.8page.main_frame + +The page's main frame. Page is guaranteed to have a main frame which persists during navigations. + +**Usage** + +```python +page.main_frame +``` + +**Returns** +- [Frame]# + +--- + ### mouse {#page-mouse} Added in: v1.8page.mouse @@ -3122,6 +3048,80 @@ page.touchscreen --- +### url {#page-url} + +Added in: v1.8page.url + +**Usage** + +```python +page.url +``` + +**Returns** +- [str]# + +--- + +### video {#page-video} + +Added in: v1.8page.video + +Video object associated with this page. + +**Usage** + +```python +page.video +``` + +**Returns** +- [NoneType]|[Video]# + +--- + +### viewport_size {#page-viewport-size} + +Added in: v1.8page.viewport_size + +**Usage** + +```python +page.viewport_size +``` + +**Returns** +- [NoneType]|[Dict]# + - `width` [int] + + page width in pixels. + - `height` [int] + + page height in pixels. + +--- + +### workers {#page-workers} + +Added in: v1.8page.workers + +This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) associated with the page. + +:::note +This does not contain ServiceWorkers +::: + +**Usage** + +```python +page.workers +``` + +**Returns** +- [List]\[[Worker]\]# + +--- + ## Events ### on("close") {#page-event-close} diff --git a/python/docs/api/class-request.mdx b/python/docs/api/class-request.mdx index 481485b87d8..d1ab0298378 100644 --- a/python/docs/api/class-request.mdx +++ b/python/docs/api/class-request.mdx @@ -42,101 +42,149 @@ request.all_headers() --- -### failure {#request-failure} +### header_value {#request-header-value} -Added in: v1.8request.failure +Added in: v1.15request.header_value -The method returns `null` unless this request has failed, as reported by `requestfailed` event. +Returns the value of the header matching the name. The name is case insensitive. **Usage** -Example of logging of all the failed requests: +```python +request.header_value(name) +``` -```py -page.on("requestfailed", lambda request: print(request.url + " " + request.failure)) +**Arguments** +- `name` [str]# + + Name of the header. + +**Returns** +- [NoneType]|[str]# + +--- + +### headers_array {#request-headers-array} + +Added in: v1.15request.headers_array + +An array with all the request HTTP headers associated with this request. Unlike [request.all_headers()](/api/class-request.mdx#request-all-headers), header names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times. + +**Usage** + +```python +request.headers_array() ``` **Returns** -- [NoneType]|[str]# +- [List]\[[Dict]\]# + - `name` [str] + + Name of the header. + - `value` [str] + + Value of the header. --- -### frame {#request-frame} +### response {#request-response} -Added in: v1.8request.frame +Added in: v1.8request.response -Returns the [Frame] that initiated this request. +Returns the matching [Response] object, or `null` if the response was not received due to error. **Usage** ```python -request.frame +request.response() ``` **Returns** -- [Frame]# +- [NoneType]|[Response]# --- -### header_value {#request-header-value} +### sizes {#request-sizes} -Added in: v1.15request.header_value +Added in: v1.15request.sizes -Returns the value of the header matching the name. The name is case insensitive. +Returns resource size information for given request. **Usage** ```python -request.header_value(name) +request.sizes() ``` -**Arguments** -- `name` [str]# - - Name of the header. +**Returns** +- [Dict]# + - `requestBodySize` [int] + + Size of the request body (POST data payload) in bytes. Set to 0 if there was no body. + - `requestHeadersSize` [int] + + Total number of bytes from the start of the HTTP request message until (and including) the double CRLF before the body. + - `responseBodySize` [int] + + Size of the received response body (encoded) in bytes. + - `responseHeadersSize` [int] + + Total number of bytes from the start of the HTTP response message until (and including) the double CRLF before the body. + +--- + +## Properties + +### failure {#request-failure} + +Added in: v1.8request.failure + +The method returns `null` unless this request has failed, as reported by `requestfailed` event. + +**Usage** + +Example of logging of all the failed requests: + +```py +page.on("requestfailed", lambda request: print(request.url + " " + request.failure)) +``` **Returns** -- [NoneType]|[str]# +- [NoneType]|[str]# --- -### headers {#request-headers} +### frame {#request-frame} -Added in: v1.8request.headers +Added in: v1.8request.frame -An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return security-related headers, including cookie-related ones. You can use [request.all_headers()](/api/class-request.mdx#request-all-headers) for complete list of headers that include `cookie` information. +Returns the [Frame] that initiated this request. **Usage** ```python -request.headers +request.frame ``` **Returns** -- [Dict]\[[str], [str]\]# +- [Frame]# --- -### headers_array {#request-headers-array} +### headers {#request-headers} -Added in: v1.15request.headers_array +Added in: v1.8request.headers -An array with all the request HTTP headers associated with this request. Unlike [request.all_headers()](/api/class-request.mdx#request-all-headers), header names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times. +An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return security-related headers, including cookie-related ones. You can use [request.all_headers()](/api/class-request.mdx#request-all-headers) for complete list of headers that include `cookie` information. **Usage** ```python -request.headers_array() +request.headers ``` **Returns** -- [List]\[[Dict]\]# - - `name` [str] - - Name of the header. - - `value` [str] - - Value of the header. +- [Dict]\[[str], [str]\]# --- @@ -334,52 +382,6 @@ request.resource_type --- -### response {#request-response} - -Added in: v1.8request.response - -Returns the matching [Response] object, or `null` if the response was not received due to error. - -**Usage** - -```python -request.response() -``` - -**Returns** -- [NoneType]|[Response]# - ---- - -### sizes {#request-sizes} - -Added in: v1.15request.sizes - -Returns resource size information for given request. - -**Usage** - -```python -request.sizes() -``` - -**Returns** -- [Dict]# - - `requestBodySize` [int] - - Size of the request body (POST data payload) in bytes. Set to 0 if there was no body. - - `requestHeadersSize` [int] - - Total number of bytes from the start of the HTTP request message until (and including) the double CRLF before the body. - - `responseBodySize` [int] - - Size of the received response body (encoded) in bytes. - - `responseHeadersSize` [int] - - Total number of bytes from the start of the HTTP response message until (and including) the double CRLF before the body. - ---- - ### timing {#request-timing} Added in: v1.8request.timing diff --git a/python/docs/api/class-response.mdx b/python/docs/api/class-response.mdx index c9d8fad13c6..bba2f69ddbb 100644 --- a/python/docs/api/class-response.mdx +++ b/python/docs/api/class-response.mdx @@ -65,40 +65,6 @@ response.finished() --- -### frame {#response-frame} - -Added in: v1.8response.frame - -Returns the [Frame] that initiated this response. - -**Usage** - -```python -response.frame -``` - -**Returns** -- [Frame]# - ---- - -### from_service_worker {#response-from-service-worker} - -Added in: v1.23response.from_service_worker - -Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)). - -**Usage** - -```python -response.from_service_worker -``` - -**Returns** -- [bool]# - ---- - ### header_value {#response-header-value} Added in: v1.15response.header_value @@ -143,23 +109,6 @@ response.header_values(name) --- -### headers {#response-headers} - -Added in: v1.8response.headers - -An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return security-related headers, including cookie-related ones. You can use [response.all_headers()](/api/class-response.mdx#response-all-headers) for complete list of headers that include `cookie` information. - -**Usage** - -```python -response.headers -``` - -**Returns** -- [Dict]\[[str], [str]\]# - ---- - ### headers_array {#response-headers-array} Added in: v1.15response.headers_array @@ -202,40 +151,6 @@ response.json() --- -### ok {#response-ok} - -Added in: v1.8response.ok - -Contains a boolean stating whether the response was successful (status in the range 200-299) or not. - -**Usage** - -```python -response.ok -``` - -**Returns** -- [bool]# - ---- - -### request {#response-request} - -Added in: v1.8response.request - -Returns the matching [Request] object. - -**Usage** - -```python -response.request -``` - -**Returns** -- [Request]# - ---- - ### security_details {#response-security-details} Added in: v1.13response.security_details @@ -290,54 +205,141 @@ response.server_addr() --- -### status {#response-status} +### text {#response-text} -Added in: v1.8response.status +Added in: v1.8response.text -Contains the status code of the response (e.g., 200 for a success). +Returns the text representation of response body. **Usage** ```python -response.status +response.text() ``` **Returns** -- [int]# +- [str]# --- -### status_text {#response-status-text} +## Properties -Added in: v1.8response.status_text +### frame {#response-frame} -Contains the status text of the response (e.g. usually an "OK" for a success). +Added in: v1.8response.frame + +Returns the [Frame] that initiated this response. **Usage** ```python -response.status_text +response.frame ``` **Returns** -- [str]# +- [Frame]# --- -### text {#response-text} +### from_service_worker {#response-from-service-worker} -Added in: v1.8response.text +Added in: v1.23response.from_service_worker -Returns the text representation of response body. +Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)). **Usage** ```python -response.text() +response.from_service_worker ``` **Returns** -- [str]# +- [bool]# + +--- + +### headers {#response-headers} + +Added in: v1.8response.headers + +An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return security-related headers, including cookie-related ones. You can use [response.all_headers()](/api/class-response.mdx#response-all-headers) for complete list of headers that include `cookie` information. + +**Usage** + +```python +response.headers +``` + +**Returns** +- [Dict]\[[str], [str]\]# + +--- + +### ok {#response-ok} + +Added in: v1.8response.ok + +Contains a boolean stating whether the response was successful (status in the range 200-299) or not. + +**Usage** + +```python +response.ok +``` + +**Returns** +- [bool]# + +--- + +### request {#response-request} + +Added in: v1.8response.request + +Returns the matching [Request] object. + +**Usage** + +```python +response.request +``` + +**Returns** +- [Request]# + +--- + +### status {#response-status} + +Added in: v1.8response.status + +Contains the status code of the response (e.g., 200 for a success). + +**Usage** + +```python +response.status +``` + +**Returns** +- [int]# + +--- + +### status_text {#response-status-text} + +Added in: v1.8response.status_text + +Contains the status text of the response (e.g. usually an "OK" for a success). + +**Usage** + +```python +response.status_text +``` + +**Returns** +- [str]# --- diff --git a/python/docs/api/class-route.mdx b/python/docs/api/class-route.mdx index a6bb757abb0..342c0a37442 100644 --- a/python/docs/api/class-route.mdx +++ b/python/docs/api/class-route.mdx @@ -440,6 +440,8 @@ await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data. --- +## Properties + ### request {#route-request} Added in: v1.8route.request diff --git a/python/docs/api/class-websocket.mdx b/python/docs/api/class-websocket.mdx index 3f8ba34d930..e7c65d56c4f 100644 --- a/python/docs/api/class-websocket.mdx +++ b/python/docs/api/class-websocket.mdx @@ -43,70 +43,72 @@ web_socket.expect_event(event, **kwargs) --- -### is_closed {#web-socket-is-closed} +### wait_for_event {#web-socket-wait-for-event-2} -Added in: v1.8webSocket.is_closed +Added in: v1.8webSocket.wait_for_event -Indicates that the web socket has been closed. +:::note +In most cases, you should use [web_socket.expect_event()](/api/class-websocket.mdx#web-socket-wait-for-event). +::: + +Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is fired. **Usage** ```python -web_socket.is_closed() +web_socket.wait_for_event(event) +web_socket.wait_for_event(event, **kwargs) ``` +**Arguments** +- `event` [str]# + + Event name, same one typically passed into `*.on(event)`. +- `predicate` [Callable] *(optional)*# + + Receives the event data and resolves to truthy value when the waiting should resolve. +- `timeout` [float] *(optional)*# + + Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browser_context.set_default_timeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout). + **Returns** -- [bool]# +- [Any]# --- -### url {#web-socket-url} +## Properties -Added in: v1.8webSocket.url +### is_closed {#web-socket-is-closed} -Contains the URL of the WebSocket. +Added in: v1.8webSocket.is_closed + +Indicates that the web socket has been closed. **Usage** ```python -web_socket.url +web_socket.is_closed() ``` **Returns** -- [str]# +- [bool]# --- -### wait_for_event {#web-socket-wait-for-event-2} - -Added in: v1.8webSocket.wait_for_event +### url {#web-socket-url} -:::note -In most cases, you should use [web_socket.expect_event()](/api/class-websocket.mdx#web-socket-wait-for-event). -::: +Added in: v1.8webSocket.url -Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is fired. +Contains the URL of the WebSocket. **Usage** ```python -web_socket.wait_for_event(event) -web_socket.wait_for_event(event, **kwargs) +web_socket.url ``` -**Arguments** -- `event` [str]# - - Event name, same one typically passed into `*.on(event)`. -- `predicate` [Callable] *(optional)*# - - Receives the event data and resolves to truthy value when the waiting should resolve. -- `timeout` [float] *(optional)*# - - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [browser_context.set_default_timeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout). - **Returns** -- [Any]# +- [str]# --- diff --git a/python/docs/api/class-worker.mdx b/python/docs/api/class-worker.mdx index d19593cc0a5..0eec2541762 100644 --- a/python/docs/api/class-worker.mdx +++ b/python/docs/api/class-worker.mdx @@ -86,6 +86,8 @@ worker.evaluate_handle(expression, **kwargs) --- +## Properties + ### url {#worker-url} Added in: v1.8worker.url diff --git a/src/generate.js b/src/generate.js index 76b305642bb..b3bf36d1565 100644 --- a/src/generate.js +++ b/src/generate.js @@ -85,10 +85,35 @@ async function getVersionForLanguageBindingCached(lang) { } async function generateDocsForLanguages () { - new Generator('js', await getVersionForLanguageBindingCached('js'), srcDir, path.join(__dirname, '..', 'nodejs', 'docs'), new JavaScriptFormatter()); - new Generator('python', await getVersionForLanguageBindingCached('python'), srcDir, path.join(__dirname, '..', 'python', 'docs'), new PythonFormatter()); - new Generator('java', await getVersionForLanguageBindingCached('java'), srcDir, path.join(__dirname, '..', 'java', 'docs'), new JavaFormatter()); - new Generator('csharp', await getVersionForLanguageBindingCached('csharp'), srcDir, path.join(__dirname, '..', 'dotnet', 'docs'), new CSharpFormatter()); + new Generator({ + lang: 'js', + version: await getVersionForLanguageBindingCached('js'), + srcDir, + outDir: path.join(__dirname, '..', 'nodejs', 'docs'), + formatter: new JavaScriptFormatter(), + }); + new Generator({ + lang: 'python', + version: await getVersionForLanguageBindingCached('python'), + srcDir, + outDir: path.join(__dirname, '..', 'python', 'docs'), + formatter: new PythonFormatter(), + renderSyncNoArgsMethodAsProperty: true, + }); + new Generator({ + lang: 'java', + version: await getVersionForLanguageBindingCached('java'), + srcDir, + outDir: path.join(__dirname, '..', 'java', 'docs'), + formatter: new JavaFormatter(), + }); + new Generator({ + lang: 'csharp', + version: await getVersionForLanguageBindingCached('csharp'), + srcDir, + outDir: path.join(__dirname, '..', 'dotnet', 'docs'), + formatter: new CSharpFormatter(), + }); }; /** diff --git a/src/generator.js b/src/generator.js index 2268dd6abbe..6de6f780984 100644 --- a/src/generator.js +++ b/src/generator.js @@ -72,17 +72,21 @@ class Generator { heading2ExplicitId = new Map(); /** - * @param {string} lang - * @param {string} version - * @param {string} srcDir - * @param {string} outDir - * @param {GeneratorFormatter} formatter + * @param {{ + * lang: string, + * version: string, + * srcDir: string, + * outDir: string, + * formatter: GeneratorFormatter, + * renderSyncNoArgsMethodAsProperty?: boolean, + * }} options */ - constructor(lang, version, srcDir, outDir, formatter) { + constructor({ lang, version, srcDir, outDir, formatter, renderSyncNoArgsMethodAsProperty }) { this.lang = lang; this.version = version; this.outDir = outDir; this.srcDir = srcDir; + this.renderSyncNoArgsMethodAsProperty = renderSyncNoArgsMethodAsProperty; /** @type {Set} */ this.generatedFiles = new Set(); this.formatter = formatter; @@ -161,8 +165,8 @@ import HTMLCard from '@site/src/components/HTMLCard'; text: '' }); clazz.membersArray.sort((m1, m2) => { - let { key: k1 } = memberSection(m1); - let { key: k2 } = memberSection(m2); + let { key: k1 } = this.memberSection(m1); + let { key: k2 } = this.memberSection(m2); k1 += toSnakeCase(m1.alias.replace(/\$\$eval/, '$$eval2')); k2 += toSnakeCase(m2.alias.replace(/\$\$eval/, '$$eval2')); return k1.localeCompare(k2); @@ -212,7 +216,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; text: '---' }); - const section = memberSection(member); + const section = this.memberSection(member); if (section.title !== memberSectionTitle) { memberSectionTitle = section.title; result.push({ @@ -343,6 +347,22 @@ ${this.documentation.renderLinksInText(member.discouraged)} return result; } + /** + * @param {docs.Member} member + */ + memberSection(member) { + if (member.deprecated || member.discouraged) + return { key: 'd', title: 'Deprecated' }; + if (member.kind === 'event') + return { key: 'c', title: 'Events' }; + const treatAsProperty = (this.renderSyncNoArgsMethodAsProperty && member.kind === 'method' && !member.async && member.argsArray.length === 0) + if (member.kind === 'property' || treatAsProperty) + return { key: 'b', title: 'Properties' }; + if (member.kind === 'method') + return { key: 'a', title: 'Methods' }; + throw new Error(`Unsupported member kind ${member.kind} for ${member.name}`); + } + /** * @param {string} text */ @@ -719,21 +739,6 @@ function writeFileSyncCached(file, content) { fs.writeFileSync(file, content); } -/** - * @param {docs.Member} member - */ -function memberSection(member) { - if (member.deprecated || member.discouraged) - return { key: 'd', title: 'Deprecated' }; - if (member.kind === 'event') - return { key: 'c', title: 'Events' }; - if (member.kind === 'method') - return { key: 'a', title: 'Methods' }; - if (member.kind === 'property') - return { key: 'b', title: 'Properties' }; - throw new Error(`Unsupported member kind ${member.kind} for ${member.name}`); -} - /** * @param {docs.Class} clazz */