我是机器人框架新手,尝试比较两个图像。我做了一些研究和开发,发现有一个现有的robotappees库可以帮助比较图像。在
链接1:http://navinet.github.io/Robot-AppEyes/RobotAppEyes-KeywordDocumentation.html#Compare%20Image
链接2:https://github.com/NaviNet/Robot-AppEyes
我使用同一个库来比较图像,但在比较两个图像时面临以下问题。在
** Settings ***
Library Selenium2Library
Library RobotAppEyes
*** Test Cases ***
RobotAppEyes 1.0 Test
Open Browser http://www.google.com.uk gc
Maximize Browser Window
Open Eyes Session http://www.google.com.uk RobotAppEyes_Test NaviNet_RobotAppEyes_Test1 JkaJK50dp1NTEhPufx08SaztsXmfBZas8z0MZVcaqcA110
# ${isOpen}= Eyes Session Is Open
# Log ${isOpen}
Compare Image C:\\Users\\Downloads\\logo.png C:\\Users\\user\\Downloads\\logo.png ignore_mismatch=False includeEyesLog=False httpDebugLog=False
Check Eyes Region .//*[@id='splash']/div[1] 500 120 logo
Run Keyword If ${isOpen}==True Close Eyes Session
Close Eyes Session
执行机器人脚本后的响应:
^{pr2}$有谁能帮我比较一下机器人的图像吗?在
能够使用image Magic解决此问题
https://blog.codecentric.de/en/2017/09/robot-framework-compare-images-screenshots/
这是我在评论中讨论后的回答。这不是迪帕克问题的完美答案,我意识到这一点,但他让我把它贴出来。在
这是它来自的完整关键字。对于小图片来说,它很滑(大约20px x~40px是它有问题的地方,尽管我还没有精确地测量过),但是如果屏幕上有精确的像素集,它对大图片的效果非常好。这是屏幕上的任何地方,而不仅仅是在DOM中,所以这是我用来在选项卡之间单击并与普通桌面交互的工具。在
若要使用此关键字,请将图片的本地副本作为绝对路径或相对路径馈送到
click_by_image()
,这两种路径都可以,并且它将按照文档的形式工作。在我提到的具体代码是
pag.locateCenterOnScreen()
,它来自pyautogui。它返回一组坐标,所以如果你没有得到这些坐标,那么你的图像就不会出现在屏幕上。如果你这样做了,那么你知道a)你的形象存在,b)它在哪里。在相关问题 更多 >
编程相关推荐