Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d2765ee

Browse files
authoredJul 16, 2024··
Merge pull request #107 from botcity-dev/fix/scale-issues-main
FIX: Adding treatments to resolve screenshot issues due to scale
2 parents f614fd2 + 35d4081 commit d2765ee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎botcity/web/bot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,10 @@ def _get_page_size(self):
475475
if not self._driver:
476476
return self.DEFAULT_DIMENSIONS
477477

478-
width = self.execute_javascript("return window.innerWidth")
479-
height = self.execute_javascript("return window.innerHeight")
478+
scale_factor = self.execute_javascript("return window.devicePixelRatio")
479+
width = int(self.execute_javascript("return window.innerWidth") * scale_factor)
480+
height = int(self.execute_javascript("return window.innerHeight") * scale_factor)
481+
480482
return width, height
481483

482484
def add_image(self, label, path):
@@ -1473,6 +1475,11 @@ def mouse_move(self, x, y):
14731475
my = y - self._y
14741476
self._x = x
14751477
self._y = y
1478+
1479+
scale_factor = self.execute_javascript("return window.devicePixelRatio")
1480+
mx = mx/scale_factor
1481+
my = my/scale_factor
1482+
14761483
ActionChains(self._driver).move_by_offset(mx, my).perform()
14771484

14781485
def click_at(self, x, y, *, clicks=1, interval_between_clicks=0, button='left'):

0 commit comments

Comments
 (0)
Please sign in to comment.