From 605ab10a1b93f21e9f45322a0bf6e3ea2fbacf69 Mon Sep 17 00:00:00 2001 From: XerxesNoble Date: Fri, 3 Mar 2017 19:22:44 -0500 Subject: [PATCH] added devicePixelRatio support --- needle/driver.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/needle/driver.py b/needle/driver.py index b869e63..86ce9eb 100644 --- a/needle/driver.py +++ b/needle/driver.py @@ -41,13 +41,16 @@ def get_dimensions(self): Returns a dictionary containing, in pixels, the element's ``width`` and ``height``, and it's ``left`` and ``top`` position relative to the document. """ + + # Support for retina displays + dpr = self._parent.execute_script('return window.devicePixelRatio') location = self.location size = self.size return { - "top": location['y'], - "left": location['x'], - "width": size['width'], - "height": size['height'] + "top": location['y'] * dpr, + "left": location['x'] * dpr, + "width": size['width'] * dpr, + "height": size['height'] * dpr } def get_screenshot(self):