Home > watir > watir and ajax

watir and ajax

So, reminder to myself. Keep in mind that an if you are checking the functionality on an 'onClick' or some seemingly innocent request which is behind the scenes really an ajax request, you have to keep in mind, ajax is a HTTP post request and will need time to return.

example.

Watir: ajax, proving certain states.

So, you fill out a form and hit the 'Add' button, which then
should produce another form element.

assert @ie.button(:value, "Add").click
assert @ie.select_list(:name, 'added_type').value == 'added'

but this fails, stating select_list does not exist.

You probably need to wait till the call has been processed.

i.e.
assert @ie.button(:value, "Add").click
Watir::Waiter.wait_until{@ie.select_lists.length > 2} # or whatever the state change will produce
assert @ie.select_list(:name, 'added_type').value == 'added'

another example:
assert @ie.button(:value, "Add").click
Watir::Waiter.wait_until{@ie.contains_text('Review Info')}
assert !@ie.contains_text('Available Reviewed Information')

Categories: watir Tags: ,
  1. No comments yet.