用来存储Excel文件数据variables的variables是否被破坏? JavaScript的

我目前正在使用JavaScript / TestComplete开发一个关键字驱动的框架,并有一个Excel文件,其中包含一个步骤编号,描述,关键字,定位器和数据。

我目前正在从Excel文件(.xlsx)中读取数据并将数据(在本例中为定位符)存储在一个variables中。

我存储stringBrowsers.Item(btlExplorer,“”,Browsers.pX64在一个名为locator的variables。当我然后尝试这个:locator.Run( https://www.google.ie/?gws_rd=ssl#spf= 1 );我收到此错误:JavaScript运行时错误TypeError。getLocator(…)。运行不是一个函数。

这是我的getLocator函数:

function getLocator(x){ var driver; var value; driver = DDT.ExcelDriver("C:\\Users\\Username\\Desktop\\Automation Framework.xlsx", "Sheet1", false); while (! driver.EOF() && driver.Value(0) != x){ DDT.CurrentDriver.Next(); } value = driver.Value(3); Log.Message(value); DDT.CloseDriver(driver.Name); return value; } 

这里是我正在运行的function:

 function openGoogle() { //Launches the specified browser and opens the specified URL in it. getLocator(1).Run("https://www.google.ie/?gws_rd=ssl#spf=1"); } 

我是JavaScript新手,如果你能给我任何提示/build议什么是错误的,将不胜感激。

由于getLocator函数返回的值是一个string,因此可以将其作为string使用,并且没有Run方法。

为了用Run方法得到实际的对象,你需要用这种方式来计算string:

 function openGoogle() { //Launches the specified browser and opens the specified URL in it. let brwsr = eval(getLocator(1)); brwsr.Run("https://www.google.ie/?gws_rd=ssl#spf=1"); }