How to determine which type of HTML element is selected in Watir

This is a continuation of Counting the number of HTML elements that have the same attribute in the Vatira question .

So, suppose I have an HTML element as follows

<input type="password" class="foo" /> <span class="foo"></span> <a href='1' class="foo">Text</a> 

So, I can get a collection of all elements having the same class name using

  elements = browser.elements(:class,"foo") 

Since, his collection, I can use each method to iterate through the collection. Iterating over the collection, I want to determine what type of tag is represented? (Something like nodeName or tagName method in Javascript). Is there any way to do this in Vatira?

Code example:

 elements = browser.elements(:class,"foo") elements.each { |element| puts element.<Watir_method_similar_to_nodeName_of_JavaScript> } 
+4
source share
1 answer
 elements.each {|element| puts element.tag_name} 

Output:

 input span a 
+3
source

All Articles