【问题标题】:Store the value of Alert Message in Selenium ide在 Selenium ide 中存储 Alert Message 的值
【发布时间】:2016-04-14 18:35:11
【问题描述】:

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

还请说明如何点击警报消息的确定按钮

【问题讨论】:

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

标签: selenium-ide


【解决方案1】:

StoreAlert 和 StoreConfirmation

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.

商店确认

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. 

【讨论】:

    猜你喜欢
    • 2021-05-20
    • 1970-01-01
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多