【问题标题】:Understanding Robot Log (log.html) file construction了解机器人日志 (log.html) 文件构建
【发布时间】:2019-01-29 17:18:38
【问题描述】:

我是 Robot 框架的新手,我想自定义测试套件完成后生成的 log.html 的输出。

我查看了log.html的源代码,发现下面一行负责添加测试执行日志

addTestExecutionLog(topsuite);

上述函数的内容如下,

function addTestExecutionLog(main) {
    $('body').append($('<h2>Test Execution Log</h2>'),
                     $.tmpl('suiteTemplate', main));
}

log.html 有 jquery-template 用于 suiteTemplatetestTemplate 分别负责添加套件和测试用例。

虽然testTemplate 模板是在源代码中定义的,但我找不到调用它们的位置。因为$.tmpl('suiteTemplate', main),只调用suiteTemplate

测试用例的testTemplate 在哪里使用?

log.html 中的testTemplate 代码:

<script type="text/x-jquery-tmpl" id="testTemplate">


  <div id="${id}" class="test">
    <div class="element-header closed" onclick="toggleTest('${id}')">
      <div class="element-header-left" title="{{html fullName}}">
        <span class="elapsed" title="Elapsed time">${times.elapsedTime}</span>
        <span class="label ${status.toLowerCase()}">TEST</span>
        <span class="name">{{html name}}</span>
        {{if !isCritical}}(non-critical){{/if}}
      </div>
      <div class="element-header-right" onclick="stopPropagation(event)" title="">
        <a class="expand" title="Expand all" href="javascript:expandAll('${id}')"></a>
        <a class="collapse" title="Collapse all" href="javascript:collapseAll('${id}')"></a>
        <a class="link" title="Link to this test" href="#${id}" onclick="makeElementVisible('${id}')"></a>
      </div>
      <div class="element-header-toggle" title="Toggle visibility"></div>
    </div>
    <div class="children">
      <table class="metadata">
        <tr>
          <th>Full Name:</th>
          <td>{{html fullName}}</td>
        </tr>
        {{if doc()}}
        <tr>
          <th>Documentation:</th>
          <td class="doc">{{html doc()}}</td>
        </tr>
        {{/if}}
        {{if tags.length}}
        <tr>
          <th>Tags:</th>
          <td>{{html tags.join(', ')}}</td>
        </tr>
        {{/if}}
        {{if timeout}}
        <tr>
          <th>Timeout:</th>
          <td>{{html timeout}}</td>
        </tr>
        {{/if}}
        <tr>
          <th>Start / End / Elapsed:</th>
          <td>${times.startTime} / ${times.endTime} / ${times.elapsedTime}</td>
        </tr>
        <tr>
          <th>Status:</th>
          <td><span class="label ${status.toLowerCase()}">${status}</span> ({{if isCritical}}critical{{else}}non-critical{{/if}})</td>
        </tr>
        {{if message()}}
        <tr>
          <th>suri Message:</th>
          <td class="message">{{html message()}}</td>
        </tr>
        {{/if}}
      </table>
    </div>
  </div>

【问题讨论】:

    标签: jquery robotframework jquery-templates


    【解决方案1】:

    经过调试发现下面的函数也是负责的。

    function drawCallback(element, childElement, childrenNames) {
        return function () {
            util.map(childrenNames, function (childName) {                
                var children = element[childName + 's']();
                var template = childName + 'Template';
                util.map(children, function (child) {
                    $.tmpl(template, child).appendTo(childElement);
                });
            });
        }
    }
    

    轨迹是这样的

    at drawCallback (log.html:571)
    at populateChildren (log.html:565)
    at expandElement (log.html:594)
    at expandRecursively (log.html:622)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      • 2021-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多