Ask a Question

Do i put the IF...then & Else statement in the wrong location?

SOLVED
bdrummond
Contributor

Do i put the IF...then & Else statement in the wrong location?

hi there, 

i have issue trying to have my If...Then and Else statement to work with my object in my keyword test project. 

Scenario: 

As you can see from the image- i have an If...Then...Else... statement.. there are two scenarios i am applying to my test. 

First, when opening an old database and IF the Database Upgrade object is Visible (true) THEN go on and update the database - this working as expected (ELSE didnt get touched) 

Secondly, i am repeating the same test, but this time with an already upgraded database. because the databaseUpgrade object shouldn't appear I'd expect to have the keyword-test to skip the pre-determined test and go straight into ELSE statement...but this is not the case. 

Do i put the IF...then & Else statement in the wrong location?? 

or am I doing this in the very bad/wrong way? 

your advise is appreciated. 

Regards, 

5 REPLIES 5
cunderw
Community Hero

You're if statements are correct, but you're getting the error because you're checking for a property on an object that doesn't exist. When an object can't be found in test complete you get a stub object with a single property, Exists=false.

 

You should first check if the object exists, then check if it's visible. You could even set visible = true in your name mapping conditions and the only have to check for exists and not both for your if statement. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped

hi cunderw.

 

thanks for your input. not quite sure on how to do with your suggestion, I have tried this (see image) but still to no avail.

 

sorry - i am quite new to keyword testing.

 

regards,

 

 

You're still checking the Visible property of an object that doesn't exist which is the cause of the error. 

 

In you if statement change Aliases.IC.databaseUpgrade.Visible to Aliases.IC.databaseUpgrade.Exists it should fix.

 

 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped

Hi @cunderw.

 

I just went and try this (which i was sure that i have tried this method before..hmm) suggestion you gave me. it works like a charm.

 

tested both scenarios and it works as expected. Thank you again with your help. 

 

Kind Regards,

 

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: