Tester-Dolores / spectron-example

spectron 试用例子

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

根据这篇文章使用Mocha+spectron测试Electron打包的桌面版程序(2)PO模型,结合spectron官方文档mochawesomemocha configuration file对electron桌面APP的UI自动化测试。

  1. 环境

electron@13.0.1

spectron@15.0.0

mocha@8.4.0

mochawesome@6.2.2

电脑环境: win10 64位

  1. 浏览器版本和驱动一致,否则会报错
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里的浏览器版本是开发写死的改不动...

chromedriver下载

解决方案2:

下载对应的浏览器版本(80.0.3987.165)

  1. 运行

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...

About

spectron 试用例子


Languages

Language:JavaScript 100.0%