提高测试代理的屏幕分辨率 [英] Increase the screen resolution on Test Agent

查看:34
本文介绍了提高测试代理的屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 RDP 访问时,在我的本地计算机和 Azure VM Windows Server 2012R2 上对桌面 WPF 应用程序运行自动化测试工作正常.

Running a automated test against a desktop WPF application works fine on my local machine and on Azure VM Windows Server 2012R2 when accessed via RDP.

但是,当 VM 用作构建机器时,由 TFS 或 VSTS 上的测试代理控制,由于屏幕分辨率设置为 1024x768 屏幕分辨率,所有测试都失败.在此显示设置之前,应用程序不会配置为运行.我们在部署测试代理时,有什么办法可以改变屏幕设置吗?

However, when the VM is used as build machine, controlled by test agent on TFS or VSTS, all test fails because of the screen resolution is set to 1024x768 screen resolution. The application is not configure to run until this display settings. Is there any way to change the screen settings when we deploy the test agent?

运行量角器时更改 VSTS 代理会话屏幕分辨率测试

推荐答案

我们在 Visual Studio + Azure 解决方案中遇到了同样的问题.为了能够执行测试,我们需要在 VM 上使用比 1027 x 768 更高的分辨率.但是由于它是 Azure 并且您为打开的机器付费,我们还希望在每次运行后关闭它们以降低成本(当您想稍微放大时尤其有用).

We've encountered the same issue on our Visual studio + Azure solution. To be able to execute the tests we need a higher resolution on the VM than 1027 x 768. But since it's Azure and you pay for machines that are turned on, we also want to turn them off after each run top keep the cost down (especially helpful when you want to scale up a bit).

因此,没有简单的选项可以让 VM 以某个(指定的)分辨率启动,这真的很痛苦.如果有比我要向您展示的更简单的东西,请告诉我,但我找不到任何东西.所以我对 Nessi 提到的想法投了赞成票.我们采取的解决方法如下.

Therefore it's a real pain that there is no simple option to let the VM boot in a certain (specified) resolution. If there is something more simple than what I'm going to show you, please let me know, but I could not find any. So I up-voted the idea mentioned by Nessi. What we did as a workaround was the following.

可能的解决方案的想法

本质上我们使用了这篇文章 作为指导方针.我们从中使用的最重要的东西是 Windows 凭据部分和 TERMSRV.

In essence we used this post as a guideline. The most important things we used from this was the Windows credentials part and the TERMSRV.

我们的设置

  • Visual Studio 构建服务器
  • 四个 Azure VM,一台机器是 selenium-grid-hub,另外三台是节点

我们的解决方案

首先我们让构建服务器启动资源组中的所有机器(到目前为止一切顺利).然后我们创建了一个 Powershell 脚本,该脚本在构建服务器上运行到节点以检查并等待 RDP 服务变得可用.这是必需的,因为在我们看到此服务处于活动状态之前最多可能需要 10 分钟.最后,我们在 selenium-grid-hub VM 上触发 Powershell,以特定分辨率与所有节点建立 RDP 连接.

First we let the Build server start all machines in the resource group (so far so good). Then we created a Powershell script that runs on the build server to the nodes to check and waits for the RDP service to become available. This was needed since it can take up to 10 minutes before we see that this service is active. And finally we trigger a Powershell on the selenium-grid-hub VM to make RDP connections to all nodes in a certain resolution.

再详细一点,以确保一切自动进行,无需任何手动输入:

In a bit more detail to make sure it all goes automatically and without any manual input needed:

  • 创建证书并将其从每个节点导出/导入中心
  • 确保凭据存储在凭据管理器中 > Windows Credentails(我们在所有机器上创建了一个用户,让生活更轻松)
  • 创建脚本以检查 RDP 服务是否处于活动状态
    • 我们在 VS 构建块中将此脚本称为 C:ScriptsRDPServiceRunCheck.ps1(参见下面的示例),参数为 $(Password) $(Chrome-node) $(用户名)
    • 所有这些参数都存储在构建服务器上的变量中
    • 这是 github 上脚本的代码
    • Creating and export/import certificates from each node into the hub
    • Making sure that the credentials are stored in the credential manager > Windows Credentails (we created one user on all machines to make life a tiny bit easier)
    • Creating a script for checking if the RDP service is active
      • We call this script C:ScriptsRDPServiceRunCheck.ps1 (see example below) in a VS build block with the arguments $(Password) $(Chrome-node) $(Username)
      • Where all these arguments have been stored in variables on the build server
      • Here is the code for the script on github
      • 我们将此脚本称为 C:ScriptsResolution.RDP.Remoting.exe(参见下面的示例),在 VS 构建块中使用参数 "C:Scripts$(Chrome-node).rdp" 1600 1200
      • 每台机器的 *.rdp 文件(预先)存储在此文件夹中的位置,1600 1200 是我们要设置的分辨率
      • 这是 可在 github 上执行的代码
      • We call this script C:ScriptsResolution.RDP.Remoting.exe (see example below) in a VS building block with the arguments "C:Scripts$(Chrome-node).rdp" 1600 1200
      • Where the *.rdp file for each machine was stored (upfront) in this folder and 1600 1200 is the resolution we want to set
      • Here is the code for the executable on github

      这篇关于提高测试代理的屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆