标签: coded-ui-tests

编码 UI 测试中的 TestContext TestRunParameters

按照此处此处概述的过程,我能够设置 TestRunParameter 并在运行时在单元测试中访问它。然后我在编码的 UI 测试中重复了完全相同的过程,但无法访问属性。

我的 .runsettings 文件:

<RunSettings>
  <TestRunParameters>
    <Parameter name="webAppUrl" value="http://localhost" />
  </TestRunParameters>
</RunSettings>
Run Code Online (Sandbox Code Playgroud)

我的测试方法:

[TestMethod]
public void MyTest1()
{
    // This throws an error because Properties["webAppUrl"] is null
    string webAppUrl = TestContext.Properties["webAppUrl"].ToString();

    // etc...
}
Run Code Online (Sandbox Code Playgroud)

编码 UI 测试是否需要额外配置才能访问这些运行时属性?

编辑:我注意到在单元测试的上下文中, TestContext 是Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestContextImplementation. 在编码的 UI 测试中,TestContext 是Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext.

visual-studio coded-ui-tests azure-devops

5
推荐指数
1
解决办法
3164
查看次数

TF400813: 资源不可用于匿名访问。需要客户端认证

我正在从事 CodedUI 测试自动化项目。我正在开发一个框架,在该框架中我试图VSTS通过RestAPI. 我之前曾开发过一个 MVC 应用程序,在该应用程序中我做了同样的事情来从VSTS使用RestAPI.

现在的问题是我无法访问VSTS. 每次我尝试访问时VSTS,我都会遇到异常TF400813: Resource not available for anonymous access. Client authentication required
我正在使用相同的PAT token. 我拥有团队项目所需的所有访问权限。我可以从浏览器访问我项目中的所有工作项。我已经尝试了下面线程中提到的所有选项,但仍然无法正常工作。
启动 Visual Studio 2015.3 时出现客户端身份验证错误
任何线索将不胜感激。
以下是我从以下位置获取数据的代码VSTS

public static List<WorkItem> GetWorkItemsWithSpecificFields(IEnumerable<int> ids)
{
    var collectionUri = "https://<name>.visualstudio.com";
    var fields = new string[] {
        "System.Id",
        "System.Title",
        "System.WorkItemType",
        "Microsoft.VSTS.Scheduling.RemainingWork"
    };
    using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(new Uri(collectionUri), new VssBasicCredential("", System.Configuration.ConfigurationManager.AppSettings["PATToken"])))
    {
        // Exception is …
Run Code Online (Sandbox Code Playgroud)

c# coded-ui-tests visual-studio-2015 azure-devops-rest-api

5
推荐指数
0
解决办法
1万
查看次数

编码的UI抛出"无法加载一个或多个请求的类型"

我无法让Coded UI调试工作.Visual Studio不会在断点上停止.一个简单的演示测试(仅在Excel工作表单元格中输入一个数字)在没有调试的情况下运行时会成功.但是在调试测试时,测试运行器会立即出错,而不会尝试进入测试类构造函数(如果提供)或测试方法.

报告的错误是:

Message: Unit Test Adapter threw exception: 
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..
Run Code Online (Sandbox Code Playgroud)

我正在运行Visual Studio 2017,版本15.5.0.

Debug窗口的输出:

'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe'. Cannot find or open the PDB file.
'testhost.x86.exe' (CLR v4.0.30319: testhost.x86.exe): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Microsoft.TestPlatform.CoreUtilities.dll'. Cannot find or open the PDB file. …
Run Code Online (Sandbox Code Playgroud)

coded-ui-tests visual-studio-debugging visual-studio-2017

5
推荐指数
1
解决办法
5060
查看次数

Visual Studio 测试运行:从测试中心的测试计划运行编码的 UI 自动化测试

构建定义

我正在使用与构建和发布配置相同的机器。我已经成功创建了构建。使用构建我能够在构建中的Visual Studio 测试任务中执行编码的 UI 脚本,并且它们工作正常我的配置用于构建定义如下所述

在此处输入图片说明

发布目的地

在成功构建定义和执行测试脚本后,我的下一个计划是从测试中心的测试计划运行自动化测试。我也将我的测试脚本与测试用例相关联。请查看我的发布定义的图像,其中我使用测试运行选择了测试运行

在此处输入图片说明

从测试中心的测试计划执行自动化测试失败后收到的通知

Deployment of release Release-11 Rejected in Deploy Test Scripts.
Run Code Online (Sandbox Code Playgroud)

日志

2018-02-21T14:24:20.8978238Z AgentName: EVSRV017-DEVSRV017-4
2018-02-21T14:24:20.8978238Z AgentId: 29
2018-02-21T14:24:20.9038250Z ServiceUrl: https://mytfsserver/tfs/DefaultCollection/
2018-02-21T14:24:20.9038250Z TestPlatformVersion: 
2018-02-21T14:24:20.9038250Z EnvironmentUri: dta://env/Calculator/_apis/release/16/20/1
2018-02-21T14:24:20.9038250Z QueryForTaskIntervalInMilliseconds: 3000
2018-02-21T14:24:20.9038250Z MaxQueryForTaskIntervalInMilliseconds: 10000
2018-02-21T14:24:20.9048252Z QueueNotFoundDelayTimeInMilliseconds: 3000
2018-02-21T14:24:20.9058254Z MaxQueueNotFoundDelayTimeInMilliseconds: 50000
2018-02-21T14:24:20.9058254Z RetryCountWhileConnectingToTfs: 3
2018-02-21T14:24:20.9058254Z ===========================================
2018-02-21T14:24:21.3909224Z Initializing the Test Execution Engine
Run Code Online (Sandbox Code Playgroud)

警告

2018-02-21T14:25:02.1240674Z ##[warning]Failure attempting to call the restapis. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred …
Run Code Online (Sandbox Code Playgroud)

tfs continuous-integration tfsbuild coded-ui-tests continuous-deployment

5
推荐指数
1
解决办法
713
查看次数

发布带有工件的测试程序集,以便在 VSTS 上的功能测试期间使用它们

我很难弄清楚如何在我的 realease 管道上正确配置功能测试。我有一个解决方案,其中包含一些使用 VSTS 中的默认构建配置构建的 Web 项目。工件没问题,我可以使用发布管道发布它们。到目前为止一切顺利,现在我想使用 CodedUI 实现功能测试并将它们集成到我的版本中。我们有一个带有 vsagent 的开发服务器,它是在我配置部署组时安装的。然后我使用我在此处下载的工具手动安装了 vstest 代理。

然后我在我的发布管道上添加了一个新任务:VsTest 配置如下

在此处输入图片说明

这是我的发布管道中测试任务的日志输出,其中表示未找到测试程序集:

在此处输入图片说明

我的构建任务:

在此处输入图片说明

这是我的工件包,它似乎没有任何测试程序集,只有 Web 项目:

在此处输入图片说明

所以基本上,我如何发布我的测试程序集以便在我的发布管道中使用它们?我是否正确地将测试程序集与我的 Web 项目工件打包在一起?

functional-testing coded-ui-tests azure-devops azure-pipelines azure-pipelines-release-pipeline

5
推荐指数
1
解决办法
4416
查看次数

CdkDragDrop 单元测试事件

所以,我一直在为我的 Angular 应用程序进行单元测试。我正在使用 Angular Material,并且我有一个使用拖放 CDK cdk 拖放 API 的组件

html 代码看起来像这样

<mat-card class="interventionCard">
  <div  cdkDropListGroup class="container">
    <div cdkDropList
         [cdkDropListData]="interventionsTodo" (cdkDropListDropped)="drop($event)" class="dragContainer">
      <div class="dragInter" *ngFor="let i of interventionsTodo" cdkDrag><img src="{{i.imgSrc}}" class="interventionIc" alt=""></div>
      <a class="resetInv" (click)="reset()"><div class="dragInter"><img src="../assets/images/simulation-intervention/noIntervention.svg" class="interventionIc" alt=""></div></a><!---->
    </div>

    <div class="dropContainer">
      <div cdkDropList [cdkDropListData]="interventionsDoneNow" (cdkDropListDropped)="drop($event)" class="dropZone">
        <div class="dragInterDropped" *ngFor="let i of interventionsDoneNow" cdkDrag><img src="{{i.imgSrc}}" class="interventionIc" alt=""></div>
      </div>
        <div class="connectorL"></div>
      <div cdkDropList [cdkDropListData]="interventionsDonePlus5" (cdkDropListDropped)="drop($event)" class="dropZone">
        <div class="dragInterDropped" *ngFor="let i of interventionsDonePlus5" cdkDrag><img src="{{i.imgSrc}}" class="interventionIc"></div>
      </div>
      <div class="connectorL"></div>
      <div cdkDropList …
Run Code Online (Sandbox Code Playgroud)

unit-testing coded-ui-tests angular-material angular

5
推荐指数
1
解决办法
4485
查看次数

如何使用Coded UI Test查找网页中的所有链接?

我可以使用Coded UI Test Builder找到网页中的所有链接,还是我必须发出HTTP请求并解析HTML?

c# visual-studio-2010 coded-ui-tests

4
推荐指数
1
解决办法
9121
查看次数

如何使用.csv文件读取数据多次运行测试(数据驱动)

我正在尝试为我们的一个Web应用程序自动化一些测试,我需要知道如何使我的Coded UI项目从CSV文件中读取数据.让我们说我想测试登录屏幕.我的CSV文件将包含一些用户名和密码.我希望我的Coded UI测试能够读取这些登录详细信息并循环遍历它们以对每组数据运行测试.

c# automated-tests data-driven-tests coded-ui-tests visual-studio-2012

4
推荐指数
1
解决办法
2万
查看次数

CodedUI测试不从CSV输入文件中读取数据

我很难使用Coded UI测试方法映射CSV文件.这很可能是一个愚蠢的问题,但我似乎找不到解决我的问题的办法,至少没有一个有效.我确保将CSV文件的属性设置为始终复制.我还通过在测试方法上面写了以下行来导入CSV文件.

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Data\\login.csv", "login#csv", DataAccessMethod.Sequential), DeploymentItem("login.csv"), TestMethod]
Run Code Online (Sandbox Code Playgroud)

文件名是login.csv,它位于Data文件夹中.

测试将编译没有任何问题但是一旦测试执行,应该从CSV文件接收输入的字段保持为空并且执行被中断.我尝试使用字符串替换CSV文件中的数据,它完全正常.我用来导入每个参数的代码是:

TestContext.DataRow["Username"].ToString()
Run Code Online (Sandbox Code Playgroud)

此外,CSV文件包含以下内容:

Username,Password,Fullname
admin@mail.com,password,Admin
Run Code Online (Sandbox Code Playgroud)

是否有人可以指出我忘记了什么.

更新:我确定了问题,似乎问题只围绕csv文件的第一列.当我尝试导入任何其他值时,它完全正常.

csv import data-driven-tests coded-ui-tests visual-studio-2013

4
推荐指数
1
解决办法
3347
查看次数

如何使用编码的UI测试通过自定义HTML属性搜索元素

input[type=submit]在GridView中有一堆按钮.在idS和name这些按钮 s虽然可以预测,因为它们使用索引号,但不适合使用SpecFlow和Coded UI Tests进行自动化.我发现很难搜索那些按钮元素.

提供给浏览器的HTML代码段:

<input type="submit" id="abc_xyz_0" data-task-id="123" value="Apply">
<input type="submit" id="qrs_tuv_0" data-task-id="345" value="Renew">
Run Code Online (Sandbox Code Playgroud)

按钮文本在每行中都是通用的("应用"和"续订"),但data-task-id属性是唯一的.我想使用此属性和值来标识要单击的按钮.我正在尝试使用SearchProperties,FilterProperties但我不断获得例外:

System.NotSupportedException:此控件不支持属性DataTaskId.

我是如何尝试找到控件的:

HtmlInputButton button = new HtmlInputButton(document);

button.SearchProperties["data-task-id"] = "123";
// or button.SearchProperties["DataTaskId"] = "123";
Run Code Online (Sandbox Code Playgroud)

一些额外的细节:

  • Windows 7的
  • Internet Explorer 11
  • 网站从localhost"Internet选项安全设置"中发送并标记为"受信任"

更新:感谢marcel de vries和AfroMogli的回答.Marcel使用JavaScript来查找元素,AfroMogli使用纯C#和CodedUI API.这两个答案同样有效,我没有注意到任何一个之间的性能差异.两个同样好的解决方案

.net c# asp.net coded-ui-tests

4
推荐指数
1
解决办法
5046
查看次数