teopanait
teopanait

Reputation: 1

Unable to handle confrimation box with selenium RC

i am trying to press the ok button from a confirmation box like this (i added Thread.spleep so i checked the button is pressed and the confirmation box is shown)

selenium.chooseOkOnNextConfirmation(); 
selenium.click("xpath=//a[contains(@href,'123')]");
assertTrue(selenium.getConfirmation().equalsIgnoreCase("123"));

but i get this

com.thoughtworks.selenium.SeleniumException: ERROR: There were no confirmations
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:262)
at com.thoughtworks.selenium.DefaultSelenium.getConfirmation(DefaultSelenium.java:429)

Thx for your help.

Upvotes: 0

Views: 1586

Answers (2)

Yan Deng
Yan Deng

Reputation: 11

I got the same error with the code

selenium.chooseCancelOnNextConfirmation();//点击cancel按钮
selenium.click("link=Delete");
selenium.getConfirmation();

Finally I find the reason is that the developer used the jconfirm function of jquery instead of window.confirm, and the jconfirm function is override with div.

Finally I used assertTrue(selenium.isElementPresent("id=popup_container")).

Upvotes: 1

sudarsan
sudarsan

Reputation: 283

from this information it is hard to say exactly. but i will give you some info which will help you

java script generates 3 types of pop-up windows

1) Alerts 2)Confirmations 3)Prompts

your case, i guess

1) may be the statement selenium.click() you used, is not triggering the confirmation box

OR

2) if it is triggering, then it may not be the Confirmation box.it could be any one of the other 2 boxes

so, you must make sure manually what type of pop-up window it is and call the statements accordingly.

ex : Confirmation window : conatins OK and Cancel buttons Alert window : contains only OK button Prompt window : contains Textbox and OK and Cancel buttons

so check and use that commands respectively

if it is not the above case please the HTML code also

Upvotes: 0

Related Questions