编码 UI 测试:查找并单击网格中的动态超链接
我记录了对网格中表格单元格内部链接的单击,然后将其移动到 UIMap 文件后修改了代码。网格中有很多链接,但它们只能使用一次,然后就会消失。这些链接是一个人的姓氏作为 InnerText 属性。我通过 sLastName 变量传递一个人的姓氏。我发现这在某些地方有效,但并非总是有效,并且希望得到任何反馈。
Public Sub ReviewPhysOrdClick(ByVal sLastName)
Dim uILastNameHyperlink As HtmlHyperlink = Me.UIPaperlessAdministratWindow1.UIPaperlessAdministratDocument9.UINamelast1449Hyperlink
'all stuff to help it find a link in the grid to click
uILastNameHyperlink.SearchConfigurations.Add("Id") 'add id property as a search item
uILastNameHyperlink.SearchProperties.Add("Id", "ctl20__UserGrid", PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.SearchProperties.Add("InnerText", sLastName, PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.Find() 'prompts a search for the control before any action is taken
Mouse.Click(uILastNameHyperlink) 'click the link
End Sub
I recorded a click on a link inside of a tablecell in a grid, then modified the code after moving it to the UIMap file. There are many links in the grid, but they can only be used once then they go away. The links are a person's last name as the InnerText property. I am passing a persons last name in via the sLastName variable. I am finding that this works in places but not all the time and would appreciate any feedback.
Public Sub ReviewPhysOrdClick(ByVal sLastName)
Dim uILastNameHyperlink As HtmlHyperlink = Me.UIPaperlessAdministratWindow1.UIPaperlessAdministratDocument9.UINamelast1449Hyperlink
'all stuff to help it find a link in the grid to click
uILastNameHyperlink.SearchConfigurations.Add("Id") 'add id property as a search item
uILastNameHyperlink.SearchProperties.Add("Id", "ctl20__UserGrid", PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.SearchProperties.Add("InnerText", sLastName, PropertyExpressionOperator.Contains) 'search parameter
uILastNameHyperlink.Find() 'prompts a search for the control before any action is taken
Mouse.Click(uILastNameHyperlink) 'click the link
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您要单击的菜单项的 id 随环境或菜单列表的变化而不断变化时,可以使用此代码。您可以直接编辑
codedui 测试并注释记录测试时捕获的其他搜索属性。放置这三行代码而不是捕获的行。效果很好。
This code can be used where ever the id of the menu item which you want to click keeps on changing on change of environments or menu lists.You can directly edit the designer map of the
codedui test and comment the other search properties which where captured while recording the test.Put this three lines of code instead of captured lines.It works well.