You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the page has been scrolled, the element coordinates returned by NeedleWebElementMixin.get_dimensions() are relative to the top-left of the page, but the screenshot that get_screenshot() crops starts at the current scroll position. This results in the returned screenshot being of either the wrong part of the page or mostly/all blank, depending on the browser. To fix this, the current scroll position needs to be subtracted from the position, like so:
diff --git a/home/jjurack/.local/share/virtualenvs/test_web-6ViYfjms/lib/python3.6/site-packages/needle/driver-orig.py b/home/jjurack/.local/share/virtualenvs/test_web-6ViYfjms/lib/python3.6/site-packages/needle/driver.py
index cd10b49..eceafe5 100644
--- a/home/jjurack/.local/share/virtualenvs/test_web-6ViYfjms/lib/python3.6/site-packages/needle/driver-orig.py
+++ b/home/jjurack/.local/share/virtualenvs/test_web-6ViYfjms/lib/python3.6/site-packages/needle/driver.py
@@ -63,8 +63,8 @@ class NeedleWebElementMixin(object):
d = self.get_dimensions()
# Cast values to int in order for _ImageCrop not to break
- d['left'] = int(d['left'])
- d['top'] = int(d['top'])
+ d['left'] = int(d['left']) - self._parent.execute_script('return window.scrollX')
+ d['top'] = int(d['top']) - self._parent.execute_script('return window.scrollY')
d['width'] = int(d['width'])
d['height'] = int(d['height'])
The text was updated successfully, but these errors were encountered:
When the page has been scrolled, the element coordinates returned by NeedleWebElementMixin.get_dimensions() are relative to the top-left of the page, but the screenshot that get_screenshot() crops starts at the current scroll position. This results in the returned screenshot being of either the wrong part of the page or mostly/all blank, depending on the browser. To fix this, the current scroll position needs to be subtracted from the position, like so:
The text was updated successfully, but these errors were encountered: