开发者

Unable to handle confrimation box with selenium RC

开发者 https://www.devze.com 2023-03-18 14:59 出处:网络
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)

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.chooseOk开发者_JAVA百科OnNextConfirmation(); 
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.


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")).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号