如何使用编码UI获得祖先和先例 [英] How to get ancestors and precedents using Coded UI

查看:85
本文介绍了如何使用编码UI获得祖先和先例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的应用程序的UI,在这里我想根据标签选择复选框.但是问题是复选框是输入,并且标签在Span标记中.我认为最简单的方法是使用HTmlSpan识别Label并转到第一个先例.但 我找不到任何方法来获得该控件的所有先前的同级对象.我看到UITestControlCollection,我们可以使用它浏览索引,我认为这不适合使用InnerText进行搜索.

The following is the UI of my application, here I want to select the checkbox based on the label. But the problem is checkbox is an input and label is in Span tag. The easiest way I can think is identify Label using HTmlSpan and go to first precedent. But I don't find any method to get all the precedent sibling of  the control. I see UITestControlCollection using which we can navigate through index, which I don't think is suitable for my search using InnerText.

使用Xpath,我们可以将控件标识为//span [contains(text(),'技术规范文档')]/preceding-sibling :: input [1]

Using Xpath we could identify the control as //span[contains(text(),'Tech Spec Documentation')]/preceding-sibling::input[1]

复选框标签

复选框标签

附件具有

<span class="option_parent">
<span onclick="ExpandCollapseBranch('297');">
<img id="box-297" src=""/>
<img id="folder-297" src=""/>
</span>
<span class="option_category">General Information</span>
<br/>
</span>
<span id="297" class="option_branch" style="display: block;">
<input class="saved" type="checkbox" onclick="CheckValue("check_431_0_297");" value="431" name="check_431_0_297"/>
<span id="check_431_0_297_text" class="saved">
<font color="Blue"/>
 First Article
</span>
<br/>
<input type="hidden" name="last_check_431_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_429_0_297");" checked="" value="429" name="check_429_0_297"/>
<span id="check_429_0_297_text" class="saved">
<font color="Blue"/>
 Tech Spec Documentation
</span>
<br/>
<input type="hidden" value="429" name="last_check_429_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_1372_0_297");" value="1372" name="check_1372_0_297"/>
<span id="check_1372_0_297_text" class="saved">
<font color="Blue"/>
 Energy Star Requirement
</span>
<br/>
<input type="hidden" name="last_check_1372_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_1165_0_297");" value="1165" name="check_1165_0_297"/>
<span id="check_1165_0_297_text" class="saved">
<font color="Blue"/>
 Special Instructions
</span>
<br/>
<input type="hidden" name="last_check_1165_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_1515_0_297");" value="1515" name="check_1515_0_297"/>
<span id="check_1515_0_297_text" class="saved">
<font color="Blue"/>
 Global Project – Originating
</span>
<br/>
<input type="hidden" name="last_check_1515_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_1550_0_297");" value="1550" name="check_1550_0_297"/>
<span id="check_1550_0_297_text" class="saved">
<font color="Blue"/>
 Global Project – Receiving
</span>
<br/>
<input type="hidden" name="last_check_1550_0_297"/>
<input class="saved" type="checkbox" onclick="CheckValue("check_2173_0_297");" value="2173" name="check_2173_0_297"/>
<span id="check_2173_0_297_text" class="saved">
<font color="Blue"/>
 Standard Portfolio
</span>
<br/>
<input type="hidden" name="last_check_2173_0_297"/>
</span>

DOM.


推荐答案

您好,Kaleem,

Hi Kaleem,

根据您的问题,请尝试使用编码的UI测试生成器记录您的UI动作,然后生成代码,然后可以打开此UIMap.uitest文件,转到"UI控件映射"窗口,检查是否可以看到UI动作您记录了.

Based on your issue, please you try to record your UI action using coded UI test builder and then generated code, then you could open this UIMap.uitest file, go to UI Control Map window check if you can see the UI action you recorded.

然后,您可以参考UIMap.Designer.cs文件修改您的UI操作,以检查此问题.

Then you could refer the UIMap.Designer.cs file to modify your UI action check this issue.

但是,如果以上建议对您没有帮助,我建议您可以为我们分享完整的html源文件,以便我们帮助您重现此问题.

However, if the above suggestion could not help you, I suggest you could share me complete html source file for us so that we will help you reproduce this issue in my side.

您可以将Web应用程序上传到OneDrive,然后在此处复制链接.

You could upload your web application on OneDrive and then copy link here.

最好的问候


这篇关于如何使用编码UI获得祖先和先例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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