Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Watir Invisible Button Breaking Ruby Script

I’m using Watir to load a page. It loads items, and has a LOAD MORE button at the bottom if there are further products.

In the HTML the button exists even if there are no more items to load, but it’s invisible. So my logic breaks.

Instead of relying on a rescue, how can Watir handle this instead? My current qualifier is the following:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if a.button(class: 'load-more-button action').exist?

It does exist, however in the visible page, the button is hidden because there are no more items to load. Hence confusion.

There is no .visible? method that I can find. So there’s a difference between visible and what’s always reported as true in the HTML.

Anybody know how I can qualify the presence of this element? Cheers

>Solution :

The #visible? method is now aliased with the #present? method.
It will return false if the element does not exist in the DOM, or if it exists but is not displayed on the page.

https://github.com/watir/watir/blob/v7.1.0/lib/watir/elements/element.rb#L537

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading