How to find an Element in Watin by its tag name?

2019-04-26 09:27发布

How to find a specific element, or a list of elements by using their TagName using Watin?

标签: .net watin
3条回答
老娘就宠你
2楼-- · 2019-04-26 09:48

For example, to find the first <h1> on a page, use:

ie.Element("h1", Find.ByIndex(0))
查看更多
3楼-- · 2019-04-26 09:55

this is what worked for me:

var element = ie.Element(x => x.Text == "[innerText]" && x.TagName == "[tagname]");

查看更多
贪生不怕死
4楼-- · 2019-04-26 09:59

As of WatiN 2.0 beta 1 this has changed to:

ie.ElementWithTag("h1", constraint);

Constraints are created when using the Find.XXX methods.

Here is an example:

ie.ElementWithTag("h1", Find.ByClass("blue");
查看更多
登录 后发表回答