@@ -427,7 +427,7 @@ def headers(self) -> typing.Dict[str, str]:
427
427
def from_service_worker(self) -> bool:
428
428
"""Response.from_service_worker
429
429
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
431
431
[FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
432
432
433
433
Returns
@@ -2528,7 +2528,7 @@ async def screenshot(
2528
2528
2529
2529
Defaults to `"device"`.
2530
2530
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
2532
2532
`#FF00FF` that completely covers its bounding box.
2533
2533
2534
2534
Returns
@@ -7995,7 +7995,7 @@ async def screenshot(
7995
7995
7996
7996
Defaults to `"device"`.
7997
7997
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
7999
7999
`#FF00FF` that completely covers its bounding box.
8000
8000
8001
8001
Returns
@@ -11047,7 +11047,7 @@ async def new_context(
11047
11047
11048
11048
Creates a new browser context. It won't share cookies/cache with other browser contexts.
11049
11049
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
11051
11051
context via `browser_context.close()` when your code is done with the `BrowserContext`, and before calling
11052
11052
`browser.close()`. This will ensure the `context` is closed gracefully and any artifacts—like HARs and
11053
11053
videos—are fully flushed and saved.
@@ -13317,7 +13317,7 @@ async def screenshot(
13317
13317
13318
13318
Defaults to `"device"`.
13319
13319
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
13321
13321
`#FF00FF` that completely covers its bounding box.
13322
13322
13323
13323
Returns
@@ -14649,14 +14649,38 @@ async def to_contain_text(
14649
14649
await expect(locator).to_contain_text(re.compile(r\"\\d messages\"))
14650
14650
```
14651
14651
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:
14653
14669
14654
14670
```py
14655
- import re
14656
14671
from playwright.async_api import expect
14657
14672
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\"])
14660
14684
```
14661
14685
14662
14686
Parameters
@@ -15231,13 +15255,37 @@ async def to_have_text(
15231
15255
await expect(locator).to_have_text(re.compile(r\"Welcome, .*\"))
15232
15256
```
15233
15257
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:
15235
15274
15236
15275
```py
15237
15276
from playwright.async_api import expect
15238
15277
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\"])
15241
15289
```
15242
15290
15243
15291
Parameters
0 commit comments