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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.15
rev: v0.15.21
hooks:
- id: ruff
args:
Expand All @@ -13,7 +13,7 @@ repos:
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
rev: v2.2.0
hooks:
- id: mypy
exclude: ^docs/examples/
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"anytree >= 2.9.0",
"cached_property",
"playwright >= 1.54.0",
"wait_for",
"wait-for>=2.0",
]

[project.optional-dependencies]
Expand Down
19 changes: 14 additions & 5 deletions src/widgetastic/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ def logger(self):
"""
return create_widget_logger(type(self).__name__, self.browser.logger)

def ensure_page_safe(self, timeout: Union[int, None] = None) -> None:
def ensure_page_safe(self, timeout: Optional[Union[int, float]] = None) -> None:
"""Waits for the page to be quiescent, replacing the old JS-based check.

Args:
timeout: Provide timeout in seconds.
timeout: Maximum time in seconds to wait for networkidle.
Accepts int or float. If None, Playwright's default timeout (30s) is used.
"""
timeout_ms = 0 if timeout is None else timeout * 1000
timeout_ms = timeout * 1000 if timeout is not None else None
self.browser.page.wait_for_load_state("networkidle", timeout=timeout_ms)

def after_click(self, element: Locator, locator: LocatorAlias) -> None:
Expand Down Expand Up @@ -1414,7 +1415,12 @@ def check(self, locator: LocatorAlias, *args, **kwargs) -> None:
"""
self.logger.debug("check: %r", locator)
el = self.element(locator, *args, **kwargs)
el.check()
# el.check()
if not el.is_checked():
# Use JS click instead of el.check() to avoid a coordinate-based
# click regression in Playwright 1.61+ / headless Chrome 149 where
# check() reports "did not change its state" on deeply scrolled pages.
el.evaluate("el => el.click()")

def uncheck(self, locator: LocatorAlias, *args, **kwargs) -> None:
"""Uncheck an element (Checkboxes/ Radio buttons) specified by the locator.
Expand All @@ -1426,7 +1432,10 @@ def uncheck(self, locator: LocatorAlias, *args, **kwargs) -> None:
"""
self.logger.debug("uncheck: %r", locator)
el = self.element(locator, *args, **kwargs)
el.uncheck()
# el.uncheck()
if el.is_checked():
# Use JS click instead of el.uncheck() — same reason as check() above.
el.evaluate("el => el.click()")

# ========================= DRAG & DROP OPERATIONS =========================
def drag_and_drop(self, source: LocatorAlias, target: LocatorAlias) -> None:
Expand Down
22 changes: 5 additions & 17 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading