0
我正在Selenium IDE中進行記錄和回放。我需要開始計算總運行時間的時間和結束時間。是否有任何方法可以讓時間更改html代碼?在Selenium IDE中查找確切的運行時間html代碼
我正在Selenium IDE中進行記錄和回放。我需要開始計算總運行時間的時間和結束時間。是否有任何方法可以讓時間更改html代碼?在Selenium IDE中查找確切的運行時間html代碼
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["Cur_time2"].getTime() - storedVars["Cur_time"].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_time和Cur_time2以捕獲開始時間和結束時間。希望這可以幫助!
Abhinav Singh thank you.it正在工作 –
很高興知道它有幫助!請通過這篇文章:http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –