2016-11-25 93 views

回答

0

storeEval可以幫助你! 在selenium IDE中運行它作爲您的源代碼。

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head profile="http://selenium-ide.openqa.org/profiles/test-case"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<link rel="selenium.base" href="http://192.168.0.118:8080" /> 
<title>New Test</title> 
</head> 
<body> 
<table cellpadding="1" cellspacing="1" border="1"> 
<thead> 
<tr><td rowspan="1" colspan="3">New Test</td></tr> 
</thead><tbody> 
<tr> 
    <td>storeEval</td> 
    <td>{new Date()}</td> 
    <td>Cur_time</td> 
</tr> 
<tr> 
    <td>echo</td> 
    <td>${Cur_time}</td> 
    <td></td> 
</tr> 
<tr> 
    <td>pause</td> 
    <td>5000</td> 
    <td></td> 
</tr> 
<tr> 
    <td>storeEval</td> 
    <td>{new Date()}</td> 
    <td>Cur_time2</td> 
</tr> 
<tr> 
    <td>echo</td> 
    <td>${Cur_time2}</td> 
    <td></td> 
</tr> 
<tr> 
    <td>storeEval</td> 
    <td>{(storedVars[&quot;Cur_time2&quot;].getTime() - storedVars[&quot;Cur_time&quot;].getTime())/1000}</td> 
    <td>diff</td> 
</tr> 
<tr> 
    <td>echo</td> 
    <td>${diff}</td> 
    <td></td> 
</tr> 
</tbody></table> 
</body> 
</html> 

你應該得到以下輸出:

[info] Playing test case Untitled 
[info] Executing: |storeEval | {new Date()} | Cur_time | 
[info] script is: {new Date()} 
[info] Executing: |echo | ${Cur_time} | | 
[info] echo: Fri Nov 25 2016 14:27:37 GMT+0530 (India Standard Time) 
[info] Executing: |pause | 5000 | | 
[info] Executing: |storeEval | {new Date()} | Cur_time2 | 
[info] script is: {new Date()} 
[info] Executing: |echo | ${Cur_time2} | | 
[info] echo: Fri Nov 25 2016 14:27:43 GMT+0530 (India Standard Time) 
[info] Executing: |storeEval | {(storedVars["Cur_time2"].getTime() - storedVars["Cur_time"].getTime())/1000} | diff | 
[info] script is: {(storedVars["Cur_time2"].getTime() - storedVars["Cur_time"].getTime())/1000} 
[info] Executing: |echo | ${diff} | | 
[info] echo: 5.06 
[info] Test case passed 
[info] Test suite completed: 1 played, all passed! 

[信息]迴音:5.06意味着你的測試時間爲5.06秒。您應該將整個測試放在兩個storeEval調用之間,分別爲Cur_timeCur_time2以捕獲開始時間和結束時間。希望這可以幫助!

+1

Abhinav Singh thank you.it正在工作 –

+0

很高興知道它有幫助!請通過這篇文章:http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –

相關問題