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

Add template in Customized Steps field


#1

Hi,
We have added Seperated steps in our Testrail project. In QC I can add html template in Test case Desccription field.
I would like to add a very simple template our Steps field, so that our testers when they are adding new test steps , they get some information pre-filled for them in the Test Step.

Please suggest how to do this.
Thanks


#2

Hello Sumit,

Thanks for your posting. It’s not directly possible to define a default text for the separate step custom field type, but it would be possible to implement this via UI Script. You can use the following UI Script (under Administration > Customizations) to define a default text. You can also learn more about UI Scripts on our website here:

http://docs.gurock.com/testrail-integration/custom-uiscripts

Here’s the script that you can use:

name: Steps template
description: Adds a simple template to case steps
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes: 

js:
$(document).ready(
    function() {
        $('a.addStep').click(function(){
            setTimeout(
                function() {
                    $('table.steps td.content:last div textarea').text('1. Step 1\n1. Step 2\n* Expected result');
                },
                1000
            );
        });
    }
);

#3

Hi Dennis,
Thanks, I checked the code sample you have provided, \n is the code doesn’t return the text in multiple line.Please correct if I am reading it wrong. How can I get Steps and Expected Result in mutiple lines instead of single line text.


#4

Hello Sumit,

Thanks for your feedback. The \n should be converted to a line-break and the above example would insert 3 separate lines like this:

1. Step 1
1. Step 2
* Expected result

Does this not work for you?


#5

Dennis,
When I run the code after saving , it returns the text string in the saved test case step as

  1. Step 1
  2. Step 2
  • Expected result

But in Edit mode in test case step, it is displayed as a Single line text string as

  1. Step 1 1. Step 2 * Expected result

I was looking for Multiline text in the Edit mode , so that User can start adding test steps

  1. Step 1
    Test step1
    Test step 2
  2. Step 2
    Test step1
    Test step 2
  • Expected result
    Expected Result
    Expected Result

#6

What is the function name for Add The First Step ?I will add similar Template in the First Step. As the UI code only works when I click Add Step link.
I can specify to our users to use Add Step link to enter the Test step. It would be nice to have template populated if the user uses the “Add the First Step” link .


#7

Thanks for your update. The following script should fix both issues (now also works with ‘Add the first step’ link and the newline characters should now also be displayed correctly in every browser):

[code]name: Steps template
description: Adds a simple template to case steps
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes:

js:
(document).ready( function() { (‘div.noSteps a, a.addStep’).click(function(){
setTimeout(
function() {
$(‘table.steps td.content:last div textarea’).text(‘1. Step 1\r1. Step 2\r* Expected result’);
},
1000
);
});
}
);[/code]

I hope this helps,
Tobias


#8

Thanks Tobias, that worked :slight_smile:


#9

I am using TestRail 5.1, and this UI script does nothing for me. Has the syntax changed? (the original response is from 4 years ago)

To be clear, I have a project that utilizes the STEPS_SEPARATED customization. I have created the UI script as listed above. I expected that to see text populated in a step as it was added. I see the same default, as if there was no UI script being invoked.

TIA


#10

Hi Phil,

Thanks for your posting. Yes, this has changed slightly and the jQuery selector should now look as follows:

table.steps div.step-text-content:last div textarea

I hope this helps!

Cheers,
Tobias


#11

Hello,

I am running the script that you propose and I see the defaults while trying to add a new step. It seems like the script does not work - TestRail v5.5.1.3746:

{code}
name: Steps template
description: Adds a simple template to case steps
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes:

js:
(document).ready( function() {
(‘div.noSteps a, a.addStep’).click(function(){
setTimeout(
function() {
$(‘table.steps div.step-text-content:last div textarea’).text(‘1. Step 1\r1. Step 2\r* Expected result’);
},
1000
);
});
});
{code}


#12

Hello again,

can you please advice on the above comment, since we are about to create a new project and we want this kind of configuration before business people are involved to write the Acceptance Criteria?

Thank you


#13

Hi @stam,

It would appear the code you were using had been more changes than just the one line mentioned by @tgurock. The following is the most recent example with corrected line and confirmed working on the latest TestRail version 5.5.

name: Steps template
description: Adds a simple template to case steps
author: Gurock Software
version: 1.0
includes: ^cases/(add|edit)
excludes: 

js:
(document).ready( function() { (‘div.noSteps a, a.addStep’).click(function(){
	setTimeout(
		function() {
			$(‘table.steps div.step-text-content:last div textarea’).text(‘1. Step 1\r1. Step 2\r* Expected result’);
			},
			1000
		);
	});
}
);

#14

@vtran Thank you for your answer. I actually managed to add the default texts in both fields of Step ‘Step Description’ and ‘Expected Result’. I am sharing the code with the appropriate comments inside:

This code will create the default texts also in case the ‘+’ (add button in the table in the right of the steps element) is clicked.

The default texts here are the following:

For Step Description field

For Expected Result field


#15

Very nice, thank you stam for the well commented example.