Forum Discussion

amysoap's avatar
Occasional Contributor
7 years ago

Enable & Disable test steps


I am looking for a help. Would you please assist me. I need to disable and enable test steps. 

Below code is not disabling particular steps from Test Steps.

My requirement i want to disable first all the Test steps under test cases then based on scenarios then i need to do enable specific test step. I tried below code as well. But it is not enable/disable specific test steps.


1) Create a Suite and Test case and test steps then trying to disable all the stpes that i have created. Wants to disable particular test steps.



def testStep = testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" )


if( testStep.disabled ){


              testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" ).setDisabled(false)



{ "UnDisabled"

              testRunner.testCase.getTestStepByName( "getDataInputsFromExcel" ).setDisabled(true)





4 Replies

  • PaulMS's avatar
    Super Contributor

    Is the groovy script in the same test case as the step named "getDataInputsFromExcel"?

    If not then result is NullPointerException error.

  • gauravkhurana's avatar
    Occasional Contributor



    // This code dsiable all steps except the current step
    def tc=testRunner.testCase

    // get the current step Name
    String ts=testRunner.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel()

    // looping through all steps
    for(def tstp in tc.getTestStepList())
    String testStepName=tstp.getName()

    if(! (testStepName.contains(ts))) // Making sure all steps gets disabled but not this groovy as the code is written here. Otherwise further code will get stopped
    { "*** Running test step *** " + testStepName

    // after the above step
    //you can define a variable tstp , get the the teststep reference and disable/ it


    //Don't  forget to press the kudos button if it worked for you