简体   繁体   English

如何在远程计算机上使用FlaUI运行UI测试而不是RDP进入它?

[英]How can I run UI tests with FlaUI on a remote machine whilst not RDP'd into it?

We have some UI tests that use FlaUI to automate interaction with the windows UI. 我们有一些UI测试使用FlaUI来自动化与Windows UI的交互。

When we run these tests on the build server, they fail to interact with the UI unless someone is connected via RDP. 当我们在构建服务器上运行这些测试时,除非有人通过RDP连接,否则它们无法与UI交互。

The error we get from the tests is just a Could not send mouse input. ErrorCode: 5 我们从测试中得到的错误只是一个Could not send mouse input. ErrorCode: 5 Could not send mouse input. ErrorCode: 5

The machine is set up to log in a user on startup and if we log in to an RDP session as that user and 'watch' the tests then they run ok and can interact with the desktop. 该机器设置为在启动时登录用户,如果我们以该用户身份登录到RDP会话并“观察”测试,那么它们运行正常并且可以与桌面交互。 As soon as we disconnect that user then they stop being able to interact again. 一旦我们断开该用户,他们就会再次无法进行交互。

We are running the tests via NCrunch grid nodes, using NCrunch grid node console app, which starts on log in (ie its not running as a service so it can interact with the desktop). 我们使用NCrunch网格节点控制台应用程序通过NCrunch网格节点运行测试,该应用程序在登录时启动(即它不作为服务运行,因此它可以与桌面交互)。

Is there some way to make the tests run in a way that means we don't have to watch them continuously? 有没有办法让测试以一种方式运行,这意味着我们不必持续观察它们?

If you simulate a mouse click, there has to be an active desktop session ( https://github.com/Roemer/FlaUI/wiki/FAQ#how-can-i-run-flaui-tests-on-a-build-serveragent ). 如果您模拟鼠标单击,则必须有一个活动的桌面会话( https://github.com/Roemer/FlaUI/wiki/FAQ#how-can-i-run-flaui-tests-on-a-build-服务 )。

You have two options: test without mouse clicks (use UIA patterns) or ensure an active desktop session for the build agent. 您有两个选择:无鼠标点击测试(使用UIA模式)或确保构建代理程序的活动桌面会话。 As stated in the FAQ, make sure the session is not closed after disconnecting RDP by running tscon 1 /dest:console 如FAQ中所述,通过运行tscon 1 /dest:console断开RDP连接后,确保会话未关闭

So I have made this work. 所以我做了这个工作。 Mainly I followed the instructions here but I also disabled ServerManager from starting up when the user logs in in TaskScheduler. 主要是我按照这里的说明操作但是当用户登录TaskScheduler时,我也禁用了ServerManager。

The company policy also prevents machines from not locking so we have a powershell script which presses numlock twice every minute to prevent the desktop from locking. 公司策略还可以防止计算机无法锁定,因此我们有一个PowerShell脚本,每分钟按两次numlock以防止桌面锁定。

There were also issues with the desktop being too small when the default user logs in which also prevented things from being clicked. 当默认用户登录时桌面太小也存在问题,这也会阻止点击内容。

As far as I remember, you can invoke events on the controls instead of simulating them with the mouse. 据我记忆,你可以调用控件上的事件,而不是用鼠标模拟它们。 It is different as the events are injected. 注入事件时会有所不同。 This applies not just in TestStack.White adaptation, but in the most robot frameworks. 这不仅适用于TestStack.White改编,而且适用于大多数机器人框架。 So what was and is the motivation behind using the mouse? 那么使用鼠标背后的动机是什么?

When the JQuery came to Javascript, among other things it changed paradigm how items are referenced. 当JQuery来到Javascript时,它改变了范例如何引用项目。 But it also reduced the amount of code you need to write, create a utility method and change: 但它也减少了您需要编写的代码量,创建实用程序方法并进行更改:

FindFirstChild(cf => cf.ByAutomationId("RedButton")).AsButton().Click();

to something shorter, for example: 更短的东西,例如:

_.Find<Button>("RedButton").Click();

Inadvertently you remove one layer of abstraction, make them more readable, runs faster, does not depend on screen resolution or dpi, etc. 无意中你删除了一层抽象,使它们更具可读性,运行速度更快,不依赖于屏幕分辨率或dpi等。

One thing I would try if previous was not applicable - run the NCrunch Grid implementation in a virtual machine. 如果以前不适用,我会尝试一件事 - 在虚拟机中运行NCrunch Grid实现。 I mean, in theory, it could work. 我的意思是,从理论上讲,它可以奏效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM