Ask a Question

Press numbers on a Windows form app from SQL query

SOLVED
DainiusA
Contributor

Press numbers on a Windows form app from SQL query

Hello everyone,

 

Not sure how to explain as simple as possible. So I have this kind of Windows form app buttons. and I have an SQL query which returns me some kind of numbers. Is it possible somehow to press these buttons depending on SQL query result. For example the SQL query returns number 56, then TestComplete needs to push number 5 then 6 and then button OK. Or SQL query returns number 186, then TestComplete needs to push number 1, then number 8, then number 6 and finally button OK.

DainiusA_0-1617800749033.png

 

 

 

3 REPLIES 3
ebarbera
Staff

Hello - 

 

Yes, this is possible. First you would store the SQL query into a variable - then you may have to split it into separate integers and store them into variables. Then create a generic object in the NameMapping that uses the variable as one of the properties to identify the button it its clicking on.

Ok I am quite new to this.

I have made a variable for SQL query that fetches the numbers I need.

And I have mapped all of the Windows form buttons separately in the NameMapping editor.

 

Now comes for me the difficult part for me - "then you may have to split it into separate integers and store them into variables"

 

Could you explain me a little bit more simplified this part ?

 

Best regards,

Dainius

HI Dainius,

 

Actual implementation depends on the data returned from the query and how you NameMapped buttons.

Assuming that:

-- Query returned string value; and

-- Buttons are NameMapped as Button1, Button2, ...

 

below is a sample untested pseudo-code:

var strQueryValue = <valueFromQuery>; // e.g. '12345'

for (var i = 0; i < strQueryValue.length; i++)

{

  eval('Button' + strQueryValue.charAt(i)).Click(); // this will click Button1, Button2, ...

  aqUtils.Delay(500); // short safety delay

}

...

 

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
================================
cancel
Showing results for 
Search instead for 
Did you mean: