diff --git a/README.md b/README.md index 4a378ad05..b994d5b02 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 104.0.5112.81 | ✅ | ✅ | ✅ | +| Chromium 105.0.5195.19 | ✅ | ✅ | ✅ | | WebKit 16.0 | ✅ | ✅ | ✅ | | Firefox 103.0 | ✅ | ✅ | ✅ | diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index fda9d9808..1b364aca9 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -427,7 +427,7 @@ def headers(self) -> typing.Dict[str, str]: def from_service_worker(self) -> bool: """Response.from_service_worker - Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via + 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)). Returns @@ -2528,7 +2528,7 @@ async def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -7995,7 +7995,7 @@ async def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -11047,7 +11047,7 @@ async def new_context( Creates a new browser context. It won't share cookies/cache with other browser contexts. - > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicilty close the returned + > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicitly close the returned context via `browser_context.close()` when your code is done with the `BrowserContext`, and before calling `browser.close()`. This will ensure the `context` is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved. @@ -13317,7 +13317,7 @@ async def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -14649,14 +14649,38 @@ async def to_contain_text( await expect(locator).to_contain_text(re.compile(r\"\\d messages\")) ``` - Note that if array is passed as an expected value, entire lists of elements can be asserted: + If you pass an array as an expected value, the expectations are: + 1. Locator resolves to a list of elements. + 1. Elements from a **subset** of this list contain text from the expected array, respectively. + 1. The matching subset of elements has the same order as the expected array. + 1. Each text value from the expected array is matched by some element from the list. + + For example, consider the following list: + + ```html + + ``` + + Let's see how we can use the assertion: ```py - import re from playwright.async_api import expect - locator = page.locator(\"list > .list-item\") - await expect(locator).to_contain_text([\"Text 1\", \"Text 4\", \"Text 5\"]) + # ✓ Contains the right items in the right order + await expect(page.locator(\"ul > li\")).to_contain_text([\"Text 1\", \"Text 3\", \"Text 4\"]) + + # ✖ Wrong order + await expect(page.locator(\"ul > li\")).to_contain_text([\"Text 3\", \"Text 2\"]) + + # ✖ No item contains this text + await expect(page.locator(\"ul > li\")).to_contain_text([\"Some 33\"]) + + # ✖ Locator points to the outer list element, not to the list items + await expect(page.locator(\"ul\")).to_contain_text([\"Text 3\"]) ``` Parameters @@ -15231,13 +15255,37 @@ async def to_have_text( await expect(locator).to_have_text(re.compile(r\"Welcome, .*\")) ``` - Note that if array is passed as an expected value, entire lists of elements can be asserted: + If you pass an array as an expected value, the expectations are: + 1. Locator resolves to a list of elements. + 1. The number of elements equals the number of expected values in the array. + 1. Elements from the list have text matching expected array values, one by one, in order. + + For example, consider the following list: + + ```html + + ``` + + Let's see how we can use the assertion: ```py from playwright.async_api import expect - locator = page.locator(\"list > .component\") - await expect(locator).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) + # ✓ Has the right items in the right order + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) + + # ✖ Wrong order + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 3\", \"Text 2\", \"Text 1\"]) + + # ✖ Last item does not match + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text\"]) + + # ✖ Locator points to the outer list element, not to the list items + await expect(page.locator(\"ul\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) ``` Parameters diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index b6462a36f..b949c7d77 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -429,7 +429,7 @@ def headers(self) -> typing.Dict[str, str]: def from_service_worker(self) -> bool: """Response.from_service_worker - Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via + 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)). Returns @@ -2554,7 +2554,7 @@ def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -8031,7 +8031,7 @@ def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -11081,7 +11081,7 @@ def new_context( Creates a new browser context. It won't share cookies/cache with other browser contexts. - > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicilty close the returned + > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicitly close the returned context via `browser_context.close()` when your code is done with the `BrowserContext`, and before calling `browser.close()`. This will ensure the `context` is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved. @@ -13404,7 +13404,7 @@ def screenshot( Defaults to `"device"`. mask : Union[List[Locator], NoneType] - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box + Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box. Returns @@ -14776,14 +14776,38 @@ def to_contain_text( expect(locator).to_contain_text(re.compile(r\"\\d messages\")) ``` - Note that if array is passed as an expected value, entire lists of elements can be asserted: + If you pass an array as an expected value, the expectations are: + 1. Locator resolves to a list of elements. + 1. Elements from a **subset** of this list contain text from the expected array, respectively. + 1. The matching subset of elements has the same order as the expected array. + 1. Each text value from the expected array is matched by some element from the list. + + For example, consider the following list: + + ```html + + ``` + + Let's see how we can use the assertion: ```py - import re from playwright.sync_api import expect - locator = page.locator(\"list > .list-item\") - expect(locator).to_contain_text([\"Text 1\", \"Text 4\", \"Text 5\"]) + # ✓ Contains the right items in the right order + expect(page.locator(\"ul > li\")).to_contain_text([\"Text 1\", \"Text 3\", \"Text 4\"]) + + # ✖ Wrong order + expect(page.locator(\"ul > li\")).to_contain_text([\"Text 3\", \"Text 2\"]) + + # ✖ No item contains this text + expect(page.locator(\"ul > li\")).to_contain_text([\"Some 33\"]) + + # ✖ Locator points to the outer list element, not to the list items + expect(page.locator(\"ul\")).to_contain_text([\"Text 3\"]) ``` Parameters @@ -15380,13 +15404,37 @@ def to_have_text( expect(locator).to_have_text(re.compile(r\"Welcome, .*\")) ``` - Note that if array is passed as an expected value, entire lists of elements can be asserted: + If you pass an array as an expected value, the expectations are: + 1. Locator resolves to a list of elements. + 1. The number of elements equals the number of expected values in the array. + 1. Elements from the list have text matching expected array values, one by one, in order. + + For example, consider the following list: + + ```html + + ``` + + Let's see how we can use the assertion: ```py from playwright.sync_api import expect - locator = page.locator(\"list > .component\") - expect(locator).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) + # ✓ Has the right items in the right order + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) + + # ✖ Wrong order + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 3\", \"Text 2\", \"Text 1\"]) + + # ✖ Last item does not match + await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text\"]) + + # ✖ Locator points to the outer list element, not to the list items + await expect(page.locator(\"ul\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"]) ``` Parameters diff --git a/setup.py b/setup.py index 4e40552cf..90c0c7e78 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ InWheel = None from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand -driver_version = "1.25.0-alpha-1659629898000" +driver_version = "1.25.0-alpha-1660067092000" def extractall(zip: zipfile.ZipFile, path: str) -> None: