Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->93.0.4576.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->14.2<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->90.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->94.0.4595.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->15.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->91.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |

## Documentation

Expand Down
6 changes: 3 additions & 3 deletions playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ async def element_handles(self) -> List[ElementHandle]:

@property
def first(self) -> "Locator":
return Locator(self._frame, f"{self._selector} >> _nth=first")
return Locator(self._frame, f"{self._selector} >> nth=0")

@property
def last(self) -> "Locator":
return Locator(self._frame, f"{self._selector} >> _nth=last")
return Locator(self._frame, f"{self._selector} >> nth=-1")

def nth(self, index: int) -> "Locator":
return Locator(self._frame, f"{self._selector} >> _nth={index}")
return Locator(self._frame, f"{self._selector} >> nth={index}")

async def focus(self, timeout: float = None) -> None:
params = locals_to_params(locals())
Expand Down
4 changes: 2 additions & 2 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -11044,8 +11044,8 @@ async def evaluate_all(self, expression: str, arg: typing.Any = None) -> NoneTyp
The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
to `expression`. Returns the result of `expression` invocation.

If `expression` returns a [Promise], then [`Locator.evaluateAll`] would wait for the promise to resolve and return its
value.
If `expression` returns a [Promise], then `locator.evaluate_all()` would wait for the promise to resolve and
return its value.

Examples:

Expand Down
4 changes: 2 additions & 2 deletions playwright/sync_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -10980,8 +10980,8 @@ def evaluate_all(self, expression: str, arg: typing.Any = None) -> NoneType:
The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
to `expression`. Returns the result of `expression` invocation.

If `expression` returns a [Promise], then [`Locator.evaluateAll`] would wait for the promise to resolve and return its
value.
If `expression` returns a [Promise], then `locator.evaluate_all()` would wait for the promise to resolve and
return its value.

Examples:

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
InWheel = None
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand

driver_version = "1.14.0-next-1628399336000"
driver_version = "1.14.0-1628783206000"


def extractall(zip: zipfile.ZipFile, path: str) -> None:
Expand Down
18 changes: 10 additions & 8 deletions tests/async/test_browsercontext_add_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async def test_should_have_expires_set_to_neg_1_for_session_cookies(context, ser
assert cookies[0]["expires"] == -1


async def test_should_set_cookie_with_reasonable_defaults(context, server):
async def test_should_set_cookie_with_reasonable_defaults(context, server, is_chromium):
await context.add_cookies(
[{"url": server.EMPTY_PAGE, "name": "defaults", "value": "123456"}]
)
Expand All @@ -225,12 +225,12 @@ async def test_should_set_cookie_with_reasonable_defaults(context, server):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]


async def test_should_set_a_cookie_with_a_path(context, page, server):
async def test_should_set_a_cookie_with_a_path(context, page, server, is_chromium):
await page.goto(server.PREFIX + "/grid.html")
await context.add_cookies(
[
Expand All @@ -251,7 +251,7 @@ async def test_should_set_a_cookie_with_a_path(context, page, server):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]
assert await page.evaluate("document.cookie") == "gridcookie=GRID"
Expand Down Expand Up @@ -311,7 +311,9 @@ async def test_should_be_able_to_set_unsecure_cookie_for_http_website(
assert not cookie["secure"]


async def test_should_set_a_cookie_on_a_different_domain(context, page, server):
async def test_should_set_a_cookie_on_a_different_domain(
context, page, server, is_chromium
):
await page.goto(server.EMPTY_PAGE)
await context.add_cookies(
[{"url": "https://www.example.com", "name": "example-cookie", "value": "best"}]
Expand All @@ -326,7 +328,7 @@ async def test_should_set_a_cookie_on_a_different_domain(context, page, server):
"expires": -1,
"httpOnly": False,
"secure": True,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]

Expand Down Expand Up @@ -370,7 +372,7 @@ async def test_should_not_block_third_party_cookies(
)
await page.frames[1].evaluate("document.cookie = 'username=John Doe'")
await page.wait_for_timeout(2000)
allows_third_party = is_chromium or is_firefox
allows_third_party = is_firefox
cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html")

if allows_third_party:
Expand All @@ -381,7 +383,7 @@ async def test_should_not_block_third_party_cookies(
"httpOnly": False,
"name": "username",
"path": "/",
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
"secure": False,
"value": "John Doe",
}
Expand Down
20 changes: 10 additions & 10 deletions tests/async/test_browsercontext_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def test_should_return_no_cookies_in_pristine_browser_context(context):
assert await context.cookies() == []


async def test_should_get_a_cookie(context, page, server, is_firefox):
async def test_should_get_a_cookie(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
document_cookie = await page.evaluate(
"""() => {
Expand All @@ -39,12 +39,12 @@ async def test_should_get_a_cookie(context, page, server, is_firefox):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]


async def test_should_get_a_non_session_cookie(context, page, server, is_firefox):
async def test_should_get_a_non_session_cookie(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
# @see https://en.wikipedia.org/wiki/Year_2038_problem
date = int(datetime.datetime(2038, 1, 1).timestamp() * 1000)
Expand All @@ -66,7 +66,7 @@ async def test_should_get_a_non_session_cookie(context, page, server, is_firefox
"expires": date / 1000,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]

Expand Down Expand Up @@ -124,7 +124,7 @@ async def test_should_properly_report_lax_sameSite_cookie(
assert cookies[0]["sameSite"] == "Lax"


async def test_should_get_multiple_cookies(context, page, server, is_firefox):
async def test_should_get_multiple_cookies(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
document_cookie = await page.evaluate(
"""() => {
Expand All @@ -145,7 +145,7 @@ async def test_should_get_multiple_cookies(context, page, server, is_firefox):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
},
{
"name": "username",
Expand All @@ -155,12 +155,12 @@ async def test_should_get_multiple_cookies(context, page, server, is_firefox):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
},
]


async def test_should_get_cookies_from_multiple_urls(context):
async def test_should_get_cookies_from_multiple_urls(context, is_chromium):
await context.add_cookies(
[
{"url": "https://foo.com", "name": "doggo", "value": "woofs"},
Expand All @@ -180,7 +180,7 @@ async def test_should_get_cookies_from_multiple_urls(context):
"expires": -1,
"httpOnly": False,
"secure": True,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
},
{
"name": "doggo",
Expand All @@ -190,6 +190,6 @@ async def test_should_get_cookies_from_multiple_urls(context):
"expires": -1,
"httpOnly": False,
"secure": True,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
},
]
10 changes: 5 additions & 5 deletions tests/async/test_defaultbrowsercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def _launch(**options):
await context.close()


async def test_context_cookies_should_work(server, launch_persistent, is_firefox):
async def test_context_cookies_should_work(server, launch_persistent, is_chromium):
(page, context) = await launch_persistent()
await page.goto(server.EMPTY_PAGE)
document_cookie = await page.evaluate(
Expand All @@ -57,12 +57,12 @@ async def test_context_cookies_should_work(server, launch_persistent, is_firefox
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]


async def test_context_add_cookies_should_work(server, launch_persistent):
async def test_context_add_cookies_should_work(server, launch_persistent, is_chromium):
(page, context) = await launch_persistent()
await page.goto(server.EMPTY_PAGE)
await page.context.add_cookies(
Expand All @@ -78,7 +78,7 @@ async def test_context_add_cookies_should_work(server, launch_persistent):
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
}
]

Expand Down Expand Up @@ -124,7 +124,7 @@ async def test_should_not_block_third_party_cookies(
)

await page.wait_for_timeout(2000)
allows_third_party = is_chromium or is_firefox
allows_third_party = is_firefox
assert document_cookie == ("username=John Doe" if allows_third_party else "")
cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html")
if allows_third_party:
Expand Down
4 changes: 2 additions & 2 deletions tests/async/test_headful.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def test_should_not_block_third_party_cookies(
)

await page.wait_for_timeout(2000)
allows_third_party = is_chromium or is_firefox
allows_third_party = is_firefox
assert document_cookie == ("username=John Doe" if allows_third_party else "")
cookies = await page.context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html")
if allows_third_party:
Expand All @@ -112,7 +112,7 @@ async def test_should_not_block_third_party_cookies(
"httpOnly": False,
"name": "username",
"path": "/",
"sameSite": "None",
"sameSite": "Lax" if is_chromium else "None",
"secure": False,
"value": "John Doe",
}
Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ async def test_locators_should_throw_on_capture_without_nth(page: Page):
"""
)
with pytest.raises(Error, match="Can't query n-th element"):
await page.locator("*css=div >> p").nth(0).click()
await page.locator("*css=div >> p").nth(1).click()


async def test_locators_should_throw_due_to_strictness(page: Page):
Expand Down
2 changes: 1 addition & 1 deletion tests/sync/test_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def test_locators_should_throw_on_capture_without_nth(page: Page):
"""
)
with pytest.raises(Error, match="Can't query n-th element"):
page.locator("*css=div >> p").nth(0).click()
page.locator("*css=div >> p").nth(1).click()


def test_locators_should_throw_due_to_strictness(page: Page):
Expand Down