我正在使用WatIn - 并拥有当前脚本:
IE ie = new IE("http://www.google.co.il");
ie.TextField(Find.ByName("q")).TypeText(mykeyword);
ie.Button(Find.ByName("btnG")).Click();
现在我想知道我的网站在哪个位置。
我知道谷歌在他们的网页上包含网站的网址(我正在解析google.co.il):
<span dir=ltr>www.website.co.il/</span>
我知道它应该是这样的: ie.Span(Find.XXX))
我是WatIN的新手,非常感谢您的帮助。
提前致谢。
答案 0 :(得分:3)
自己找到解决方案:
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++;
}
}
}