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

[UI Script] Question: Hiding fields in test cases/add or edit


#1

Hi,
I would like to hide the Milestone and Priority fields in the test cases.
I’ve tried to make a script according to examples from you documentation and this forum but I just don’t get it right… :confused:
I would really appreciate some help!
Thanks,
/Katarina


#2

Hello Katarina,

Sure, please see below for hiding these fields on the test case form:

[code]name: Hide Milestone and Priority fields on test case form
description: Hides the Milestone and Priority fields on the test case form
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes:

js:
(document).ready( function() { (‘table.io td:eq(2)’).hide();
$(‘table.io td:eq(4)’).hide();
}
);
[/code]

And for hiding these fields on the view pages:

[code]
name: Hide Milestone and Priority fields on test case page
description: Hides the Milestone and Priority fields on the test case page
author: Gurock Software
version: 1.0
includes: ^(cases|tests)/view
excludes:

js:
(document).ready( function() { (‘table.io td:eq(1)’).hide();
$(‘table.io td:eq(3)’).hide();
}
);[/code]

I hope this helps!

Regards,
Tobias


#3

Thanks! :slight_smile:
It works perfectly!
/Katarina


Hiding custom field in test cases
#4

this is great, but I don’t quite understand it (hence I’m a JS noob).

I assume this:

somehow describes the fields to hide. ?

Is there a document to learn from which field has which id ?


#5

Hello,

The ‘table.io td:eq(1)’ is a jQuery selector and this specifies the element to hide (in this case the second element in a table with an ‘io’ CSS class, which refers to the blue table at the top when viewing a test case). You can learn more about jQuery selectors on the following page:

http://api.jquery.com/category/selectors/

I hope this helps!

Regards,
Tobias


#6

that helped - Thanks !
:smiley:


#7

You are welcome!

Regards,
Tobias


#8

I am cautiously entering the world of TestRail UI Scripting and API calling. While I am understanding of this reference to the jQuery selector and ‘io’ CSS class, where would I find reference material for the “includes:” and “excludes:” parameters. In this particular example of hiding fields, how would I have known to use either of the includes parameter, “^(cases|tests)/view”, or “^(cases|tests)\view”. I know there is also “^dashboard”.

Is there a reference that I am not seeing where the names of pages and format usage of these can be found in TestRail blog/documentation? 99% there is and I am just not finding it.

– Tom


#9

Hello Tom!

Thanks for your posting. The includes and excludes options refer to the page in TestRail you want to include/exclude the UI script and you can see the page/URI in your browser (behind the index.php part). The ^(cases|tests) syntax is just a way of saying that the UI script should be included on both the case and test pages. Does this already answer your question?

Cheers,
Tobias