Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago
Solved

CAll objects declared in another unit function

Hello,

I know, In Test Complete there no need to create objectRepository we can use Name Mapping in place of object repository.

but i have to create ObjectRepository, How can i call my objects

Like:

Unit A

Function AllObjects()

 Set abc = ........Something here.......

 Set bcd = ........Something here.......

 Set cde = ........Something here.......

End Function

 

'USEUNIT A

Sub TestCase()

 'here what should i do so that I can get objects

as i am trying A.Allobjects.      

but after Allobjects proposals does'nt show objects in the function

how can i call the objects declared in another unit, function.

End Sub

9 Replies

  • Wamboo's avatar
    Wamboo
    Community Hero

    Hi,


    There's no need to call it something like A.Allobjects.


    If you use the NameMapping repository and (as we see in the code) you store references to NameMapping objects in variables.


    You already have a reference, so you have to call AllObjects -> check the result and use the returned value in the code.

    • kaiiii's avatar
      kaiiii
      Regular Contributor

      Hi Wamboo ,

      Thanks for reply

      but I did'nt get your point. can you please eleborate.

       

      • Wamboo's avatar
        Wamboo
        Community Hero

        I think You are using VB.


        I am using JavaScript but the example will be simple and i think you can understand it.


        example:

         

        Unit A

        Function AllObjects()

        Set abc = ........Something here.......

        Set bcd = ........Something here.......

        Set cde = ........Something here.......

        End Function

         

        Here you try to save values (NameMapping repository values in variables). Return these values from the function and use it in the routine you want. In JS this is something like that.

         

        function storeValues() {
          let variable = Aliases.obj.obj;
          return variable;
        }

        to be honest You can always store single NameMapping value inside variable without declaring function above it.

         

        example:

         

        var mainMenuButton = Aliases.obj.obj2;

         

        or declare a function inside the variable:

         

        var mainMenuButton = function() { 
          return alias.Find(propNames, propValues, depth, refresh);
        }

         

        ofc, instead of Alias.obj you can always use Sys.

         

        Is that helpful? Is that what you meant?