开发者

how to get the page source and search with Watin

开发者 https://www.devze.com 2023-01-30 06:52 出处:网络
i开发者_运维知识库\'m using Watin and i want to search in the page source (HTML), like the ctrl+F search, what is the best way to do it?

i开发者_运维知识库'm using Watin and i want to search in the page source (HTML), like the ctrl+F search, what is the best way to do it?

thanx for any help, Shiran


This should help you, that is a example of how to impliment it

        // Find text like ctr+F (NOT IN SOURCE BUT IN "WHAT YOU SEE"
        if (ie.Text.Contains("SOME TEXT TO FIND").Equals(true))
        {
            //Do stuff you would like when found here
            MessageBox.Show("Text Found! ");

        }
        else
        { 
            // cant find
        }

        //OR

        // Find text in SOURCE
        if (ie.Html.Contains("SOME TEXT TO FIND").Equals(true))
        {
            //Do stuff you would like when found here
            MessageBox.Show("Text Found! ");

        }
        else
        { 
            // cant find
        }


You can use the IE.Text property to get the text of the whole page equivalent to innerText of the body element. Otherwise if you want the raw HTML you can use IE.Html.

0

精彩评论

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