Forum Discussion

DarylMM's avatar
DarylMM
Occasional Contributor
7 years ago
Solved

Variable used to store data from Excel file broken?

I am currently developing a Keyword driven framework using JavaScript / TestComplete and have an Excel file which contains a step number, Description, Keyword, Locator and Data.

 

I am currently reading the data from the Excel file (.xlsx) and storing the data (in this case the locator) in a variable..

I am storing the String Browsers.Item(btlExplorer,"",Browsers.pX64 in a variable called locator. When I then attempt this: locator.Run(https://www.google.ie/?gws_rd=ssl#spf=1); I receive this error: JavaScript runtime error. TypeError. getLocator(...).Run is not a function.

 

This is my getLocator function:

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;
}

And here is the function I am running:

 

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");
}

 

I am new to JavaScript, if you could give me any tips / advice on what is going wrong it would be greatly appreciated.

  • if you are having return value as Browsers.Item(btlExplorer,"",Browsers.pX64) then you need to eval this object in-order to use .Run() method.

     

    Like below,

     

    value = eval(driver.Value(3));

     

1 Reply

  • shankar_r's avatar
    shankar_r
    Community Hero

    if you are having return value as Browsers.Item(btlExplorer,"",Browsers.pX64) then you need to eval this object in-order to use .Run() method.

     

    Like below,

     

    value = eval(driver.Value(3));