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

Customizing UI script for Add Test Result


#1

In 2.7 you describe a way to customize the Add Test Result screen, however I don’t see any instructions on how to do so.

How can I create a UI script and target it at that screen, or the Push Defect screen?

Thanks


#2

Hello Chris,

Thanks for your posting. TestRail 2.7 introduced new UI script events for the Add Test Result and Push Defect dialogs:

[code]name: Hello world on push dialog
description: Shows a ‘Hello, world!’ message when the push dialog was loaded
author: Gurock Software
version: 1.0
includes: ^tests/view
excludes:

js:
(document).ready( function() { .subscribe(‘push_dialog.loaded’, ‘uiscript’, function()
{
alert(‘Hello, world!’);
});
}
);[/code]

[code]name: Hello world on result dialog
description: Shows a ‘Hello, world!’ message when the test result dialog was loaded
author: Gurock Software
version: 1.0
includes: ^tests/view
excludes:

js:
(document).ready( function() { .subscribe(‘result_dialog.loaded’, ‘uiscript’, function()
{
alert(‘Hello, world!’);
});
}
);[/code]

TestRail 3.0 will add an additional event (‘result_dialog.validate’) that is triggered when the Add Result button is clicked:

[code]name: Make Version field required
description: Makes the Version field required on Add Result dialog
author: Gurock Software
version: 1.0
includes: ^tests/view
excludes:

js:
(document).ready( function() { .subscribe(‘result_dialog.loaded’, ‘uiscript1’, function(o)
{
$(’#addResultVersion’).prev().append(’ *’);
});

    $.subscribe('result_dialog.validate', 'uiscript1', function(o)
    {
        if ($.trim(o.values.version) == '')
        {
            $('#addResultErrors').append('Field Version is a required field.');
            $('#addResultErrors').show();
            o.event.stopPropagation();
            return;
        }
    });
}

);[/code]

I hope this helps and please let me know in case you have any further questions.

Regards,
Tobias