Forum Discussion

DainiusA's avatar
DainiusA
Contributor
4 years ago

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.

 

 

 

  • 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

    }

    ...

     

  • 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.

    • DainiusA's avatar
      DainiusA
      Contributor

      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

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        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

        }

        ...