I have used click_no_wait to click a button and then used javascript_dialog.button('OK').click to click the “OK” button on the resulting pop up. This has worked in all situations except for one for me. It appears the click_no_wait is clicking too fast.
By this I mean that when I use click_no_wait the button on the page flashes (as if clicked) but the pop up does not occur, and then my Watir app hangs, waiting for the pop up which does not pop up. If I switch to click then the pop up occurs, but the Watir app hangs (as would be expected).
Is there another option available? The code is below. (I cannot link the actual site, it is behind a passworded area)
Ruby / Watir:
browser.button(:name => "dgPermission:_ctl"+num+":_ctl1").click_no_wait
browser.javascript_dialog.button('OK').click
HTML:
<html><body><div><table style="width:100%; height:600px;"><tr>
<td>Group Name</td>
<td><span disabled="disabled"><input id="dgPermission__ctl2_cbAdd" type="checkbox" name="dgPermission:_ctl2:cbAdd" checked="checked" disabled="disabled" /></span></td>
<td><input type="submit" name="dgPermission:_ctl2:_ctl0" value="Edit" /></td>
<td><input type="submit" name="dgPermission:_ctl2:_ctl1" value="Delete" onclick="javascript:if (!confirm('Are you sure you want to remove this permission?')) return false;" language="javascript" /></td>
</tr></table></div></body></html>
(The page can contain multiple groups, so the middle section could have multiples of that section, each with a different number ID in the dgPermission name)
as far as I know the only difference between click and click_no_wait is what happens after the click is sent.
potentially you could try firing off the event directly