在 Selenium IDE html 代码中找到准确的 运行 时间

Find exact running time in Selenium IDE html code

我正在用 Selenium 进行录制和回放 IDE.I 需要开始时间和结束时间来计算总时间 运行 time.Is 有什么方法可以改变时间 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[&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! 

[info] echo: 5.06 表示你的测试时间是5.06秒。您应该将整个测试放在 Cur_timeCur_time2 的两个 storeEval 调用之间,以捕获开始时间和时间结束。希望这对您有所帮助!