3
votes

I recently started using Watir-Webdriver after previously using Watir since I needed some functionality which was present in webdriver but not in Watir. I am facing a problem in watir-webdriver which I never faced in Watir.

Whenever one used the click method on a button in Watir, it used to implicitly wait till the new page is loaded completely. I read on the Watir-webdriver docs that the waiting and in this question that the waiting in watir-webdriver has been changed so as to accommodate the dynamic changes made to a webpage made by AJAX. Now, the page which I am automating does not have any AJAX elements, it only contains static elements.

But when I used the click method in watir-webdriver, it does not wait for the next page to load implicitly and executes the next line in the call immediately. I could use is wait_until_present but to do it for lots of pages seems like an overkill to me when waiting for a page to load on a click seems to be the standard behavior.

Am i missing some options which I need to toggle so that the click method of Watir is emulated in watir-webdriver?

2
are you sure the page is not loading portions via javascript calls, such as custom controls, jquery, etc?Chuck van der Linden
The waiting has not so much changed as we have added additional helper methods to allow you to deal better with situations where the browser reports that it is done loading the page (all files specified in the html are loaded) but client side actions are still rendering, making changes, and/or loading additional content. This can sometimes happen even in 'static' pages if there is a lot of javascript and CSS class magic happening to control positioning and rendering of objects on the page.Chuck van der Linden

2 Answers

1
votes

If you are having problems where the browser is indicating the page is loaded, but stuff is still happening client side (might be javascript code executing, or css logic etc) then I'd suggest using the 'when_present' decorator in front of your action.

That's a little cleaner than having to put in a separate wait step, and is a lot better than fixed sleep periods etc.

browser.button(:how => 'what').when_present.click
1
votes

you may also wait for the div to load if you want the content to load but not click.

browser.div(:how => 'what').wait_until_present