利用Applitools Eyes识别视觉bug

简介: Appilitools eyes是一款检测不同次运行页面是否相同的软件。同样运行一个测试程序,可能呈现出来的结果不同。不同的结果可能是bug,也可能是每次展现给用户的结果不同,比如百度搜索,淘宝页面,这里以百度搜索作为案例

Appilitools eyes是一款检测不同次运行页面是否相同的软件。同样运行一个测试程序,可能呈现出来的结果不同。不同的结果可能是bug,也可能是每次展现给用户的结果不同,比如百度搜索,淘宝页面,这里以百度搜索作为案例。

1,要使用Appilitools eyes,首先需要到Appilitools官网https://applitools.com/上注册账号(可以使用github的账号),注册完毕,它会给你一个密钥。

2,在本机上运行

pip3 install eyes-selenium

3,建立测试程序

#!/usr/bin/env python
# coding:utf-8
import unittest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from applitools.selenium import Eyes,Target
from selenium.webdriver.common.by import By
class checkEyes(unittest.TestCase):
    def test_baidu(self):
        driverPath= "C:\\Lib\\chromedriver.exe"
        service= Service(executable_path=driverPath)
        options= webdriver.ChromeOptions()
        options.add_argument("user-data-dir=C:\\Lib\\ChromeProfile")
        self.driver= webdriver.Chrome(service=service, options=options)
        eyes= Eyes()
        eyes.api_key="你的applitools密钥"
        self.driver= webdriver.Chrome()
        self.driver.implicitly_wait(5)
        eyes.open(self.driver,"Baidu首页","检查百度首页及搜索结果")
        self.driver.get('https://www.baidu.com')
        #第一个视觉验证检查点
        eyes.check("百度首页视觉验证",Target.window())
        self.driver.find_element(By.ID,"kw").send_keys("hello world")
        self.driver.find_element(By.ID,"su").click()
        #第二个视觉验证检查点
        eyes.check("百度搜索结果视觉验证",Target.window())
        eyes.close()
        self.driver.quit()
if __name__ == "__main__":
      unittest.main()

运行,运行通过,他会告诉你

--- Test passed. 
See details at https://eyes.applitools.com/app/batches/00000251648871736096/00000251648871735982?accountId=ag4cztZPEEOOoL6WkqNNqA__
.
----------------------------------------------------------------------
Ran 1 test in 20.359s
OK

https://eyes.applitools.com/app/batches/00000251648871736096/00000251648871735982?accountId=ag4cztZPEEOOoL6WkqNNqA__查看
image.png

由于第一次运行,结果是正确的。再次运行,出现结果

Re-raising an error received from SDK server: DiffsFoundError("Test '检查百度首页及搜索结果' of 'Baidu 首页' detected differences! See details at: https://eyes.applitools.com/app/batches/00000251648871497323/00000251648871497183?accountId=ag4cztZPEEOOoL6WkqNNqA__")
E
======================================================================
ERROR: test_baidu (__main__.checkEyes.test_baidu)
----------------------------------------------------------------------
Traceback (most recent call last):  
File "C:\Users\xiang\Desktop\eyes.py", line 31, in test_baidu
eyes.close()
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\eyes.py", line 382, in close
return
super(WebEyes, self).close(raise_ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\eyes.py", line 184, in close
return
self._close(raise_ex, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\eyes.py", line 233, in _close
results= self.get_results(raise_ex) if wait_result else []            
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\eyes.py", line 167, in get_results    
results= self._commands.eyes_get_results(self._eyes_ref, raise_ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\command_executor.py", line 275, in eyes_get_results
return self._checked_command(context, "Eyes.getResults", payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\command_executor.py", line 288, in _checked_command_check_error(response_payload)
File "C:\Users\xiang\AppData\Local\Programs\Python\Python312\Lib\site-packages\applitools\common\command_executor.py", line 298, in _check_error
raise
usdk_error
applitools.common.errors.DiffsFoundError: Test '检查百度首页及搜索结果' of 'Baidu 首页' detected differences! See details at: https://eyes.applitools.com/app/batches/00000251648871497323/00000251648871497183?accountId=ag4cztZPEEOOoL6WkqNNqA__
----------------------------------------------------------------------
Ran 1 test in 22.625s
FAILED (errors=1)

仍旧到https://eyes.applitools.com/app/batches/00000251648871736096/00000251648871735982?accountId=ag4cztZPEEOOoL6WkqNNqA__查看
image.png

第一个检查点是相同的,第二个则不同,所以报错。选择Ignore region,然后通过鼠标点掉图上的粉红色。
image.png

点击右上角的保存键
image.png

再次运行,测试通过。

= RESTART: C:\Users\xiang\Desktop\eyes.py
--- Test passed. 
See details at https://eyes.applitools.com/app/batches/00000251648869473990/00000251648869473901?accountId=ag4cztZPEEOOoL6WkqNNqA__
.
----------------------------------------------------------------------
Ran 1 test in 25.603s
目录
相关文章
|
4月前
|
数据采集 存储 人工智能
从0到1:天猫AI测试用例生成的实践与突破
本文系统阐述了天猫技术团队在AI赋能测试领域的深度实践与探索,讲述了智能测试用例生成的落地路径。
从0到1:天猫AI测试用例生成的实践与突破
|
5月前
|
Java 应用服务中间件
从Tomcat 9.X到Tomcat 10. X以上
如果您原来使用的是Tomcat 9.X,现在您要升级到Tomcat 10. X以上,需要做如下设置
219 0
|
5月前
|
缓存 监控 关系型数据库
使用MYSQL Report分析数据库性能(上)
最终建议:当前系统是完美的读密集型负载模型,优化重点应放在减少行读取量和提高数据定位效率。通过索引优化、分区策略和内存缓存,预期可降低30%的CPU负载,同时保持100%的缓冲池命中率。建议每百万次查询后刷新统计信息以持续优化
530 161
|
9月前
|
人工智能 编解码 芯片
告别低效沟通|让技术提问不再头疼-这套高效AI提问模板来帮你
不会向ai提问,不知道怎么提问的 可以看看
20967 1
告别低效沟通|让技术提问不再头疼-这套高效AI提问模板来帮你
|
5月前
|
SQL 测试技术 数据库
healenium+python+selenium
上次介绍了如何利用healenium+java+selenium来实现selenium的自愈,这次介绍如何healenium+python+selenium。关于healenium+python+selenium网上资料更少,并且甚至是错误的。在著名的书籍《软件测试权威指南中》也是有一定问题的。现在介绍如下
289 4
|
5月前
|
测试技术
自动化测试登录后的功能
在自动化测试的时候,往往许多功能需要登录以后才可以进行操作的,在这里我介绍一种方法,在登录以后将Cookies信息存入本地文件,在测试登录以后操作的时候再从本地文件把信息调出来存入Cookies
110 4
|
Web App开发 机器学习/深度学习 人工智能
详细解读AI测试之Applitools入门教程
详细解读AI测试之Applitools入门教程
742 0
|
存储 JavaScript 前端开发
执行上下文和执行栈
执行上下文是JavaScript运行代码时的环境,每个执行上下文都有自己的变量对象、作用域链和this值。执行栈用于管理函数调用,每当调用一个函数,就会在栈中添加一个新的执行上下文。
|
监控 Cloud Native 持续交付
云原生架构下微服务的最佳实践与挑战####
【10月更文挑战第20天】 本文深入探讨了云原生架构在现代软件开发中的应用,特别是针对微服务设计模式的最优实践与面临的主要挑战。通过分析容器化、持续集成/持续部署(CI/CD)、服务网格等关键技术,阐述了如何高效构建、部署及运维微服务系统。同时,文章也指出了在云原生转型过程中常见的难题,如服务间的复杂通信、安全性问题以及监控与可观测性的实现,为开发者和企业提供了宝贵的策略指导和解决方案建议。 ####
339 5

热门文章

最新文章