Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

[UI Script] Hide Add Test Run button on the runs/overview page


#1

In our TestRail environment I want all of my designers to only create test plans, and not test runs. It was mentioned several times in our process documents, but I still have people creating test runs instead of test plans. Normally, this isn’t a problem (just delete the test run, add a test plan); however, I may not catch it for a day or two, and I don’t want to delete test runs that already have results added.

Is there already a UI script to hide the Add Test Run button on the runs/overview pages? My initial search didn’t find one.

Thanks,
Don


Disabling "Add Test Run" Button
#2

Actually, that turned out to be easier than I anticipated:

name: Hide Add Test Run Button
description: Hides the Add Test Run Button
author: Don Young
version: 1.0
includes: ^runs/overview
excludes: 

js:
$(document).ready
(
    function() 
    {
        $("a.sidebar-button.bottom").hide();
    }
);

#3

There might be a better method of selecting the Add Test Run button in the javascript (it doesn’t have an id), but I didn’t see any other “sidebar-button bottom” classes in the HTML source.


#4

Hi Don!

Thanks for your posting. There are other places where you can start test runs under some circumstances but removing the Add Test Run button would cover 99% of all cases. You can chance the selector to something like the following to be more efficient (but it shouldn’t really matter on the test run overview page from a performance perspective):

$('#sidebar a.sidebar-button.bottom');

Regards,
Tobias


#5

Thanks. For posterity here’s the updated version:

name: Hide Add Test Run Button
description: Hides the Add Test Run Button
author: Don Young
version: 1.0
includes: ^runs/overview
excludes: 

js:
$(document).ready
(
    function() 
    {
        $('#sidebar a.sidebar-button.bottom').hide();
    }
);

#6

Thanks, Don!

Regards,
Tobias


#7

What change can I make to hide the Test Plan as we use Test Runs exclusively.

Thanks,

Brian


#8

Hi Brian,

You can use the following UI script in this case (not necessarily recommended though as test plans are very useful for starting multiple runs or testing against multiple configurations!):

name: Hide Add Test Plan Button
description: Hides the Add Test Plan Button
author: Tobias Gurock
version: 1.0
includes: ^runs/overview
excludes: 

js:
$(document).ready
(
    function() 
    {
        $('#sidebar a.sidebar-button:eq(0)').removeClass('bottom');
        $('#sidebar a.sidebar-button:eq(1)').hide();
    }
);

Regards,
Tobias


#9

Thanks - I can let my team know and decide. We really do not have different configs - we initially started to do Test plans but boss decided not to use them.


#10

You are welcome, Brian!

Regards,
Tobias


#11

You need to be sure to specify the exact button you want to remove, or else it will impact every screen where that button appears, for example the Add Test Plan page. I followed this model the first time, and it removed the Add Test Suite button on that page.

If you add the remove( ":contains('Add Test Run') piece as indicated below, it will target just that one button.

js:
$(document).ready(
function() {
  $( "a.sidebar-button.bottom" ).remove( ":contains('Add Test Run')" );
}
);

On another note, has anyone been able to execute multiple functions from a single script? I seem to be able to only get one to run…


#12

Hi Jon,

Thanks for your posting! You can alternatively also limit UI scripts to certain pages via the includes option and this looks as follows:

includes: ^runs/overview

Cheers,
Tobias


#13

How does that work for popups? Are those considered new pages, or is there something specific we should do?

Also, I ended up going this route mainly because I was having to target other elements on the page, and so it was just easier to continue this trend across the board once I figured it out.


#14

Hi Jon!

This UI script would be included on the runs/overview page in this case and this would be independent of popups or dialogs. Are you trying to target or customize a popup/dialog (if so, which one)? There’s limited support for UI scripts and dialogs in TestRail but there are some special dialog events you can use (e.g. for the Add Test Result dialog).

Cheers,
Tobias


#15

I am looking at making tweaks to the test result popup, but wasn’t sure how to target that popup.


#16

Hello Jon,

You would need to target the pages on which the result dialog can be shown and this includes runs/view and tests/view. The includes option would look as follows in this case:

includes: ^(runs|tests)/view

The result dialog supports several events and they can be used as follows:

name: Demonstrate loaded event on result dialog
description: Demonstrate the loaded event on the Add Result dialog
author: Gurock Software
version: 1.0
includes: ^(runs|tests)/view
excludes: 

js:
$(document).ready(
    function() {
       $.subscribe('result_dialog.loaded', 'uiscript_test_load', function(o)
       {
           alert('loaded!');
       });
    }
);

Other events are result_dialog.validate and results.added.

I hope this helps!

Cheers,
Tobias