Forum Discussion

conehead's avatar
conehead
Occasional Contributor
7 years ago

Compare displayed screen value against select cnt(*)...

I have a count on an app screen that I'd like to edit. This should always be equal to a number of select rows in an Oracle table. I know how to Set Variable Value to what's on screen, but don't understand how I would retrieve:

 

select count(*) as my_count

from table

where status = 1

and location like '%BLAHBLAH%'

 

Do I somehow use a database checkpoint?  Is it a matter of creating another variable that will dynamically change each Test Run?

 

I'm new to this and would like to know what the best approach would be.

 

Tks.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    conehead wrote:

    I have a count on an app screen that I'd like to edit. This should always be equal to a number of select rows in an Oracle table. I know how to Set Variable Value to what's on screen, but don't understand how I would retrieve:

     

    select count(*) as my_count

    from table

    where status = 1

    and location like '%BLAHBLAH%'

     

    Do I somehow use a database checkpoint?  Is it a matter of creating another variable that will dynamically change each Test Run?

     

    I'm new to this and would like to know what the best approach would be.

     

    Tks.


    I wouldn't use a database checkpoint.  Instead, I'd make use of the ADO objects available in TestComplete, write a JavaScript function to execute an SQL query and return the results, call that function within your keyword test and then set the variable value to "last operation result" to capture and store the result for comparison.

     

    Documentation on ADO is here  https://support.smartbear.com/testcomplete/docs/reference/program-objects/ado/index.html

     

    I have an SQLUtilities script extension that encapsulates some of that for you.  Part of it isn't working properly at the moment concerning using the parameters of the ADOCommand object... but you can by pass that by formatting the SQL Query string yourself before passing it to the utility.  If you are interested, please PM me for assistance.

     

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    You can still use Set Variable Value, but use Code Expression inside it to run your database query.  Then you can compare the two variables.

  • conehead's avatar
    conehead
    Occasional Contributor

    Okay, the Mode: Code Expression requires a Value:.   Am I suppose to execute my SQL Select using JavaScript?  I would think there must be somewhere I have to enter custom SQL.

     

    Tks.

     

     

     

    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      That box looks small but you can put whatever code you need to in there.  Are you doing any other scripting in the project, I assume in javascript?