Allowing Child Steps in Custom Python Test Step

Hello, I am currently trying to allow my custom Python Test Step to have child steps. This is the code:

@attribute(OpenTap.Display("If", "Will run its child steps if the two fields are equal", "Custom"))
class IfStep(TestStep):
    Value1 = property(String, None)\
        .add_attribute(Display("Equals", "", "Parameters"))
    Value2 = property(Input[String], None)\
        .add_attribute(Display("If",  "", "Parameters"))
    def __init__(self):
      super().__init__()
      self.Value2 = Input[String]()
      self.AllowAnyChild = True
    def Run(self):
      super().Run()

Even though I have set the AllowAnyChild attribute to True, within OpenTAP I am not able to add child steps to this step. Here is what OpenTAP looks like on my end:
image

How do I add child steps to a custom-built Test Step?

1 Like

Hi jrobin,
The correct syntax to achieve this would be:

@attribute(OpenTap.Display("If", "Will run its child steps if the two fields are equal", "Custom"))
@attribute(OpenTap.AllowAnyChild())
class IfStep(TestStep):
   ...

An example of this can be found in BasicFunctionality.py from the PythonExamples plugin.

3 Likes

I just tried it and it works. Thank you Ivan.

2 Likes