Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

watin

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

like image 408
Nikola Stjelja Avatar asked Dec 23 '08 15:12

Nikola Stjelja


People also ask

How do I find the tag name of an element?

tagName. The tagName read-only property of the Element interface returns the tag name of the element on which it's called. For example, if the element is an <img> , its tagName property is "IMG" (for HTML documents; it may be cased differently for XML/XHTML documents).

What is get Element by tag name in javascript?

getElementsByTagName() method returns a live HTMLCollection of elements with the given tag name. All descendants of the specified element are searched, but not the element itself. The returned list is live, which means it updates itself with the DOM tree automatically. Therefore, there is no need to call Element.

Why getElementsByTagName is not working?

The "getElementsByTagName is not a function" error occurs for multiple reasons: calling the getElementsByTagName() method on a value that is not a DOM element. placing the JS script tag above the code that declares the DOM elements. misspelling getElementsByTagName (it's case sensitive).


1 Answers

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"));
like image 167
Jeroen van Menen Avatar answered Nov 01 '22 02:11

Jeroen van Menen