How to find an Element in Watin by its tag name?
10,308
Solution 1
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"));
Solution 2
For example, to find the first <h1> on a page, use:
ie.Element("h1", Find.ByIndex(0))
Author by
Nikola Stjelja
I'm a father , husband, developer and writer. I also love games, books and tv show and movies. And walking and probalbly something else..
Updated on June 13, 2022Comments
-
Nikola Stjelja about 2 years
How to find a specific element, or a list of elements by using their TagName using Watin?
-
Matthias Schaffer almost 14 yearsCould you expand this example to show what is in the constraint object?
-
Baptiste Pernet over 13 yearsI -1, because this is obsolete
-
Andy123 over 13 yearsBe aware that you are iterating over all the elements in the page, where as ElementWithTag(tagname, constaint) only iterates over the elements with the given tagname.
-
Andy123 over 13 yearsConstraints are created when using the Find.XXX methods. Here is an example: ie.ElementWithTag("h1", Find.ByClass("blue");