How to find a specific element, or a list of elements by using their TagName using Watin?
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).
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.
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).
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"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With