Forum Discussion

csnider's avatar
csnider
Occasional Contributor
7 years ago

Pointing to scripts from keyword tests, then using dataloops

I'm fairly new to test automation.  I've been able to build successful keyword tests with data driven loops.

 

I'm being asked about breaking out each line in the keyword tests into scripts.  Basically, a small script to interact with each control in the app under test (settext, clickbutton, etc...)  I simply did the "convert to script" function in Test Complete for one control (Priority) and below you see the results.

 

Note how it's referencing a specific DB table variable (excel spreadsheet) that I setup in the keyword test (in the dataloop).  Scroll all of the way to the right.

 

function set_overviewPriorityText()
{
  Aliases.BetaGlobalDataEntry.GlobalDataEntryMainForm.radDock1.radSplitContainer3.documentContainer1.documentTabStrip1.twDocumentEntry.pnlOverview.radSplitContainer2.pnlDocumentEntry.tabMainForm.CassTabPage.Overview.txtPriority.txtPriority.wText = KeywordTests.junk.Variables.oceanPositive("txtPriority");
}

 

I'm hoping to have small scripts like that above for all controls in the app under test, then pull those smaller scripts into a main keyword test using the "Run Script Routine" feature.  This helps maintain the "Priority" control script in a single place.  If the control name changes, I update the name in one place (as an example.)

 

In a keyword test, I want to be able to specify the spreadsheet to use for that keyword test.  Then I pull those smaller scripts into it and it know to use the spreadsheet I just defined.

 

I'm having a hard time explaining this and I'm not even sure this makes sense.  Please feel free to ask questions or point out how my question is dumb.  :)  he he

 

Chris

  • Thanks for the reply, Marsha.

     

    I ended up doing this using the keyword functionality and it works well.  Small individual keyword tests for app controls that are being tested, parameters inside those small tests, and a datasheet as a variable in the big keyword test (that's made up of all the small tests.)

     

    Works well!  Finally!  :)


    Chris

  • csnider's avatar
    csnider
    Occasional Contributor

    Here is a suggested solution:

     

    We suggest you create a function and parameterize the file that is being called

     

    function main(){
    sub("c:\\myfile")  
    }
    function sub(file_path){
    }

     

     

    I pasted the above directly into a script file.  Now when I "insert" the "sub" script routine in a keyword test, I'm prompted for the value.  See the attached Word doc with screenshots of how I set it up.

     

    I'm not sure what to do from here.  How will the remaining script routines that I pull over into the main keyword test know to use the file I pointed to?  I'll need to specify the columns for each control to use.

     

    Very familiar with doing a dataloop in a keyword test, but not this way.

     

    Can I please get some hand holding from you gurus?  :)

    • Marsha_R's avatar
      Marsha_R
      Moderator

      You can use a function if you want it to prompt you all the time but if you want to set the path once and change it occasionally, then put the path into a project variable of type string and use that variable in your other functions. 

       

      In the case of your example you could call the variable FilePath and its value would be c:\\myfile

       

       

       

  • csnider's avatar
    csnider
    Occasional Contributor

    Thanks for the reply, Marsha.

     

    I ended up doing this using the keyword functionality and it works well.  Small individual keyword tests for app controls that are being tested, parameters inside those small tests, and a datasheet as a variable in the big keyword test (that's made up of all the small tests.)

     

    Works well!  Finally!  :)


    Chris