Keyword test not working as Script test
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keyword test not working as Script test
I have Keyword tests which compare Excel workbook values to the frontend web application using the Excel Read Value and Compare Property operations.
These Keyword tests work fine but when converting them to a script they do not and I get this error. Does anyone have any insight as to why?
Example script:
//USEUNIT HelperScripts
function FR_Rollup()
{
var Var1, LastResult, LastResult1;
Var1 = "";
changeDashboardLanguage("French");
Browsers.CurrentBrowser.Navigate(ProjectSuite.Variables.url);
Delay(500);
LastResult = Excel.Open(ProjectSuite.Path + "Dashboard_translations_COMPLETE.xlsx").SheetByTitle["fr_FR"].CellByName["C37"].Value;
Var1 = LastResult;
aqObject.CompareProperty(Aliases.browser.pageDashboard.panelAllDispatchesStatusText.contentText, 0, Var1, true, 3);
LastResult1 = Excel.Open(ProjectSuite.Path + "Dashboard_translations_COMPLETE.xlsx").SheetByTitle["fr_FR"].CellByName["C38"].Value;
Var1 = LastResult;
aqObject.CompareProperty(Aliases.browser.pageDashboard.panelUploadPendingStatusText.contentText, 0, Var1, true, 3);
}
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"of undefined" in the error message is telling you that the function was unable to get your Excel sheet so it has no reference for the CellByName call.
Did you use the Convert To Script function to get this code or did you write it separately? If you didn't use Convert To Script function, then I suggest trying that and seeing what code TestComplete gives you.
If you did use that convert function, be sure and run this script in the spot in your test where it has access to all the variables that it needs. Running it stand alone may not work.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did use convert to script. The excel path is ProjectSuite.Path + *sheet name*. I don't know why it would be accessible within the project via Keyword tests but not by Script tests.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's code written in Python that works,
You are trying to run your code in JavaScript, but your coding is actually in Python.
If you look at the code examples in Excel.Open Method, Python uses square brackets, whereas JavaScript uses round brackets. This was a bug a while back, I wonder if it has been reintroduced!?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the insight. Seems like a bug because my project is Javascript, not Python.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Replace the square brackets with round brackets in your code, and it will work.
