Ask a Question

Parameterizing Regions (images) under Stores in a function

SOLVED
sameerjade
Frequent Contributor

Parameterizing Regions (images) under Stores in a function

Hello,

I am trying to parameterize regions (images) under Stores but it seems to not work. I tried with these 2 methods, 'Region.Check' and 'Region.Compare'. Here is what I have tried:

 

First workflow:

function ValidateRegion1(myRegion, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
{
onscreenObj = myAppWindow;
Regions.myRegion.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);
}

Run: ValidateRegion1(myRegion1);

Result: It fails with error: "TypeError: region.Check is not a function"

 

Second workflow:

function ValidateRegion2(myRegion, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)
{
onscreenObj = myAppWindow.Picture();
Regions.Compare(myRegion, onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);
}

Run: ValidateRegion2(myRegion1);

Result: It fails with error: Cannot get a picture object from the input parameter. Although I passed the Picture method to my 'myAppWindow' object.

 

Is there a way to parameterize regions so that I can create and use a function for multiple region comparisons?

 

I found this link but here they are showing how to parameterize the 'onscreenObj' object but still hard-coding the region object. My onscreenObj object is going to be same but I have several regions to use for comparison, so I want to parameterize the region object.

https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/regions/parameterizing.html

 

Any help is appreciated. Thanks!

2 REPLIES 2
AlexKaras
Champion Level 3

Hi,

 

It is my guess that you pass string as the value of myRegion input parameter in both cases.

I.e. you call  ValidateRegion1() function like this:  ValidateRegion1('region1', ...)

If my guess is correct, then you should use eval() or evaluate() function depending on what is provided by your script language:

eval('Regions.' + myRegion + '.Check(onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam)');

and

Regions.Compare(eval(myRegion), onscreenObj, transparentParam, mouseParam, pixelTolParam, colorTolParam, maskParam);

 

Does this help?

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
sameerjade
Frequent Contributor

The eval() function works perfectly! That is exactly what I needed. Thanks!

 

Yes, you are correct that I was passing string as the value of myRegion input parameter in both cases.

 

Regards,

cancel
Showing results for 
Search instead for 
Did you mean: