2016-04-12 30 views

回答

0

storeText(定位器,VARIABLENAME)命令中使用的文本值硒IDE用於存儲文本值。

例如,

    在警報消息
  • ,文本值有定位X
  • 要將該消息存儲在變量瓦爾

所以,你可以寫命令storeText | X | Var

現在,爲了將此消息與已定義的消息進行比較,首先將消息存儲在變量中。

商店(表達式,VARIABLENAME)命令用於在你的情況下可變

存儲值,可以在可變VAR1存儲消息ý

所以可以寫命令存儲| Y | VAR1

對於比較信息您可以在下面的用戶命令

verifyEval | storedVars ['Var'] == storedVars ['Var1'] | true

如果兩個字符串不匹配,則如果兩個 字符串匹配,則運行此腳本將導致測試通過,如果兩個字符串不匹配,則會失敗並顯示[錯誤]。

我希望它適合你。

+0

謝謝...它爲我的腳本 –

+0

工作歡迎@VaishaliBajpai –

+0

這個命令不工作時,警報信息顯示屏上彈出與OK鍵 –

0

如果你談論的是默認的JavaScript警告或確認有它兩個命令:

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. 

檢查了這一點也是: Working example