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.
精彩评论