我可以使用 Coded UI Test Builder 找到网页中的所有链接,还是必须发出 HTTP 请求并解析 HTML?
问问题
9159 次
1 回答
8
你可以做这样的事情......
BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.google.com"));
bw.WaitForControlReady();
UITestControl document = bw.CurrentDocumentWindow;
HtmlControl control = new HtmlControl(document);
control.SearchProperties.Add(HtmlControl.PropertyNames.ClassName, "HtmlHyperlink");
UITestControlCollection controlcollection = control.FindMatchingControls();
List<string> names = new List<string>();
foreach (UITestControl x in controlcollection)
{
if (x is HtmlHyperlink)
{
HtmlHyperlink s = (HtmlHyperlink)x;
names.Add(s.Href);
}
}
于 2011-07-14T18:26:25.633 回答