2.7.2 d模式页面和元素对象增加screenshot_as_bytes()方法

This commit is contained in:
g1879 2022-06-30 11:08:59 +08:00
parent ee61f1d8bd
commit 396a2d8523
6 changed files with 28 additions and 8 deletions

View File

@ -647,6 +647,10 @@ class DriverElement(DrissionElement):
return img_path
def screenshot_as_bytes(self) -> bytes:
"""以字节方式返回元素截图"""
return self.inner_ele.screenshot_as_png
def prop(self, prop: str) -> str:
"""获取property属性值 \n
:param prop: 属性名

View File

@ -457,6 +457,10 @@ class DriverPage(BasePage):
self.driver.save_screenshot(img_path)
return img_path
def screenshot_as_bytes(self) -> bytes:
"""以字节方式返回页面截图"""
return self.driver.get_screenshot_as_png()
def scroll_to_see(self, loc_or_ele: Union[str, tuple, WebElement, DriverElement]) -> None:
"""滚动页面直到元素可见 \n
:param loc_or_ele: 元素的定位信息可以是loc元组或查询字符串详见ele函数注释

View File

@ -196,6 +196,10 @@ ele1.wait_ele(ele2).hidden()
path = ele.screenshot(r'D:\tmp', 'img_name')
```
## screenshot_as_bytes()
此方法以字节形式返回元素截图。
## set_prop()
此方法用于设置元素`property`属性。

View File

@ -546,6 +546,10 @@ page.scroll_to_see((By.XPATH, '//div'))
page.screenshot(r'D:\img', 'img1')
```
## screenshot_as_bytes()
此方法以字节形式返回页面可见范围截图。
## set_window_size()
此方法用于设置浏览器窗口大小。

View File

@ -1,3 +1,7 @@
# v2.7.2
- d 模式页面和元素对象增加`screenshot_as_bytes()`方法
# v2.7.1
- DriverPage

View File

@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
setup(
name="DrissionPage",
version="2.7.1",
version="2.7.2",
author="g1879",
author_email="g1879@qq.com",
description="A module that integrates selenium and requests session, encapsulates common page operations.",