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

Add button to test projects/overview

Hello, I wish to add a button to the test runs page. I have seen this code from 2013:

[code]name: Add a button to the test run toolbar
description: Adds a new button to the toolbar of test runs
author: Gurock Software
version: 1.0
includes: ^runs/view
excludes:

js:
(document).ready( function() { /* Create the button */ var image = uiscripts.env.resource_base + “images/icons/running.png”; var button = ("<img width=“8” height=“16” src="" + image + “”/> New Button");

    /* Add it to the toolbar */
    $("div#contentHeader span.actions:last").before(button);

    /* Bind the click event */
    $("a", button).click(
        function()
        {
            alert('Clicked!');
        }
    );
}

);[/code]

But it does not work. I am using TestRail 6.5.3.1001 and I am guessing alot has changed since the above code was published as there is no test run toolbar.

My intent is I have an executable jar file that I could call from a .bat file. Preferably, I would like an input text box to handle one parameter which would be the name of a test scenario. The test already runs, creates all the run info and logs the results using the API. My manager would like a button to run it instead of manually running a bat file.

I hope this makes sense and is possible.

This is how I added a button to the toolbar in runs/view:

var button = $('<div class="toolbar content-header-toolbar" id="button_id"><a class="toolbar-button content-header-button button-responsive toolbar-button-last" id="inner_id"style="padding-left: 8px" href="javascript:void(0)">Button caption</a></div>');
	
$("#content-header .content-header-inner").prepend(button);	

You also have to make sure the image exists on the server.

Best regards.

Thank you for the advice, I am getting closer. I am not sure what image I need on the server. I am comfortable using any that is available already to make it work as I just need a button if possible.

I originally posted before understanding what page I need. I am currently working on the projects/overview page. The default ui script that displays a popup works here so I have been hacking away from there. I guess the button can appear anywhere but I am trying to make it appear in the top toolbar along with Reports | Edit

Thanks again!

Edit: So this is where I am:

name: Add Button
description: Add button to toolbar
author: Gurock Software
version: 1.0
includes: ^projects/overview
excludes: 

js:
(document).ready( function() {var button = $('<div class="toolbar content-header-toolbar" id="button_id"><a class="toolbar-button content-header-button button-responsive button-start button-notext" href="javascript:void(0)"></a></div>');

    /* Add it to the toolbar */
    $("#content-header .content-header-toolbar").prepend(button);

    /* Bind the click event */
    $("a", button).click(
        function()
        {
            alert('Clicked!');
        }
    );
}
);

Well, I am have been working on this all weekend and cannot get a button to appear anywhere on the Projects/overview page. If anybody can help with code to put a button on the page (anywhere) , I would be most grateful as I just need a button.

I got it working. Code is messy but it works:

name: Hello world
description: adds a button
author: Gurock Software
version: 1.0
includes: ^projects/overview
excludes: 

js:
$(document).ready(
	function() {
		$('.content-header-toolbar').prepend('<a class="toolbar-button toolbar-button-last content-header-button button-start" id="runTest" href="javascript:void(0)"><span>Run</span></a>');

 $("#runTest").click(
        function()
        {
            alert('Clicked!');
        }
    );
	}

);
2 Likes