HedonicHedgehog
HedonicHedgehog

Reputation: 592

Watir finds elements by class, but elements are null?

I am able to find elements by class using Watir, but I can't figure out how to do additional processing with them after selection - the elements found are nil (see below).

I would love to see the html text of each element found.

code fragment

Upvotes: 0

Views: 89

Answers (1)

titusfortner
titusfortner

Reputation: 4194

You have instances of Watir::HTMLElement which at time of definition only stores the parent and selector. The @element variable which represents the object in the DOM located by Selenium through a browser driver will only be populated when you take an action on the element.

To see the text of each element, just put puts event.text inside your loop.

Upvotes: 1

Related Questions