4
我可以使用编码UI测试生成器查找网页中的所有链接,或者我需要制作HTTP请求并解析HTML吗?如何使用编码UI测试查找网页中的所有链接?
我可以使用编码UI测试生成器查找网页中的所有链接,或者我需要制作HTTP请求并解析HTML吗?如何使用编码UI测试查找网页中的所有链接?
你可以做这样的事情......
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);
}
}