cancel
Showing results for 
Search instead for 
Did you mean: 

Check if a test parameter has a value

hca
New Contributor

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

 

Tags (2)
2 REPLIES 2
tristaanogre
Community Hero

Re: Check if a test parameter has a value

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
hca
New Contributor

Re: Check if a test parameter has a value

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

 

 

 

 

 

 

 

 

New Here?
Join us and watch the welcome video:
Announcements