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 –