如何在 TestRail 中更新红色的失败文本

问题描述 投票:0回答:2

我想更新 TestRail 中的特定文本,例如“通过”为绿色,“失败”为红色。

这是我们输入评论的文本区域。但是看起来 Textarea 不会渲染 html 代码。

https://www.gurock.com/testrail/docs/user-guide/getting-started/editor

当我读到他们不支持文本区域的颜色时..

You cannot use Markdown or HTML within a code block, which makes them a convenient way to show samples of Markdown or HTML syntax:

我们无法更改 HTML 页面,但唯一的选择是将 HTML 代码传递到内容。

有没有可能?

html testrail
2个回答
0
投票

TestRail 尚不支持文本字段中的 HTML,这限制了您只能使用 Markdown,因此您无法真正添加开箱即用的颜色。

您可以做的是为要突出显示的单词定义一个模式,并使用 UI 脚本将样式动态添加到页面元素,例如下面的脚本(您必须适应自己的用例) 。分解它的作用是:

  1. 使用
    .change-column-content
    类查找结果文本元素
  2. 迭代元素
  3. 将字符串
    [FAILED]
    替换为样式化的
    <span>
  4. 每 2 秒循环一次以查找新元素,以防页面发生变化

您可以在这个 TestRail 自定义结果屏幕截图中看到它在 TestRail 中的样子。您还可以查看TestRail UI 脚本文档以获取更多示例和使用详细信息。

name: Customize results text
description: Adds a highlight to string [FAILED] in results history
author: Diogo Rede
version: 1.0
includes: ^runs/view
excludes: 

js:
$(document).ready(function() {
    var get_info = function () {
        $('.change-column-content').each(function (index) {
            if (this.getAttribute("customized") !== 'true') { 
                this.setAttribute("customized", "true");
                this.innerHTML = this.innerHTML.replaceAll("[FAILED]", "<span class='custom-text'>[FAILED]</span>");
            }
        });
    }

    get_info();
    setInterval(get_info, 2000);
});

css:
.custom-text {
    color: white;
    background-color: red;
}

0
投票

我添加了以下 UI 脚本:

name: Highlight Text in Red
description: Highlights any text wrapped in {{red}} with red color in Test Results
author: Your Name
version: 1.0
includes: 
excludes: 

js:
$(document).ready(
  function() {
    // Find all elements where test result content is shown
    $('.markdown, .grid_content').each(function() {
      // Get the current HTML content of the element
      var html = $(this).html();

      // Replace any text wrapped in {{red}} and {{/red}} with red-colored span
      var updatedHtml = html.replace(/\{\{red\}\}([\s\S]*?)\{\{\/red\}\}/g, '<span style="color:red;">$1</span>');

      // Update the element's HTML with the modified content
      $(this).html(updatedHtml);
    });
  }
);

之后 - 我按照以下格式将我想要的文本标记为红色(“红色文本”部分将为红色):

How to do the {{red}}text in red{{/red}} without issues
© www.soinside.com 2019 - 2024. All rights reserved.