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

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

问题描述

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

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

因此,没有一个简单的选择让虚拟机以某个(指定的)分辨率启动,这是一个真正的痛苦.如果有比我要告诉您的事情更简单的事情,请告诉我,但我找不到任何东西.因此,我投票赞成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,另外三台是节点

我们的解决方案

首先,我们让Build服务器启动资源组中的所有计算机(到目前为止非常好).然后,我们创建了一个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服务是否处于活动状态的脚本
    • 我们在带有参数$(Password) $(Chrome-node) $(Username)
    • 的VS构建块中将此脚本称为C:\Scripts\RDPServiceRunCheck.ps1(请参见下面的示例)
    • 所有这些参数都存储在构建服务器上的变量中
    • 这是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:\Scripts\RDPServiceRunCheck.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:\Scripts\$(Chrome-node).rdp" 1600 1200
      • 的VS构建块中将此脚本称为C:\Scripts\Resolution.RDP.Remoting.exe(请参见下面的示例)
      • 每台计算机的* .rdp文件(预先存储)存储在此文件夹中,而1600 1200是我们要设置的分辨率
      • 这是可在github上执行的代码
      • We call this script C:\Scripts\Resolution.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天全站免登陆