开发者

How to find all links in web page using Coded UI Test?

开发者 https://www.devze.com 2023-03-05 01:52 出处:网络
Can I find all links in web page 开发者_如何学运维using Coded UI Test Builder, or I have to make HTTP request and parse HTML?You could do something like this...

Can I find all links in web page 开发者_如何学运维using Coded UI Test Builder, or I have to make HTTP request and parse HTML?


You could do something like this...

        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);
            }
        }
0

精彩评论

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