4

コード化された UI テスト ビルダーを使用して Web ページ内のすべてのリンクを見つけることはできますか? それとも、HTTP 要求を作成して HTML を解析する必要がありますか?

4

1 に答える 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 に答える