TestComplete 不同的选项卡不在同一脚本中相互访问信息
TestComplete different tabs not accessing information within each other in same script
所以我有一个看起来像这样的函数,最终我试图将按钮的位置信息存储在与函数所在的选项卡相同的脚本内的不同选项卡中。例如,在一个选项卡中,让我们称之为 GeneralTab,我已经声明了我想要做的所有操作。这是它的样子。
function MyFunction
{
ThePage.Button.click();
}
到目前为止非常简单。我想要做的是将其位置存储在脚本中的不同选项卡中。我们称此选项卡为 LocationTab。 LocationTab 看起来像这样:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
有趣的是,当我在同一个选项卡中 运行 MyFunction 时,它工作正常。看起来像下面这样:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
function MyFunction
{
ThePage.Button.click();
}
但是如果我尝试让它们成为同一脚本中的两个不同选项卡,我会在尝试 运行 MyFunction()
时收到错误消息。它说
"ThePage is undefined".
这是怎么回事。
您需要在 GeneralTab 脚本的顶部添加 //USEUNIT LocationTab
。查看文档了解详细信息:Calling Routines and Variables Declared in Another Unit.
所以我有一个看起来像这样的函数,最终我试图将按钮的位置信息存储在与函数所在的选项卡相同的脚本内的不同选项卡中。例如,在一个选项卡中,让我们称之为 GeneralTab,我已经声明了我想要做的所有操作。这是它的样子。
function MyFunction
{
ThePage.Button.click();
}
到目前为止非常简单。我想要做的是将其位置存储在脚本中的不同选项卡中。我们称此选项卡为 LocationTab。 LocationTab 看起来像这样:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
有趣的是,当我在同一个选项卡中 运行 MyFunction 时,它工作正常。看起来像下面这样:
var page = LaunchInternetExplorer(url);
function MyPage()
{
this.Button = page.SomeLocation;
}
ThePage = new MyPage();
function MyFunction
{
ThePage.Button.click();
}
但是如果我尝试让它们成为同一脚本中的两个不同选项卡,我会在尝试 运行 MyFunction()
时收到错误消息。它说
"ThePage is undefined".
这是怎么回事。
您需要在 GeneralTab 脚本的顶部添加 //USEUNIT LocationTab
。查看文档了解详细信息:Calling Routines and Variables Declared in Another Unit.