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

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

问题描述

当通过 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 凭据(我们在所有计算机上创建了一个用户,以使生活更轻松一些)
  • 创建用于检查 RDP 服务是否处于活动状态的脚本
    • 我们在带有参数 $(Password) $(Chrome-node) $(用户名)
    • 所有这些参数都存储在构建服务器上的变量中
    • 这是 github 上的脚本
    • 的代码
    • 我们在一个带有参数 "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天全站免登陆