So I have a function that looks like this, and ultimately I'm trying to store the button's location information in a different tab inside the same script as the tab the function is in. So for instance in one tab, let's call it GeneralTab, I have all my operations I want to do declared. This is what it looks like.
function MyFunction
{
ThePage.Button.click();
}
Pretty simple so far. What I am trying to do is store its location in a different tab within the script. Let's call this tab LocationTab. LocationTab looks like this:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
Here is what is intresting, when I run MyFunction inside of the same tab this works fine. That would look like the following:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
function MyFunction
{
ThePage.Button.click();
}
But if I try to have them be two different tabs in the same script, I get an error when I try and run MyFunction()
. It says
"ThePage is undefined".
What is going on here.
You need to add
//USEUNIT LocationTab
at the top of your GeneralTab script. Check the docs for details: Calling Routines and Variables Declared in Another Unit.