Ask a Question

Best way to execute an action if a control is visible?

SlickRick
Contributor

Best way to execute an action if a control is visible?

First sorry if this question was already asked but i have created a shared keyword test to try and perform an action only if a control is visible:

SlickRick_0-1692817086032.png

Initially in my condition i had only the Control.Visible check but was throwing an error since the control did not exist for that case.

This is when i added the Control.Exists first check.

What bothers me is that this check make my test much slower when the control in question is not available.

 

For example when this control does exist, it would take 10sec to execute my test. But if it is not available, my test would then take 20-25sec to perform the same thing.

Therefore i was wondering if i was doing the right way or if there was a better way that would speed up the check?

 

Thanks!

 

5 REPLIES 5
Marsha_R
Champion Level 3

Instead of just Exists, you can use a Wait to do a similar thing and also control the timing. Here's a reference for that:

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

rraghvani
Champion Level 3

The existence of an object is based on this time, in project settings.

rraghvani_0-1692865734656.png

Note, to check the property value of Visible, the Object must exist.

 

Best to use what @Marsha_R has mentioned.

Hi @Marsha_R thanks for the reply. However in my case there are some cases where the control might not be present at all and it would be ok.

Using changing the timeout might be good for me to reduce the wait time, but .Exists seems to be the only property i can use to avoid a crash and to correctly figure out if the control is available or not.

@rraghvani Thanks!
From what i can read from the links, i can conclude that the approach i am using to determine if a control is available and visible to the user is correct. However i could reduce the wait timeout to avoid waiting too long. 

 

Thanks to both of you!

You use the Wait to see if it exists and then decide what to do it if does exist and what to do if it does not. 

There are examples here

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

 

Marsha_R_0-1692900625211.png

 

cancel
Showing results for 
Search instead for 
Did you mean: