I’m using watir-webdriver and i’m having trouble with a confirmation popup. I click on a ‘Sell’ button and a confirmation popup appears. I can’t seem to figure out how to come up with the step to click ‘OK’ on the popup. Any help would be much appreciated.
The html in question is: (Button)
<button>class="btn primary" onclick="return confirm('Are you sure you wish to sell the selected loan parts?');" value="Sell Loan Parts" name="sell_loan_parts" style="" type="submit"</button>
I tried using following step, but I guess this is incorrect:
@browser.button(:onclick, "return confirm('Are you sure you wish to sell the selected loan parts?');").click
Error message I recieve is:
Modal dialog present (Selenium::WebDriver::Error::UnhandledAlertError)
[remote server] file:///var/folders/fd/hjkxr06j6gs6620tl4k_9fh00000gn/T/webdriver-profile20121129-50930-ul24fl/extensions/fxdriver@googlecode.com/components/command_processor.js:10402:in `unknown'
Watir has an api for handling these types of javascript alerts. Some useful links:
You should be able to click OK in the confirm by doing: