Skip to content
Closed
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
3 changes: 2 additions & 1 deletion playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,10 @@ async def not_to_have_css(
name: str,
value: Union[str, Pattern[str]],
timeout: float = None,
pseudo: Literal["after", "before"] = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_css(name, value, timeout)
await self._not.to_have_css(name, value, timeout=timeout, pseudo=pseudo)

async def to_have_id(
self,
Expand Down
5 changes: 4 additions & 1 deletion playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -14104,6 +14104,7 @@ async def not_to_have_css(
name: str,
value: typing.Union[str, typing.Pattern[str]],
*,
pseudo: typing.Optional[Literal["after", "before"]] = None,
timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
) -> None:
"""LocatorAssertions.not_to_have_css
Expand All @@ -14116,13 +14117,15 @@ async def not_to_have_css(
CSS property name.
value : Union[Pattern[str], str]
CSS property value.
pseudo : Union["after", "before", None]
Pseudo-element to read computed styles from.
timeout : Union[float, None]
Time to retry the assertion for in milliseconds. Defaults to `5000`.
"""
__tracebackhide__ = True

await self._impl_obj.not_to_have_css(
name=name, value=value, timeout=to_milliseconds(timeout)
name=name, value=value, pseudo=pseudo, timeout=to_milliseconds(timeout)
)

async def not_to_have_id(
Expand Down
5 changes: 4 additions & 1 deletion playwright/sync_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -14178,6 +14178,7 @@ def not_to_have_css(
name: str,
value: typing.Union[str, typing.Pattern[str]],
*,
pseudo: typing.Optional[Literal["after", "before"]] = None,
timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
) -> None:
"""LocatorAssertions.not_to_have_css
Expand All @@ -14190,14 +14191,16 @@ def not_to_have_css(
CSS property name.
value : Union[Pattern[str], str]
CSS property value.
pseudo : Union["after", "before", None]
Pseudo-element to read computed styles from.
timeout : Union[float, None]
Time to retry the assertion for in milliseconds. Defaults to `5000`.
"""
__tracebackhide__ = True

self._sync(
self._impl_obj.not_to_have_css(
name=name, value=value, timeout=to_milliseconds(timeout)
name=name, value=value, pseudo=pseudo, timeout=to_milliseconds(timeout)
)
)

Expand Down
14 changes: 14 additions & 0 deletions tests/async/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ async def test_assertions_locator_to_have_css(page: Page, server: Server) -> Non
"color", "rgb(42, 42, 42)", timeout=100
)

await page.set_content(
"<style>div.foobar::before { content: 'foo'; color: rgb(234, 74, 90); }</style><div class=foobar>kek</div>"
)
await expect(page.locator("div.foobar")).to_have_css(
"color", "rgb(234, 74, 90)", pseudo="before"
)
await expect(page.locator("div.foobar")).not_to_have_css(
"color", "rgb(42, 42, 42)", pseudo="before", timeout=100
)
with pytest.raises(AssertionError):
await expect(page.locator("div.foobar")).not_to_have_css(
"color", "rgb(234, 74, 90)", pseudo="before", timeout=100
)


async def test_assertions_locator_to_have_id(page: Page, server: Server) -> None:
await page.goto(server.EMPTY_PAGE)
Expand Down
14 changes: 14 additions & 0 deletions tests/sync/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ def test_assertions_locator_to_have_css(page: Page, server: Server) -> None:
"color", "rgb(42, 42, 42)", timeout=100
)

page.set_content(
"<style>div.foobar::before { content: 'foo'; color: rgb(234, 74, 90); }</style><div class=foobar>kek</div>"
)
expect(page.locator("div.foobar")).to_have_css(
"color", "rgb(234, 74, 90)", pseudo="before"
)
expect(page.locator("div.foobar")).not_to_have_css(
"color", "rgb(42, 42, 42)", pseudo="before", timeout=100
)
with pytest.raises(AssertionError):
expect(page.locator("div.foobar")).not_to_have_css(
"color", "rgb(234, 74, 90)", pseudo="before", timeout=100
)


def test_assertions_locator_to_have_id(page: Page, server: Server) -> None:
page.goto(server.EMPTY_PAGE)
Expand Down