开发者

Coded UI Test : Finding and clicking dynamic hyperlinks in a grid

I recorded a click on a link inside of a tablece开发者_JAVA技巧ll 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜