tags:

views:

260

answers:

1

Hi,

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.

A: 

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++;
                    }
                }
            }
Eytan Levit
You can even remove the if when you use Filter on the Spans collection like this:foreach(Span span in ie.Spans.Filter(Find.By("dir", "ltr"))
Jeroen van Menen