根据这篇文章使用Mocha+spectron测试Electron打包的桌面版程序(2)PO模型,结合spectron官方文档、mochawesome、mocha configuration file对electron桌面APP的UI自动化测试。
- 环境
电脑环境: win10 64位
- 浏览器版本和驱动一致,否则会报错
Error: Failed to create session.
session not created: This version of ChromeDriver only supports Chrome version 91
Current browser version is 80.0.3987.165 with binary path d:\study\spcetron\node_modules\spectron\lib\launcher.bat
解决方案1(采用此方案):
替换 \node_modules\electron-chromedriver\bin
下的 chromedriver.exe
为对应版本(80.0.3987.165)的驱动
采用该方案原因:app里的浏览器版本是开发写死的改不动...
解决方案2:
下载对应的浏览器版本(80.0.3987.165)
- 运行
mocha runtest
原本的命令: mocha test --reporter mochawesome --reporter-options reportFilename=customReportFilename,overwrite=false
(鬼记得住...)
后面发现mochawesome必须依赖mocha存在,mochawesome又没有配置文件,去看了下mocha文档发现有configuration file,然后又找到了sample,果然有reporter配置参数...
如果您有任何问题...请先google...
If you have any questions... Please Google first...