Forum Discussion

hca's avatar
hca
New Contributor
6 years ago

Check if a test parameter has a value

Hi,

 

I'm trying to trigger a particular property checkpoint only if a given test parameter has a value.

 

I am using an If ... Then statement, with value: Param_Name Does Not Equal undefined.

 

This works correctly if the parameter is defined, but falls over if it is has no value defined.

 

I have also tried "" and null, but nothing seems to work.

 

Can anyone suggest the best way to do an If ... Then, testing whether a parameter has a value?

 

Thanks

 

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Are you doing script code or a keyword test?

    If you're doing a keyword test, unless the parameter has the "optional" check box set, it will always have a value.  If it has the "optional" set, then it uses the "default" value.  So there will always be a value. 

     

    So, your detection should be whether or not the parameter has whatever you have set as the default value.  Tht will indicate that the parameter has not been set by an external call.

    • hca's avatar
      hca
      New Contributor

      Hi Robert,

       

      Thanks for your reply. I am using a keyword test.

       

      The parameter I am trying to assess via the 'if' statement is an optional parameter. It may or may not have a value, so the default value is blank.

       

      The scenario is actually an address...

      'Addressee Line 1' (Required), 'Addressee Line 2' (Optional).

       

      I am trying to run Property checkpoints against the generated address which is a multi-line text field.

      If there is a value in pareameter Addressee Line 2, then execute a Property Checkpoint to see if the generated address contains that value.

      Else If the parameter is blank, then don't execute that Property checkpoint.

       

      The set of Conditions available do not include "is blank". The closest option is Equals / Does Not Equal.

       

      I have tried the following :

      - If parameter Does Not Equal null

      - If parameter Does Not Equal ""

      - If parameter Does Not Equal undefined

       

      On further tweaking, it looks like I was using the wrong input to define "".

       

      I have now managed to get the condition working by using a type of String and just leaving it blank.

       

      It seems I just needed to bounce it around and try some different angles!

      Sorry to trouble you and thanks for your interest.

       

      Regards

      Heinz