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

[UI Script] Add Save + Cancel buttons to test case form


#1

The following UI script adds Save + Cancel buttons to the toolbar on the test case form.

[code]name: Add Save + Cancel buttons to test case form
description: Adds Save + Cancel buttons to the toolbar on the test case form
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes:

js:
(document).ready( function() { var save = ("<span class=“actions”><a href="#"><img width=“16” height=“16” src=“images/icons/accept.png”> Save Test Case");
("div#contentHeader").prepend(save); save.click( function() { (’#submit’).click();
}
);

    var cancel = $("<span class=\"actions\"><a href=\"#\"><img width=\"16\" height=\"16\" src=\"images/icons/cancel.png\"> Cancel</a></span>");
    $("div#contentHeader").prepend(cancel);
    cancel.click(
        function() 
        {
            var href = $('#submit').next().attr('href');
            document.location = href;
        }
    );
}

);
[/code]

Regards,
Tobias


#2

Hello Tobias,
this is really good, but we are used to separate steps. When we have more steps it would be nice to have Save + Cancel buttons on the right side panel - Sticky Sidebar. Is it possible to solve it with UI script?

Regards,

Zbynek


#3

Hello Zbynek,

Thanks for your posting and great to hear that you like the UI script. It would also be possible to add the buttons to the sidebar but it’s not so easy to implement this as sticky sidebar. I would recommend using the buttons at the bottom (and top with the UI script) if possible.

Regards,
Tobias


#4

This UI Script doesn’t appear to work with 4.0? Would it be possible to get an updated version? Thanks!


#5

Hello Logan,

Yes, there were some changes with the 4.0 that affect this UI script and we will look into updating this script for the 4.0.

Regards,
Tobias


#6

That’s a good idea as I noticed it was gone after the update.

Mike


#7

Here’s the updated UI script for TestRail 4.0:

[code]name: Add Save + Cancel buttons to test case form
description: Adds Save + Cancel buttons to the toolbar on the test case form
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes:

js:
(document).ready( function() { var save = (‘Save Test Case’);
save.click(
function()
{
$(’#accept’).click();
}
);

    var cancel = $('<a class="toolbar-button toolbar-button-last content-header-button button-cancel" href="javascript:void(0)">Cancel</a>');
    cancel.click(
        function() 
        {
            var href = $('#accept').next().attr('href');
            document.location = href;
        }
    );

var toolbar = $('<div class="toolbar content-header-toolbar"></div>');
toolbar.append(cancel);
toolbar.append(save);
    $("#content-header .content-header-inner").prepend(toolbar);
}

);[/code]

Mike: the new version disables all UI scripts as part of the update because the new version comes with lots of changes to the UI (and CSS/HTML). We recommend verifying/updating UI scripts before enabling them again.

I hope this helps!

Regards,
Tobias


#8

This works again now. I removed another script I was trying out and removed the warning message (click the X) and tested it out, Save/Cancel at top right of screen when editing. Thanks for the update!


#9

Good to hear that and thanks for the confirmation!

Regards,
Tobias


#10

This has been most useful me, many thanks!


#11

Great to hear that and thanks for your feedback on this!

Regards,
Tobias


[UI Script] Add a new button to the sidebar of test runs
#12

Hi, we copied and pasted this code into a UI Script - when we clicked on Add UI script - it comes up with the “error Line 8 uses an invalid format (“name: value” expected).” - can you help please


#13

Hi Irene,

Have you seen the latest TestRail 4.2 release with shortcuts? This allows you to save test case by pressing just Ctrl + S / Command + S, so adding an additional button would not usually be needed anymore:

http://blog.gurock.com/?p=3193


#14

Dennis, many of us still prefer to use a mouse rather than keyboard shortcuts, so the UI script certainly has value to me (and others). As such is there a correction possible to the “error Line 8 uses an invalid format (“name: value” expected).” issue?

Regards,
Neil


#15

Hi Neil,

There’s an issue with how the UI script is rendered in this forum and you would need to add an empty line after excludes:. That said, the UI script above is no longer supported with the latest TestRail version and you can also simply press the Enter key in many fields to submit the form (e.g. the Title field). An alternative is to use the keyboard shortcuts as Dennis mentioned and Ctrl + S can be used throughout the entire application on the forms.

Cheers,
Tobias