Skip to content

Commit cbd2ba3

Browse files
Refactor zoom implementation to use CSS transform scale for better coordinate accuracy
1 parent ec92063 commit cbd2ba3

File tree

1 file changed

+10
-1
lines changed
  • browsergym/miniwob/src/browsergym/miniwob

1 file changed

+10
-1
lines changed

browsergym/miniwob/src/browsergym/miniwob/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,16 @@ def setup(self, page: playwright.sync_api.Page) -> tuple[str, dict]:
6161

6262
# navigate to the task's url
6363
self.page.goto(self.url)
64-
self.page.evaluate("document.documentElement.style.zoom='150%'")
64+
# Apply zoom using CSS transform scale instead of document.documentElement.style.zoom
65+
# This avoids coordinate system mismatches with getBoundingClientRect() in whoCapturesCenterClick()
66+
self.page.evaluate(
67+
"""
68+
document.body.style.transform = 'scale(1.5)';
69+
document.body.style.transformOrigin = 'top left';
70+
document.body.style.width = '66.67%';
71+
document.body.style.height = '66.67%';
72+
"""
73+
)
6574
# remove human display if requested (goal, time left, last reward etc.)
6675
if self.remove_human_display:
6776
self.page.evaluate( # if error : core is not defined, make sure you started the miniwob http server at the right place miniwob-plusplus/miniwob/html

0 commit comments

Comments
 (0)