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
1 change: 1 addition & 0 deletions playwright/_impl/_element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ async def select_option(
dict(
timeout=timeout,
noWaitAfter=noWaitAfter,
force=force,
**convert_select_option_values(value, index, label, element)
)
)
Expand Down
25 changes: 19 additions & 6 deletions playwright/_impl/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async def query_selector(
self, selector: str, strict: bool = None
) -> Optional[ElementHandle]:
return from_nullable_channel(
await self._channel.send("querySelector", dict(selector=selector))
await self._channel.send("querySelector", locals_to_params(locals()))
)

async def query_selector_all(self, selector: str) -> List[ElementHandle]:
Expand Down Expand Up @@ -321,7 +321,15 @@ async def dispatch_event(
) -> None:
await self._channel.send(
"dispatchEvent",
dict(selector=selector, type=type, eventInit=serialize_argument(eventInit)),
locals_to_params(
dict(
selector=selector,
type=type,
eventInit=serialize_argument(eventInit),
strict=strict,
timeout=timeout,
),
),
)

async def eval_on_selector(
Expand All @@ -334,10 +342,13 @@ async def eval_on_selector(
return parse_result(
await self._channel.send(
"evalOnSelector",
dict(
selector=selector,
expression=expression,
arg=serialize_argument(arg),
locals_to_params(
dict(
selector=selector,
expression=expression,
arg=serialize_argument(arg),
strict=strict,
)
),
)
)
Expand Down Expand Up @@ -549,6 +560,8 @@ async def select_option(
selector=selector,
timeout=timeout,
noWaitAfter=noWaitAfter,
strict=strict,
force=force,
**convert_select_option_values(value, index, label, element),
)
)
Expand Down
2 changes: 2 additions & 0 deletions tests/async/test_browsercontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,6 @@ async def test_strict_selectors_on_context(browser: Browser, server: Server):
)
with pytest.raises(Error):
await page.text_content("button")
with pytest.raises(Error):
await page.query_selector("button")
await context.close()
19 changes: 18 additions & 1 deletion tests/async/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import asyncio

from playwright.async_api import Error
import pytest

from playwright.async_api import Error, Page
from tests.server import Server


async def test_evaluate_handle(page, server):
Expand Down Expand Up @@ -253,3 +256,17 @@ async def test_should_report_different_frame_instance_when_frame_re_attaches(
frame2 = await frame2_info.value
assert frame2.is_detached() is False
assert frame1 != frame2


async def test_strict_mode(page: Page, server: Server):
await page.goto(server.EMPTY_PAGE)
await page.set_content(
"""
<button>Hello</button>
<button>Hello</button>
"""
)
with pytest.raises(Error):
await page.text_content("button", strict=True)
with pytest.raises(Error):
await page.query_selector("button", strict=True)