cancel
Showing results for 
Search instead for 
Did you mean: 

Script failue as test compete searching for an object in the if statement and didn't find it

SOLVED
Contributor

Script failue as test compete searching for an object in the if statement and didn't find it

function Unit12()
{
if(Aliases.Device.Process_ionicframework_newpnm295021.RootLayout.WebView_orgapachecordovaengineSystem.HomePage.CustomerAccount.CustomerAccountSearch.CustomerAccountSearch.SearchBYIPV4.SearchBYIPV4.VisibleOnScreen)
{
Log.Message(aa)
}
else
{
KeywordTests.TS01_BackButton.Run();
}
}

 

Can anyone help me to understand - Why my above code is searching the object in the if statement?

 

during playback I am getting message waiting for the object..Preparing an object recognition hint.. 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Leader

Re: Script failue as test compete searching for an object in the if statement and didn't find it

Yo!

 

In belowe code example You have twice:

a) "Aliases.Device.Process_ionicframework_newpnm295021.RootLayout.WebView_orgapachecordovaengineSystem.HomePage.CustomerAccount.CustomerAccountSearch.CustomerAccountSearch.SearchBYIPV4.SearchBYIPV4.VisibleOnScreen"

 

Is this right?

 

b) "Log.Message(aa)" -> use " " inside "aa"

 

1) Try to check you NameMapping repository for correct object values "CustomerAccountSearch". do You have it in repository?

 

2) Do not use "VisibleOnScreen" if you want to check to exist of an object. Use .Exists instead.

View solution in original post

4 REPLIES 4
Contributor

Re: Script failue as test compete searching for an object in the if statement and didn't find it

I got this error-

Unable to find the following object when executing the VisibleOnScreen command:

Aliases.​Device.​Process_ionicframework_newpnm295021.​RootLayout.​WebView_orgapachecordovaengineSystem.​HomePage.​CustomerAccount.​CustomerAccountSearch.​

Community Leader

Re: Script failue as test compete searching for an object in the if statement and didn't find it

Yo!

 

In belowe code example You have twice:

a) "Aliases.Device.Process_ionicframework_newpnm295021.RootLayout.WebView_orgapachecordovaengineSystem.HomePage.CustomerAccount.CustomerAccountSearch.CustomerAccountSearch.SearchBYIPV4.SearchBYIPV4.VisibleOnScreen"

 

Is this right?

 

b) "Log.Message(aa)" -> use " " inside "aa"

 

1) Try to check you NameMapping repository for correct object values "CustomerAccountSearch". do You have it in repository?

 

2) Do not use "VisibleOnScreen" if you want to check to exist of an object. Use .Exists instead.

View solution in original post

Community Hero

Re: Script failue as test compete searching for an object in the if statement and didn't find it

Hi,

 

To add to what was said by Wamboo:

 

> Why my above code is searching the object in the if statement?

Because your code references some object and tries to use some its property (.VisibleOnScreen in your case).

In order to get a value of some property, TestComplete must resolve all referenced objects within objects' chain. If some intermediate object is not found, all child objects cannot be resolved as well and an error will be posted to test log.

Considering your line of code as an example:

First, TestComplete will try to connect to a device.

If succeeded, it will try to find there the Process_ionicframework_newpnm295021 process. (I think that it is logical that there is no sense to look for the process if there is no connected device, isn't it?)

If the process is found, then TestComplete will search for the object referenced by the RootLayout alias. Note, that Aliases tree is based on NameMapping one but may be shortened, i.e. some intermediate objects from NameMapping tree may be excluded from Aliases tree for test code simplicity and manageability. Nevertheless, all parent objects (if any) from the NameMapping tree must exist as well while looking for the given Alias.

And only after the final referenced object is found (SearchBYIPV4 in your case), TestComplete will be able to check if it contains required property (VisibleOnScreen) an get its value.

You must use .WaitXXX() methods (.WaitAliasChild() in your case) instead of direct referencing if some given object may not exist at the moment. .Exists property must be checked then to verify if the object was found and only then you may use the found object.

For example, if the process may not be running, your code should be like this:

if (! Aliases.Device.WaitAliasChild("Process_ionicframework_newpnm295021", 0).Exists) // process is not running

  // start the process and wait until it is ready

else // process is running

  // you may use Aliases.Device.Process_ionicframework_newpnm295021 object in your code

 

Hope this makes things more clear.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Manager

Re: Script failue as test compete searching for an object in the if statement and didn't find it

Hi @mithunpal2,

 

Was the original issue resolved? Please share the solution you decided to use.

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!