最近负责项目组Windows App自动化测试框架搭建工做,在这里简单地把这个过程当中参考的资料整理起来,仅仅是搬运工,感谢大牛们分享的资料。 同时也记下本身遇到的一些问题和解决办法。html
11种免费Window App自动化工具介绍(英文版): https://testguild.com/automation-tools-desktop/git
9种 https://www.logigear.com/blog/test-automation/12-best-automation-tools-for-desktop-apps-in-2020/github
12 种 https://blog.testproject.io/2016/12/22/9-free-desktop-test-automation-tools/ windows
由于我所作项目测试的APP是部署在server端,须要在测试机上远程访问server,这方面对工具的选取有很大限制, 因此我选了集成在Appium里的WinAppDriver,由于能够用到Appium的远程访问功能。 我的以为若是用Microsoft UI automation会方便些,它里面定义了各类各样的控件(Button, TreetMenu等),基本上直接调用现成的接口就能够了,不须要花太多精力作二次开发,但它不能远程访问。用WinAppDriver须要二次开发,大部控件都要本身定义,须要编码能力。我花了不少时间去调查是否能够Mirosoft UI automation和Appium结合起来用, 可是没有找到方法, 若是有朋友有找到合适的方法,欢迎一块儿探讨。session
花了一些时间研究Mirosoft UI automation, 这里顺带把以前参考资料列出来app
1. 官网介绍: https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-fundamentals 框架
2. 详细说明和例子ide
3. 简单明了的中文介绍: 测试
https://blog.csdn.net/ffeiffei/article/details/6637418
WinAppDriver
官网介绍: http://appium.io/docs/en/drivers/windows/
Winappdriver整体介绍, 环境搭建,代码样本, 注意事项:
1. 安装Node.js 和Appium :
http://www.javashuo.com/article/p-djixlfqd-nb.html
建议Appium的非GUI和GUI版都安装,咱们用的通常是非GUI,可是有时候能够用GUI版本定位问题,好比经过Appium session定位元素。
2. 安装WinAppDriver (官网上WinAppDriver是集成在Appium, 安装了Appium,是不须要再安装WinAppDriver,可是我安装了Appium后,运行程序会提示WinAppDriver未安装,多是版本问题)
参考 :https://www.cnblogs.com/nanshufang/p/winappdriver.html
1, 安装Nodejs
2. 安装Appium
3. 安装WinAPPDriver(虽然Appium官网说不用单独安装这个,可是我试了不安装会遇到问题)
4. 我是用C#, 在vs2015(2017)里新建一个工程,并把经过Nuget安装上Appium driver.
具体设置过程参考: http://appium.io/docs/en/drivers/windows/
5. 启动Appium
6. 开启开发者模式
7.启动WinAppDriver.exe(这一步通常是不须要的,若是报WinAppDriver没起来或没安装能够试一试)
在C:\Program Files (x86)\Windows Application Driver, 能够双击里面的WinAppDriver.exe文件
8. 环境好啦,开始写测试代码
官方介绍: https://docs.microsoft.com/en-us/windows/win32/winauto/inspect-objects
这里要注意:我发现有些朋友说装了SDK后没有找到inspect.exe, 我猜是由于有几个版号,没有找对文件夹,下图是我电脑上实际找到的位置(找版号最大的,没找到的话,把这几个文件夹都看一下)
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86
1. 安装完appium,执行代码,报如下错误:
An unknown server-side error occurred while processing the command. Original error: Could not verify WinAppDriver install; re-run install
解决办法:下载安装WinAppDriver
https://github.com/microsoft/WinAppDriver/releases/tag/v1.2-RC
Appium官方文档是说Appium上有内置了WinAppDriver,不用单独安装。还有若是只装了GUI Appium,也会报这个错,最好装非GUI版本。
2. Error:
Message: Test method Winformtest.CalculatorSession.TestMethod3 threw exception: OpenQA.Selenium.WebDriverException: Unexpected error. The URL '/session' did not map to a valid resourcer
缘由:
url 错了
//private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
改为: private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/wd/hub";
3. 设置待测试APP的路径:
appOptions.AddAdditionalCapability("app", @"C:\Program Files(x86)\....... \****.exe");
报错:
OpenQA.Selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: The system cannot find the file specified
这个是我犯的低级错误,目录中的(x86)前面有一个空格,加上空格就行了,为了解决这个问题费了好多时间,一开始还觉得本身的方法不对。像这样路径之类信息必定要复制, 不能手动输入
4. 以前跑均可以的,能够执行点击或者双击,忽然执行click()就报
An unknown error occurred in the remote end while processing the command
若是是Actions, 执行doubleclick() 就报Access Denied
Element 实际是有找到的,由于代码都没改变,环境也没变
网上找了有不少人遇到相似的问题,特别是远程的时候,若是测试本地没问题,看了解答的,都没有找到根本缘由,有时候莫名其妙就行了,有说重启电脑,切换语言的。
个人解决办法:一样的代码,换成在本地跑,是能够过的,因而又切换成server上,发现也好了,莫名其妙的, 后面发现若是把行测APP所在server(咱们用的是虚拟机)的窗口关闭或者最小化,就会报这个错,若是保打开状态,就没问题
因此个人解决办法是:保持窗口打开。
下面是网上找一些办法,可是不能解决个人问题,也许能解决其余朋友的问题,列在这。
https://github.com/Microsoft/WinAppDriver/issues/361
https://github.com/Microsoft/WinAppDriver/issues/357