Skip to main content

PicAssert图片断言工具:

anchor: 测码范晔 联系邮箱: 1538379200@qq.com 当前版本:v 1.3.1 通过图片拓展断言方式

assert_exist会将图片在全局做一次模板匹配行为,当查找的图片大于或者等于设置的阈值的时候,程序将返回True, 当全局匹配的图片匹配度低于所设置的阈值时,程序将启动特征匹配模式,对前面相似度较近的区域进行截图,再次进行特征分析, 如果特征分析的结果判断为图片相似,程序将返回True,否则返回False assert_click图片点击返回一个分辨率的坐标点

参数

1、Assert类参数 driver: 传入的selenium.webdriver.Chrome的实例 lock_conf: 是否锁定配置文件输入,设置为True则从配置文件读取配置,在其他设备运行增加兼容性 2、Assert().assert_exist()方法参数 pic_path(str): 需要进行断言的图片路径,有传入driver则默认作用浏览器 threshold(float|int): 整数或者浮点数,断言的判断阈值,0~1之间,默认0.7 3、Assert().assert_click()方法参数 pic_path(str): 需要点击的目标图片,传入图片的路径,有传入driver默认作用浏览器 hwnd(str): 字符串形式,应用于GUI界面,填写当前窗口的句柄,填写可以默认使用后台鼠标点击,不移动当前鼠标指针(传入driver的浏览器默认不用传入)

使用示例

from PicAssert.Assert import Assert
from SafeDriver.drivers import driver, option


dr = driver()
ps = Assert(driver=dr, lock_conf=True)
res1 = ps.assert_exist(r'D:\test.png')
if res1 is True:
    print("找到图片")
else:
    print("未找到")
res2 = ps.assert_click(r'D:\test2.png')
print("当前点击坐标点:", res2)

如何提升兼容性

1、因为不同设备的分辨率尺寸,很难做到完全的兼容使用,目前建议在本机进行操作 2、浏览器运行,现在暂时不增加无头模式的运行兼容,因为其截图和设备尺寸的兼容现在没有很好的方法解决

Release files for PicAssert 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PicAssert 1.3.1
File Size Uploaded
PicAssert-1.3.1.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PicAssert 1.3.1
File Interpreter ABI Platform
PicAssert-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / PicAssert-1.3.1.tar.gz

Download URL PicAssert-1.3.1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f57b5a8909fd416fdb116a11fc13e76469e42dc06dba7bc25724d055dd124685
BLAKE2b-256 checksum
How to use checksums
f2c46e848999343d254e000054e81326c9913b49f09288768da8f288fb17a412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Release files / PicAssert-1.3.1-py3-none-any.whl

Download URL PicAssert-1.3.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1795097cdd7b46dcdded60f40570dcd83983ec51cb5fa7dfb817cd5bc7bd92b5
BLAKE2b-256 checksum
How to use checksums
51aa78a17d11555c5a7ca3c1406bc4e963c02ed44655894e63e9830cb6dc7ded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page