编码 UI 测试:查找并单击网格中的动态超链接

发布于 2024-11-18 18:33:46 字数 957 浏览 6 评论 0原文

我记录了对网格中表格单元格内部链接的单击,然后将其移动到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

能怎样 2024-11-25 18:33:46

当您要单击的菜单项的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文