TestRail UI Scripts

TestRail provides the ability to customize the user interface via so called UI Scripts. UI Scripts are a very flexible tool for administrators to customize parts of TestRail’s design and behavior by writing standard JavaScript code and by defining simple style sheets.

UI Scripts can be applied to single pages, multiple pages or even the whole application. You don’t need a special development environment or framework to write UI scripts, as you can simply define and test scripts directly in TestRail. Basic HTML, CSS and JavaScript knowledge is required to write UI Scripts, but it’s possible to learn this while writing your first simple scripts.

[1]

Why We Need to Disable “Test Run” Button?

We need to disable “Add Test Run” button in “Test Runs & Results” tab. Each agile sprint we should first add “Test Plan” and then we have to add “Test Run(s)” inside previously created “Test Plan”. When “Add Test Run” button is not disabled, many testers click that button and add a “Test Run” without a “Test Plan” by mistake. Thus, I needed to disable that button with below UI script.

Button

First, go to Administration -> Customization section.

2016-09-02_19-53-13

Click “Add UI Script” button.

2016-09-02_19-54-37

And paste below code and click “Save UI Script” button.

Note: If you want to disable another element, you should find its locator and then change the script.

2016-09-02_19-56-30

Result

2016-09-02_19-30-59

From now on, you can not create a “Test Run” accidentally. First, you should create a “Test Plan”, then inside that plan, you can add “Test Run(s)”

2016-09-02_20-01-55

Better Solution:

You can do the same operation only for Test Runs & Results page with css. Thanks to Dennis Gurock for his feedback.

References

[1] http://docs.gurock.com/testrail-custom/uiscripts-introduction