Scenario:
1.Open the Google search site
2.Search with keyword "testing"
3.Need to count the number of occurance of string "Cached" in the Searched result page of google
Use the script below to complete the above scenario,
function countString ( SearchForStr, msg, count )
{
i = 0;
msg = document.wlSource
do
{
offset = msg.indexOf(SearchForStr)
if (offset == -1)
{
return i;
}
l = SearchForStr.length;
offset = offset + l;
msg = msg.substring(offset,65535);
i++;
}
while (i <= 65535)
}
SearchForStr = "Cached"
count = 0
x = countString (SearchForStr, msg, count )
InfoMessage(x)
x - is the count for the number of times searched string occurs.
No comments:
Post a Comment