C# – Using WatIN to determine website’s position in google

c++watin

I'm using WatIn – and have the current script:

IE ie = new IE("http://www.google.co.il");
ie.TextField(Find.ByName("q")).TypeText(mykeyword);
ie.Button(Find.ByName("btnG")).Click();

Now I want to be somehow understand which position my website is in.

I know that google wraps website's urls in their pages with(i'm parsing google.co.il):

<span dir=ltr>www.website.co.il/</span>

I know it should be something like:
ie.Span(Find.XXX))

I am new to WatIN and will appreciate any help.

Thanks in advance.

Best Solution

Found the solutions myself:

            using (IE ie = new IE("http://www.google.co.il"))
            {
                ie.TextField(Find.ByName("q")).TypeText(keyword);
                ie.Button(Find.ByName("btnG")).Click();
                int position = 1;
                label1.Text = "";
                foreach (Span span in ie.Spans)
                {
                    if (span.OuterHtml.ToLower().StartsWith("<span dir=ltr>"))
                    {
                        label1.Text += position.ToString() + ": " + span.InnerHtml + "\n";
                        position++;
                    }
                }
            }
Related Question