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

UI Scripts during test result posting


I’m finding that while UI scripts are executed upon the loading of a new page, if I update the test results page with a new test result, the UI scripts fail to run. I believe most scripts are using the document ready function of jquery. Should they be using something else?



Hello Chris,

Could you post an example UI script and steps to reproduce so we can try this here? Thank you.



In creating a minimal reproduction, I noticed that it doesn’t always happen, but here’s an example that works. This UI Script adds a button beside “Test Case” on a tests screen. Its there when the screen first loads, but if you add a test result on the page, it disappears.

I’ve had similar things happen with other UI scripts.

name: Test button
description: Adds a test button
author: Gurock Software
version: 1.0
includes: ^tests

(document).ready( function() { (“div#contentHeader span.actions”).before(“test”);

div.some-class {


Hello Chris,

Thanks for the additional details. The issue here is that parts of the page are reloaded via Ajax after adding a new test result or comment (e.g. to update the background color and other parts of the title banner). This then reverts the changes you’ve made via the UI script in your document.ready handler. There’s currently no easy workaround to change this behavior but we will look into adding additional JavaScript events so you can reapply your UI script after specific actions (we’ve already added a few events in TestRail 2.7, e.g. when the Add Test Result or Push Defect dialogs were loaded).

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



I figured it was an AJAX load causing the problem. I suppose you’re rewriting most of the screen, since we have other elements that are part of the test results (such as changing image links into image tags) that also seem to disappear.

Until we get a new event, we can live with refreshing the screen after a submission.

Thank you


Yes, this would work as well in the meantime. We will make sure to consider new events for one of the next TestRail versions.

Have a good weekend.



I know this is a pretty old thread, but I think I’m running into this exact issue… I have a UI script that adds a button to the test result page (I ended up using the trigger.ui example provided by gurock as a base, changing the include from ^runs/view to ^tests/view). After adding a new test result, the button goes away. When I refresh the page, the button returns. Is there any known solution or workaround yet for this issue?



Hello Alex,

Thanks for your posting. Some elements are reloaded via JS when you add a test result and this also includes the title bar and sidebar. If you reload the page after submitting a test result, the button would be back and there’s currently no other workaround unfortunately for this use case.