Forum Discussion

sid's avatar
sid
Occasional Contributor
8 years ago

How to update 'USEUNIT name at run time

I am reading unit name from excel and passing them to tempVar and using Execute command , I am execute TestCase.

But I am not able to update 'USEUNIT name at run time ? how to do that plz help.,. 

I don't want to declare 'n'n number of USEUNIT

 

Example(DriverScript)

 

'USEUNIT Unit1   '# want to read from excel or how to assign unit name at run time?

'USEUNIT Unit2

'USEUNIT Unit3

.....

...

...

'USEUNIT UnitN


Sub Main

 

         unitName =  "Unit2"  '# reading from excel

 

         methodName = "Test" '# reading from excel

 

         Execute unitName &"."&methodName

 

End Sub

4 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    As per my understanding, What you are trying achieve here is all functions needs to executed from excel sheet.

     

    hence, you want to map the Unit thru script.

     

    If my understanding correct, Then there is no way to do that.

     

    But you can do below things in-order to get it worked,

    1. Create a common unit where you will using the Excel sheet functions to call the functions.

    2. And a all UNIT names that referenced in all functions which are going to execute.

    3.Then use below code as you already did.

     

     Execute unitName &"."&methodName

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      A slightly more complicated way of doing things is turn each of your code units into a script extension runtime object.  You can then use aqObject.CallMethod to execute your code like so:

       

       

      aqObject.CallMethod(unitname, methodname)
      • shankar_r's avatar
        shankar_r
        Community Hero

        My recommendation is , You should USEUNIT in your scripts so you can avoid unwanted errors and make it trust-able scripts