Forum Discussion

philyoung99's avatar
philyoung99
Occasional Contributor
8 years ago

Run VBscript from keyword test

Hi, 

 

I have looked everywhere and I guess this is something simple I cannot find. I have a VBscript that I am able to run by using the "Run Current routine" button that appears when I double click on my script unit.

 

I want to be able to run this from a Keyword test directly..

 

I have experimented with trying to call from a code snippet and also trying to use "Run Script routine" and receive "there is no appropriate test to choose" 

 

I have tried to add the script as a test to test items, but cannot seem to get my vbscript selectable form the list of tests. 

 

Can someone give me a quick pointer/screenshot please? I am new to vbscript as well which probably isn't helping.

 

thanks a lot

phil

 

7 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    For a project variable it is
    Project.Variables.MyVariableName

    For keyword test local it is
    KeywordTests.MyKeywordTest.Variables.MyVariableName

    It's similar for parameters. A trick I use for scripting something new is to create a keyword test that does what I want, then use Convert To Script. You find that by right-clicking the test name in the explorer. Then you have a keyword test and a script to compare.

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    See attached.  Choose Run Script Routine and pick your test from the list.

     

  • philyoung99's avatar
    philyoung99
    Occasional Contributor
    Thanks for your reply. But when I try to use run script routine, I have the message... "there is no appropriate test to choose"

    The code I am trying to run is intended to not be a test actually, but update an excel sheet with test results..(when I figure out how to reference keyword test variables from a DDL I am using from within a script). So I basically just need to be able to call this script from within the keyword test at a point of my choosing.

    Thanks
    Phil
  • philyoung99's avatar
    philyoung99
    Occasional Contributor
    In fact. I wonder if I have just left some specific code out of the vbscript that allows the script to be selectable from run code routine in test complete ?
      • philyoung99's avatar
        philyoung99
        Occasional Contributor

        You will never guess...

         

        I cracked it..

         

        I think it was simply down to some testcomplete saving weirdness..I logged on tonight to get you the script - made no changes to it and tried to add as a run script routine again and the item was selectable and I have successfully run it - no issues! :)

         

        I am also puzzling over the way to reference data driven keyword test variables from within the script.

        I am guessing the format would be something like MyProjectName.Variables.dtVar.ID 

        Meaning the ID from the data driven layer variable within the project called "my project name"?

         

        or very similar?

         

        thanks a lot

        phil