Ask a Question

Object lookup is acting strange

SOLVED
hannecroonen
Contributor

Object lookup is acting strange

Hi all,

 

I have a question regarding object lookups;

I am using this in my tests since I have to check if certain windows are showing or not at the right time.
To reduce my code duplication I did this using object lookups as following;

var windowPaths = {
    "vat rates": AddonHost.VATRatesWindow,"adjust dimensions": function () {
      return logiComWrapper.confirmationWindow.message.Caption.includes(
        "ventilation"
      )
        ? logiComWrapper.confirmationWindow
        : Log.Error("The window caption is not correct");
    },
    "project management import": function () {
      return AddonHost.projectImportWindow.selectBtn.Caption.includes("Project")
        ? AddonHost.projectImportWindow
        : Log.Error("The window caption is not correct");
    },
    "position management import": function () {
      return AddonHost.projectImportWindow.selectBtn.Caption.includes(
        "Position"
      )
        ? AddonHost.projectImportWindow
        : Log.Error("The window caption is not correct");
    },
    "project estimation data": function () {
      while (reynaPro.progressWindow.ProgressDialog.Exists) {}
      return logiComWrapper.estimationOptionsWindow;
    },
    "free cost": AddonHost.addWindow
}

windowPaths[windowName.toLowerCase()]

This is only part of the object lookup, it is much bigger and it seems that whenever I use this it is still running through the complete lookup and searching for all these items whilst many of them are not existing at that point in the program. This make my test fail even though everything is going right.

 

Somebody that has an idea why this is happening?

Looks like it is only at certain values that he gets stuck and others he just ignores...

 

I would think the program only tries to read the 'right' part when the 'left' part is the one you are calling?

 

Thanks in advance,

kind regards.

5 REPLIES 5
Marsha_R
Community Hero

Would you not want to use the Wait function at the time you need each window?

https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/waiting-process-or-window-a....


Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Hi Marsha,

 

it is not that I need all of them to show up.

This is a function that only checks if at a certain step a certain window is shown.

I tried to put this all in one function instead of making numerous smaller functions that all do the same but at different steps in the process.

So for example; if the 'free costs' window should be up -> I run this function but it should only search for that window, not for all the rest in the function...

Read here about the Wait functions. These are built in functions in TestComplete that already do what you are trying to create.

 

https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/waiting-process-or-window-a...

 

For your 'free costs', you would use WaitWindow  then use Exists to make sure it is there when the Wait is done.  There are a lot of examples on that page so you can see how it works.

 

try this on one of your objects and let us know what happens.

 

 


Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Hi Marsha,

 

I know how the wait functions work, I use them a lot throughout my testing framework!

Problem is this function has maybe 200 windows that I need to check and if I would use the wait functions this would delay the program by minutes if not hours so that is not feasible...

I do think this object lookup functionality is not what I was searching for so I went back to using switch cases instead and this works perfectly, I just tried to find a shorter way to implement this.

It would be about 30 minutes if you use the default time out, which I agree is too long, but we worked out ours by changing the wait time between test steps just a little and then changing the default time for the Wait to be shorter. Slowing down the test steps gives more time for the windows (and anything else) to be available before TC looks for it and then the Wait rarely if ever fails.


Marsha_R
[Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: