开发者

Watin ContainsText method fails to find text in FireFox

开发者 https://www.devze.com 2023-01-02 17:08 出处:网络
The ContainsText method finds the text only in specific area in the html but fails to find id in other parts of the page.

The ContainsText method finds the text only in specific area in the html but fails to find id in other parts of the page. The text that located und开发者_如何学运维er 'div id="content"' can be found But the text in other area of the html is not found (f.e 'form id="aspnetForm"')

        Browser b = new FireFox("http://localhost:8668/login.aspx");
        b.Button("login.login.button")).Click();
        bool blah = b.ContainsText("Hello");

I'm using the latest watin release. The issue is reproduced with FF3.0, FF3.5 and FF3.6 In IE it's working fine for the tested text.


Used workaround:

By parsing the html with html agility pack

Looks like this:

    public bool ContainsTextInternal(string text)
    {
        var htmldoc = new HtmlDocument();
        htmldoc.LoadHtml(browser.Html);
        return htmldoc.DocumentNode.InnerText.Contains(text);
    }

html agility pack link

0

精彩评论

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

关注公众号