qaispak qaispak - 27 days ago 8
Ruby Question

Watir wont wait for page to be loaded

I am loading a page and then clicking on an element in that page. Currently I am using sleep to click on it but I don't feel that is robust enough (also, it disappears after a while).

@myvariable = on(page2).target_link_element.wait_until_present().link.text

The wait_until_present() seems to be achieving nothing. If I do not add sleeps the code just races through. Only works with sleep (3) but I want to avoid that.

Also, I am using pageobjects gem for my pages.

Answer Source

You should upgrade to the latest version of Watir, currently v6.8.4. Since v6.5.0, there have been a number of bug fixes that have addressed the issue you are seeing.