Forum Discussion

Kostja's avatar
Kostja
Contributor
10 years ago

Need Help with Project Variable

Hello,

 

I just started a few days ago with TestComplete 9 and made my first experiences. Now i wanted to create several scripts/units which use variables from other scripts/units. I already read the section at the support site, but my code still didn't work as expected...

 

Since I'm out of ideas I hope somebody in this board could help me ;).

 

The script as simple as can be...

 

The first script:

 

//USEUNIT OpenUp

Project.Variables.browser= Browsers.Item(btFirefox);

function FuseAll()
{
  OpenUp.OpenUp();
}

The second script

 

function OpenUp()
{
  //browser = Browsers.Item(btFirefox);
  browser.Run("http://192.168.100.23/")
}

When execute I always get the Error >> 'browser' is undefined' <<.

I also wrote the Variable in the 'Temporary Variables' and declared it as an 'Object'.

 

So, what is the problem in my process?

 

Thanks for help in advance

  • Hi, 

     

    instead of using your function name in USEUNIT you have to use your script file name (.svb file name)

     

    like //USEUNIT testScript2 

     

    Then call whatever functions are available in your testScript2 into testScript1.

  • I solved the problem with functions. Maybe Project variables are not supposed to be used like this? Still it would be nice to know if it could be done with global variables/Project variables.

    • Ravik's avatar
      Ravik
      Super Contributor

      Hi, 

       

      instead of using your function name in USEUNIT you have to use your script file name (.svb file name)

       

      like //USEUNIT testScript2 

       

      Then call whatever functions are available in your testScript2 into testScript1.