From dcfa1ff2a1230ae9a61c56248137d3e93371c43a Mon Sep 17 00:00:00 2001 From: g1879 Date: Sat, 5 Aug 2023 15:36:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E7=B4=A0=E5=B1=8F=E5=B9=95=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E4=B9=98=E4=BB=A5=E5=83=8F=E7=B4=A0=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/chromium_element.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DrissionPage/chromium_element.py b/DrissionPage/chromium_element.py index ad1930f..9e56a8e 100644 --- a/DrissionPage/chromium_element.py +++ b/DrissionPage/chromium_element.py @@ -1516,21 +1516,24 @@ class Locations(object): """返回元素左上角在屏幕上坐标,左上角为(0, 0)""" vx, vy = self._ele.page.rect.viewport_location ex, ey = self.viewport_location - return vx + ex, ey + vy + pr = self._ele.page.run_js('return window.devicePixelRatio;') + return int((vx + ex) * pr), int((ey + vy) * pr) @property def screen_midpoint(self): """返回元素中点在屏幕上坐标,左上角为(0, 0)""" vx, vy = self._ele.page.rect.viewport_location ex, ey = self.viewport_midpoint - return vx + ex, ey + vy + pr = self._ele.page.run_js('return window.devicePixelRatio;') + return int((vx + ex) * pr), int((ey + vy) * pr) @property def screen_click_point(self): """返回元素中点在屏幕上坐标,左上角为(0, 0)""" vx, vy = self._ele.page.rect.viewport_location ex, ey = self.viewport_click_point - return vx + ex, ey + vy + pr = self._ele.page.run_js('return window.devicePixelRatio;') + return int((vx + ex) * pr), int((ey + vy) * pr) def _get_viewport_rect(self, quad): """按照类型返回在可视窗口中的范围