Forum Discussion

DarkShadows's avatar
DarkShadows
Contributor
6 years ago

TestComplete_Webapplication_DDTDriver_How to read and use the xpath value.

Hello Team,

 

Really appreciate if someone guides me on how to read XPath value available in excel file and use it in the script.

Currently, I'm locating object through using its path and all this XPath maintained in excel sheet.

So how can I read and use them in my scripts?

I have created the following scripts however it's not working due to the invalid syntax of the XPath expression error.

 

Browsers.Item(btBrowser).Navigate(Excel.Cells.Item(3,5));
let page = Sys.Browser("*").Page("*");
LoginPage = Aliases.browser.Login.form ;
let username = page.FindChildByXPath(Excel.Cells.Item(4,4), true); //[Reading Xpath value from excel]
let password = page.FindChildByXPath(Excel.Cells.Item(4,5), true);//[Reading Xpath value from excel]
let loginbutton = page.FindChildByXPath(Excel.Cells.Item(4,6), true);//[Reading Xpath value from excel]
if (!strictEqual(page, null))
{
username.SetText(Excel.Cells.Item(5,5));
password.SetText(Excel.Cells.Item(6,5));
loginbutton.ClickButton();
}
else
{
Log.Error("Unable to find the requested element!! ");
}

Error after running above scripts

JavaScript runtime error. Invalid syntax of the XPath expression: Excel.Cells.Item(4,4) Check the expression syntax and correct it, if needed. Pay attention to missing parentheses, brackets and quotes Error location: Unit: The invalid syntax of the XPath expression: