cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh child objects during test run (in desktop testing)?

SOLVED
Zsoka
New Contributor

How to refresh child objects during test run (in desktop testing)?

There is a desktop window, which has more tabs, and some tabs include a text editor. I wrote a test which checks the functions of the text editor in the following way:

lprops := ['FullName','WndClass'];
lvals := ['*Toolbar', 'TWPToolPanel'];
ltarget := Aliases.(Application Name).Find(lprops,lvals,20,true);
ltarget.button.Click;

I chose this way, because more elements in the object tree are cached and their mapping name is always changing. It properly works on any single tab of the window. Although, when I try to run the editor check more times in one test, the test fails after changing tab, because it searches the button on the previous tab. I tried Refresh and RefreshMappingInfo methods on the common parent object of the tabs, but they doesn't help. (The names and number of tabs can change in the window depending on the conditions.)

Is there any way to clear cached mapping tree during test run?

Thank you in advance for any suggestion!

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: How to refresh child objects during test run (in desktop testing)?

Hi,

 

Are tabs that are not active and their controls disposed of or continue to exist?

If they continue to exist then nothing in your code prevents TestComplete from finding a control on the inactive tab.

Possible solution:

a) Change object addressing to search not from application, but from the tab root. E.g. 

ltarget := Aliases.(Application Name).tab1.Find(lprops,lvals,20,true);

b) Add some other criterion (e.g. VisibleOnScreen) to the search conditions to prevent TestComplete from matching invisible controls.

 

Does this help?

 

 

Regards,
  /Alex [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
================================

View solution in original post

5 REPLIES 5
Marsha_R
Community Hero

Re: How to refresh child objects during test run (in desktop testing)?

Are you changing focus to the new tab before you try testing on it, and are you using the properties in Find that will let you tell the tabs apart?

Zsoka
New Contributor

Re: How to refresh child objects during test run (in desktop testing)?

Let me show you the simplified structure of the code:

 

The editor buttons have the following mapping on the first tab:

Window.PageControl.Tab1.Editor.Panel.Button1

Window.PageControl.Tab1.Editor.Panel.Button2 and so on.

The editor buttons have the following mapping on the second tab:

Window.PageControl.Tab2.Editor.Panel.Button1

Window.PageControl.Tab2.Editor.Panel.Button2 and so on.

(Sometimes the Editor and other objects between Panel and Buttons are cached and their mapping is not stable.)

 

The test looks like:

Window.PageControl.TabIndex := 1;

editor_test;

Window.PageControl.TabIndex := 2;

editor_test;

 

The editor_test looks like:

Window.PageControl.Refresh;

lprops := ['FullName','WndClass'];
lvals := ['*Panel', 'TWPToolPanel'];
ltarget := Aliases.(application name).Find(lprops,lvals,20,true);

ltarget.Button1.Click;

ltarget.Button2.Click; (and so on)

 

Is there any mistake in the concept? Or is there any additional thing which can help refreshing?

Zsoka
New Contributor

Re: How to refresh child objects during test run (in desktop testing)?

Sorry, I have to correct myself, the Editor and other objects between Editor and Panel are cached and their mapping is not stable.

AlexKaras
Community Hero

Re: How to refresh child objects during test run (in desktop testing)?

Hi,

 

Are tabs that are not active and their controls disposed of or continue to exist?

If they continue to exist then nothing in your code prevents TestComplete from finding a control on the inactive tab.

Possible solution:

a) Change object addressing to search not from application, but from the tab root. E.g. 

ltarget := Aliases.(Application Name).tab1.Find(lprops,lvals,20,true);

b) Add some other criterion (e.g. VisibleOnScreen) to the search conditions to prevent TestComplete from matching invisible controls.

 

Does this help?

 

 

Regards,
  /Alex [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
================================

View solution in original post

Zsoka
New Contributor

Re: How to refresh child objects during test run (in desktop testing)?

Since the original purpose was to create an editor test which is independent from the mapping route of the editor, I chose the second suggestion to try out.

 

It worked, so many thanks for your help! 😊

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