简体   繁体   English

范围报告 - 折叠父节点以看不到子节点

[英]Extent Reports - Collapse Parent Nodes to NOT see Child Nodes

So I have just added Extent Reports (Version 4.0.6) to the testing framework and everything is looking great BUT there's just one thing I am trying to do which I don't know if it's even possible..所以我刚刚将范围报告(版本 4.0.6)添加到测试框架中,一切看起来都很棒,但是我正在尝试做一件事,我不知道它是否可能..

So basically, I know you can do this (logic isn't exact):所以基本上,我知道你可以做到这一点(逻辑不准确):

extentNode = extentTest.createNode(TestStep1);
reportExtentNode2 = extentNode.createNode(childParam1);
reportExtentNode2 = extentNode.createNode(childParam2);
reportExtentNode2 = extentNode.createNode(childParam3);

Which would look like this:看起来像这样:

-Test Step 1
 --Child Node 1
 --Child Node 2
 --Child Node 3

-Test Step 2
 --Child Node 1
 --Child Node 2

This layout is great, but I don't want to see the child nodes unless I click on the parent node..这个布局很棒,但我不想看到子节点,除非我点击父节点..

-Test Step 1 (3 x Child Nodes hidden)
-Test Step 2 (2 x Child Nodes hidden)

It looks that it can be done (sort of) if I edit the HTML (I think it's the HTML part) of the file.. But I'd like to be able to get it right without having to edit the file like that..如果我编辑文件的 HTML (我认为它是 HTML 部分),它看起来可以完成(有点)。但我希望能够正确地完成它而不必像那样编辑文件。 .

I think the following snippet should work (tested with 4.0.9):我认为以下代码段应该可以工作(用 4.0.9 测试):

$('.detail-head').next().find('.accordion > .card').find('.accordion').hide();
$(document).ready(function() {
  $('.card-header').click(function() {
    $(this).siblings('.accordion').toggle()
  });
});

In order to execute it you need to use the instance of ExtentSparkReporter or ExtentHtmlReporter and call reporter.config().setJS(yourSnippet)为了执行它,您需要使用ExtentSparkReporterExtentHtmlReporter的实例并调用reporter.config().setJS(yourSnippet)

It's possible, below is a snippet that works with the latest version 5 with mouseover/mouseout (can be changed to click):这是可能的,下面是一个与最新版本 5 一起使用鼠标悬停/鼠标悬停的片段(可以更改为单击):

$('.test-item').click(function() {
  $('.detail-head + div > .accordion').find('.accordion').addClass('d-none');
});

$('.test-content-detail').mouseover(function(evt) {
  var t = $(evt.target);
  if (t.is('.detail-head + div > .accordion > .card') || t.is('.detail-head + div > .accordion > .card > .card-header')) {
    $(this).find('.accordion').removeClass('d-none');
  }
})

$('.test-content-detail').mouseout(function(evt) {
  var t = $(evt.target);
  if (t.is('.detail-head + div > .accordion > .card')) {
    $('.detail-head + div > .accordion').find('.accordion').addClass('d-none');
  }
})

Note: the above is not a ready-made solution but can be further customized to build out this behavior.注意:以上不是现成的解决方案,但可以进一步定制以构建此行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM