2016-04-14 91 views
0

如何在Selenium IDE中存储Alert/Confirmation Message的值?在Selenium IDE中存储Alert Message的值

,并也请您解释如何在警报消息

+0

阅读storeAlert文档的最后2段。如果您看到警告消息,则表示您卡住了。 Selenium必须为加载的每个页面重新定义window.alert,以拦截该功能以使其自动化。如果页面在页面加载事件之前提醒消息,Selenium没有这种机会。 (假设本地window.alert,而不是一个JS小部件。) –

回答

1

StoreAlert的OK按钮,然后点击StoreConfiramtion

storeAlert

Returns: 
    The message of the most recent JavaScript alert 

Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts. 

Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not consume it with getAlert, the next Selenium action will fail. 

Under Selenium, JavaScript alerts will NOT pop up a visible alert dialog. 

Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK. 

storeConfirmation

Returns: 
    the message of the most recent JavaScript confirmation dialog 

Retrieves the message of a JavaScript confirmation dialog generated during the previous action. 

By default, the confirm function will return true, having the same effect as manually clicking OK. This can be changed by prior execution of the chooseCancelOnNextConfirmation command. 

If an confirmation is generated but you do not consume it with getConfirmation, the next Selenium action will fail. 

NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog. 

NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK. 
相关问题