Thursday, August 23, 2012

Coded UI - Find link in browser page

Imagine the following scenario:

You need to get all links in a page that share a Property value.


 this.TestRunner.UIMap.UIMozillaWindow.UIItemList.UIHyperlink.WaitForControlExist();
 UITestControl window = this.TestRunner.UIMap.MozillaWindow;            
 window.SearchProperties.Add(BrowserWindow.PropertyNames.ClassName, "MozillaWindowClass");

WinEdit section = new WinEdit(window);
section.SearchProperties.Add(WinEdit.PropertyNames.ControlType, "Edit", PropertyExpressionOperator.Contains);


UITestControlCollection links = section.FindMatchingControls();
foreach (UITestControl x in links)
{                
 // anything you need to do
 MessageBox.Show(x.Name.ToString());
}


No comments:

Post a Comment