@@ -427,7 +427,7 @@ def headers(self) -> typing.Dict[str, str]:
427427 def from_service_worker(self) -> bool:
428428 """Response.from_service_worker
429429
430- Indicates whether this Response was fullfilled by a Service Worker's Fetch Handler (i.e. via
430+ Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via
431431 [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
432432
433433 Returns
@@ -2528,7 +2528,7 @@ async def screenshot(
25282528
25292529 Defaults to `"device"`.
25302530 mask : Union[List[Locator], NoneType]
2531- Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
2531+ Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
25322532 `#FF00FF` that completely covers its bounding box.
25332533
25342534 Returns
@@ -7995,7 +7995,7 @@ async def screenshot(
79957995
79967996 Defaults to `"device"`.
79977997 mask : Union[List[Locator], NoneType]
7998- Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
7998+ Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
79997999 `#FF00FF` that completely covers its bounding box.
80008000
80018001 Returns
@@ -11047,7 +11047,7 @@ async def new_context(
1104711047
1104811048 Creates a new browser context. It won't share cookies/cache with other browser contexts.
1104911049
11050- > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicilty close the returned
11050+ > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicitly close the returned
1105111051 context via `browser_context.close()` when your code is done with the `BrowserContext`, and before calling
1105211052 `browser.close()`. This will ensure the `context` is closed gracefully and any artifacts—like HARs and
1105311053 videos—are fully flushed and saved.
@@ -13317,7 +13317,7 @@ async def screenshot(
1331713317
1331813318 Defaults to `"device"`.
1331913319 mask : Union[List[Locator], NoneType]
13320- Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
13320+ Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
1332113321 `#FF00FF` that completely covers its bounding box.
1332213322
1332313323 Returns
@@ -14649,14 +14649,38 @@ async def to_contain_text(
1464914649 await expect(locator).to_contain_text(re.compile(r\"\\d messages\"))
1465014650 ```
1465114651
14652- Note that if array is passed as an expected value, entire lists of elements can be asserted:
14652+ If you pass an array as an expected value, the expectations are:
14653+ 1. Locator resolves to a list of elements.
14654+ 1. Elements from a **subset** of this list contain text from the expected array, respectively.
14655+ 1. The matching subset of elements has the same order as the expected array.
14656+ 1. Each text value from the expected array is matched by some element from the list.
14657+
14658+ For example, consider the following list:
14659+
14660+ ```html
14661+ <ul>
14662+ <li>Item Text 1</li>
14663+ <li>Item Text 2</li>
14664+ <li>Item Text 3</li>
14665+ </ul>
14666+ ```
14667+
14668+ Let's see how we can use the assertion:
1465314669
1465414670 ```py
14655- import re
1465614671 from playwright.async_api import expect
1465714672
14658- locator = page.locator(\"list > .list-item\")
14659- await expect(locator).to_contain_text([\"Text 1\", \"Text 4\", \"Text 5\"])
14673+ # ✓ Contains the right items in the right order
14674+ await expect(page.locator(\"ul > li\")).to_contain_text([\"Text 1\", \"Text 3\", \"Text 4\"])
14675+
14676+ # ✖ Wrong order
14677+ await expect(page.locator(\"ul > li\")).to_contain_text([\"Text 3\", \"Text 2\"])
14678+
14679+ # ✖ No item contains this text
14680+ await expect(page.locator(\"ul > li\")).to_contain_text([\"Some 33\"])
14681+
14682+ # ✖ Locator points to the outer list element, not to the list items
14683+ await expect(page.locator(\"ul\")).to_contain_text([\"Text 3\"])
1466014684 ```
1466114685
1466214686 Parameters
@@ -15231,13 +15255,37 @@ async def to_have_text(
1523115255 await expect(locator).to_have_text(re.compile(r\"Welcome, .*\"))
1523215256 ```
1523315257
15234- Note that if array is passed as an expected value, entire lists of elements can be asserted:
15258+ If you pass an array as an expected value, the expectations are:
15259+ 1. Locator resolves to a list of elements.
15260+ 1. The number of elements equals the number of expected values in the array.
15261+ 1. Elements from the list have text matching expected array values, one by one, in order.
15262+
15263+ For example, consider the following list:
15264+
15265+ ```html
15266+ <ul>
15267+ <li>Text 1</li>
15268+ <li>Text 2</li>
15269+ <li>Text 3</li>
15270+ </ul>
15271+ ```
15272+
15273+ Let's see how we can use the assertion:
1523515274
1523615275 ```py
1523715276 from playwright.async_api import expect
1523815277
15239- locator = page.locator(\"list > .component\")
15240- await expect(locator).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"])
15278+ # ✓ Has the right items in the right order
15279+ await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"])
15280+
15281+ # ✖ Wrong order
15282+ await expect(page.locator(\"ul > li\")).to_have_text([\"Text 3\", \"Text 2\", \"Text 1\"])
15283+
15284+ # ✖ Last item does not match
15285+ await expect(page.locator(\"ul > li\")).to_have_text([\"Text 1\", \"Text 2\", \"Text\"])
15286+
15287+ # ✖ Locator points to the outer list element, not to the list items
15288+ await expect(page.locator(\"ul\")).to_have_text([\"Text 1\", \"Text 2\", \"Text 3\"])
1524115289 ```
1524215290
1524315291 Parameters
0 commit comments