尝试electron桌面APP的UI自动化测试框架

pywinauto【failed】

https://www.kancloud.cn/gnefnuy/pywinauto_doc/1193038

试用win gui检测工具 inspect spy++
spy++ 无法检测到APP
inspect ...看不太懂,好像也检测不到,有error报错
gui-inspect-tool

electron+spectron+mocha【success】

尝试使用 electron+spectron+mocha,遇到问题:unknown error: Chrome failed to start: crashed. when trying to test electron spectron with mocha

查看github,这方面的问题好像挺多的,也没有已解决的。
stackoverflow上面唯一一个已解决的说是spectron和electron版本不兼容,换了对应的版本之后还是有问题。

最终版本,能够启动app和关闭app,源码已上传github.spectron-example
在此过程遇到的问题:

  1. chrome 启动失败 见上面...暂未研究是何原因,但已确定和electron,spectron版本无关
  2. github上readme提到的chrome driver不兼容问题,一开始以为是本地浏览器不兼容,找到对应版本(80)的浏览器下载安装后发现还是报相同的错误,然后发现APP里面写死了chrome版本号,我只能更改本地的驱动.....坑爹
  3. 最开始报错ensure 'done()' you called.
    简单研究了下是超时未返回result,promise要显示声明done(),简单加了个resolve()
    后面可以正常运行就注释掉了....
it('launch the app',function() {
		/*
    return HomePage.run(function (resolve){
      resolve();
    })
    */
		return HomePage.run();
	});
  1. git push 遇到10053,403 问题
    首先 git config --global 配置用户名邮箱
    其次根据最开始写的文章设置ssh key - win10系统git安装与配置
    然后发现这台电脑已经安装了git了...直接在要上传到git的目录下右键 git bash here
    这时候git push 遇到403 的问题...坑爹..修改.git/config文件
[remote "origin"]
	url = https://github.com/Tester-Dolores/spectron-example.git

在url的github.com前面添加Tester-Dolores@,即 https://Tester-Dolores@github.com/Tester-Dolores/spectron-example.git
来!继续git push ,然后弹出框输入密码即可..后续不需要重复输入密码

完结!撒花~

参考:
测试框架Mocha
使用Mocha+spectron测试Electron打包的桌面版程序(2)PO模型
官方文档 - 只想说issue好多..
mochawesome
mocha configuration file

macaca

testerhome上看到一篇不错的文章,使用 Macaca 测试 Electron 桌面 App

官网文档中文版

配置环境:

# desktop环境
npm i macaca-electron --save-dev
# 命令行工具
npm i -g macaca-cli

又再次回到了解electron...

# 克隆示例项目的仓库
$ git clone https://github.com/electron/electron-quick-start

# 进入这个仓库
$ cd electron-quick-start

# 安装依赖并运行
$ npm install && npm start

又回到使用spcetron...

上面的内容,主要还是一些知识点整理和个人的一些思考,权当参考,如有错误或者更好的建议,可以在评论区指正,不胜感激!

原文地址:https://www.cnblogs.com/Tester_Dolores/p/14842408.html