Forum Discussion

QAConsultant's avatar
QAConsultant
Contributor
14 years ago

Data value checkpoint

Hello,



I'm attempting to create a checkpoint for a dynamic system generated number:

1. System generates a Case# > fill out other info in the application...

2. The Case# gets written to the database when clicking 'Save'

What I want to do is take the Case# from 1 and verify it was successfully written to the database.



How would I do this, and is this feasible?



Thanks,

Dan
  • Hi,




    1. System generates a Case# > fill out other info in the application...


    You can save the generated number to a variable (for example, GenNumber).




    2. The Case# gets written to the database when clicking 'Save'


    To access the database value, you can use a DB Table variable (for example, DBVar).




    What I want to do is take the Case# from 1 and verify it was successfully written to the database.


    Then, you can compare the value of the GenNumber variable with the value stored in the DB Table variable. For example:




    function Compare()

    {

      var GenNumber = Aliases.myApp.NumberField.wText;

      var DBValue = Project.Variables.DBVar.Value("GeneratedNumberColumn");

      if (GenNumber = DBValue)

         Log.Message("The values are identical") 

      else

         Log.Message("The values are not identical")

    }

  • Thanks, Margaret 



    One more question: Is there any way to do this in a keyword test without javascripting?



    Thanks,

    Dan
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Dan,


    Yes, you can use this approach for the keyword test. For this purpose, I'd recommend that you add the Run Code Snippet operation to your keyword test and specify the code from Margaret's post as this operation's parameter. This operation lets you run code snippets directly from a keyword test.


    An important thing: make sure that JScript is set as a language for your project.


    I hope this information helps :)


  • Y'all are awesome, this helps a lot!



    Thanks, Margaret and Irina for the very thorough assistance.



    -Dan