mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.2.33修复异域iframe内元素截图问题;元素对象删除stats.is_whole_in_viewport属性
This commit is contained in:
parent
640059a445
commit
56dac7abd7
@ -857,9 +857,8 @@ class ChromiumBase(BasePage):
|
||||
location_in_viewport(self, right_bottom[0], right_bottom[1]))
|
||||
|
||||
if v:
|
||||
shu = self.run_js('return document.body.scrollHeight > window.innerHeight;')
|
||||
heng = self.run_js('return document.body.scrollWidth > window.innerWidth;')
|
||||
if shu and not heng:
|
||||
if (self.run_js('return document.body.scrollHeight > window.innerHeight;') and
|
||||
not self.run_js('return document.body.scrollWidth > window.innerWidth;')):
|
||||
x += 10
|
||||
# elif heng and not shu:
|
||||
# y += 5
|
||||
|
@ -1421,14 +1421,6 @@ class ChromiumElementStates(object):
|
||||
x, y = self._ele.locations.click_point
|
||||
return location_in_viewport(self._ele.page, x, y) if x else False
|
||||
|
||||
@property
|
||||
def is_whole_in_viewport(self):
|
||||
"""返回元素是否整个都在视口内"""
|
||||
x1, y1 = self._ele.location
|
||||
w, h = self._ele.size
|
||||
x2, y2 = x1 + w, y1 + h
|
||||
return location_in_viewport(self._ele.page, x1, y1) and location_in_viewport(self._ele.page, x2, y2)
|
||||
|
||||
@property
|
||||
def is_covered(self):
|
||||
"""返回元素是否被覆盖,与是否在视口中无关"""
|
||||
|
@ -230,9 +230,6 @@ class ChromiumElementStates(object):
|
||||
@property
|
||||
def is_in_viewport(self) -> bool: ...
|
||||
|
||||
@property
|
||||
def is_whole_in_viewport(self) -> bool: ...
|
||||
|
||||
@property
|
||||
def is_covered(self) -> bool: ...
|
||||
|
||||
|
@ -485,7 +485,7 @@ class ChromiumFrame(ChromiumBase):
|
||||
pic_type = 'png'
|
||||
else:
|
||||
if as_bytes not in ('jpg', 'jpeg', 'png', 'webp'):
|
||||
raise ValueError("只能接收 'jpg', 'jpeg', 'png', 'webp' 四种格式。")
|
||||
raise TypeError("只能接收 'jpg', 'jpeg', 'png', 'webp' 四种格式。")
|
||||
pic_type = 'jpeg' if as_bytes == 'jpg' else as_bytes
|
||||
|
||||
elif as_base64:
|
||||
@ -493,7 +493,7 @@ class ChromiumFrame(ChromiumBase):
|
||||
pic_type = 'png'
|
||||
else:
|
||||
if as_base64 not in ('jpg', 'jpeg', 'png', 'webp'):
|
||||
raise ValueError("只能接收 'jpg', 'jpeg', 'png', 'webp' 四种格式。")
|
||||
raise TypeError("只能接收 'jpg', 'jpeg', 'png', 'webp' 四种格式。")
|
||||
pic_type = 'jpeg' if as_base64 == 'jpg' else as_base64
|
||||
|
||||
else:
|
||||
@ -522,11 +522,16 @@ class ChromiumFrame(ChromiumBase):
|
||||
arguments[0].insertBefore(img, this);
|
||||
return img;'''
|
||||
new_ele = first_child.run_js(js, body)
|
||||
new_ele.scroll.to_see(True)
|
||||
new_ele.scroll.to_see(center=True)
|
||||
top = int(self.frame_ele.style('border-top').split('px')[0])
|
||||
left = int(self.frame_ele.style('border-left').split('px')[0])
|
||||
|
||||
r = self.page.run_cdp('Page.getLayoutMetrics')['visualViewport']
|
||||
sx = r['pageX']
|
||||
sy = r['pageY']
|
||||
r = self.page.get_screenshot(path=path, as_bytes=as_bytes, as_base64=as_base64,
|
||||
left_top=(cx + left, cy + top), right_bottom=(cx + w + left, cy + h + top))
|
||||
left_top=(cx + left + sx, cy + top + sy),
|
||||
right_bottom=(cx + w + left + sx, cy + h + top + sy))
|
||||
self.page.remove_ele(new_ele)
|
||||
return r
|
||||
|
||||
|
@ -17,7 +17,6 @@ class ChromiumFrame(ChromiumBase):
|
||||
self.frame_id: str = ...
|
||||
self._frame_ele: ChromiumElement = ...
|
||||
self._backend_id: str = ...
|
||||
self.frame_page: ChromiumBase = ...
|
||||
self._doc_ele: ChromiumElement = ...
|
||||
self._is_diff_domain: bool = ...
|
||||
self.doc_ele: ChromiumElement = ...
|
||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
|
||||
|
||||
setup(
|
||||
name="DrissionPage",
|
||||
version="3.2.32",
|
||||
version="3.2.33",
|
||||
author="g1879",
|
||||
author_email="g1879@qq.com",
|
||||
description="Python based web automation tool. It can control the browser and send and receive data packets.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user