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))
Share:
10,308
Nikola Stjelja
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, 2022

Comments

  • Nikola Stjelja
    Nikola Stjelja about 2 years

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

  • Matthias Schaffer
    Matthias Schaffer almost 14 years
    Could you expand this example to show what is in the constraint object?
  • Baptiste Pernet
    Baptiste Pernet over 13 years
    I -1, because this is obsolete
  • Andy123
    Andy123 over 13 years
    Be 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
    Andy123 over 13 years
    Constraints are created when using the Find.XXX methods. Here is an example: ie.ElementWithTag("h1", Find.ByClass("blue");