Forum Discussion

CrazyFrog's avatar
CrazyFrog
Contributor
7 years ago
Solved

How can i in java check if a teststepname already exists

Hello 

 

I write my own testautomation script in java using the SoapUI API.

My script create teststeps when the aren't there.

How can i check if a teststep is already created?

 

I can use  the code below, but then i have to create a loop.

Is it possible to do a .indexOf('teststepname)  or something like that (without a loop)?

 

listOfTestSteps = testCase.getTestStepList();

listOfTestSteps.get(x).getName()

 

Thanks

 

Raymond

 

  • Here's how I check:

     

    def testStepName = "Name to Check";
    
    if (context.testCase.getTestStepIndexByName(testStepName) == -1)
    {
          log.info("test step does not exist");
    }
    else
    {
          log.info("test step exists.");
    }
    
    

2 Replies

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      Here's how I check:

       

      def testStepName = "Name to Check";
      
      if (context.testCase.getTestStepIndexByName(testStepName) == -1)
      {
            log.info("test step does not exist");
      }
      else
      {
            log.info("test step exists.");
      }