mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
2.7.2 d模式页面和元素对象增加screenshot_as_bytes()方法
This commit is contained in:
parent
ee61f1d8bd
commit
396a2d8523
@ -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: 属性名
|
||||
|
@ -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函数注释)
|
||||
|
@ -196,6 +196,10 @@ ele1.wait_ele(ele2).hidden()
|
||||
path = ele.screenshot(r'D:\tmp', 'img_name')
|
||||
```
|
||||
|
||||
## screenshot_as_bytes()
|
||||
|
||||
此方法以字节形式返回元素截图。
|
||||
|
||||
## set_prop()
|
||||
|
||||
此方法用于设置元素`property`属性。
|
||||
|
@ -546,6 +546,10 @@ page.scroll_to_see((By.XPATH, '//div'))
|
||||
page.screenshot(r'D:\img', 'img1')
|
||||
```
|
||||
|
||||
## screenshot_as_bytes()
|
||||
|
||||
此方法以字节形式返回页面可见范围截图。
|
||||
|
||||
## set_window_size()
|
||||
|
||||
此方法用于设置浏览器窗口大小。
|
||||
|
18
docs/版本历史.md
18
docs/版本历史.md
@ -1,10 +1,14 @@
|
||||
# v2.7.2
|
||||
|
||||
- d 模式页面和元素对象增加`screenshot_as_bytes()`方法
|
||||
|
||||
# v2.7.1
|
||||
|
||||
- DriverPage
|
||||
|
||||
- 增加`get_session_storage()`、`get_local_storage()`、`set_session_storage()`、`set_local_storage()`、`clean_cache()`方法
|
||||
|
||||
- `run_cdp()`的`cmd_args`参数改为`**cmd_args`
|
||||
|
||||
- 增加`get_session_storage()`、`get_local_storage()`、`set_session_storage()`、`set_local_storage()`、`clean_cache()`方法
|
||||
|
||||
- `run_cdp()`的`cmd_args`参数改为`**cmd_args`
|
||||
|
||||
- 关闭 driver 时会主动关闭 chromedriver.exe 的进程
|
||||
|
||||
@ -18,9 +22,9 @@
|
||||
# v2.6.0
|
||||
|
||||
- 新增`Listener`类
|
||||
- 可监听浏览器数据包
|
||||
- 可异步监听
|
||||
- 可实现每监听到若干数据包执行操作
|
||||
- 可监听浏览器数据包
|
||||
- 可异步监听
|
||||
- 可实现每监听到若干数据包执行操作
|
||||
- 放弃对selenium4.1以下的支持
|
||||
- 解决使用新版浏览器时出现的一些问题
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -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.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user