Absent Member.
Absent Member.
232 views

TC 12.53 JavaScript syntax debugging outside of TC/LR

I am not sure how often this will be helpful, but I ran into one situation already: debugging and correcting a malformed string. Many (perhaps all) of the syntax errors you code in TC will result in line #X being called out as the offending problem, but not the first character that starts the syntax error. When that occurs, if it is possible to evaluate the string outside the context of your TC script, you can try using the Windows Scripting Host support for JavaScript on any recent Windows desktop.

You create and edit a file with the .js extension, and then to run that script simply double click it. Unfortuately the object names differ from the TC environment but this set of 4 lines of a WSH JavaScript should give you a decent starting point to hack a quick script to work with (at least) string syntax problems:

ws = WScript.CreateObject('WScript.Shell');
buttonCaption = " Generate ";


ws.Popup("//button[text()='" + buttonCaption + "']");

ws.Popup("//button[text()=\"" + buttonCaption + "\"]");

Now if either of the above strings used with the Popup method (that generates a Window's Alert popup) you will get an error message identifying the first char where the syntax is supposed to be bad.

 

-Hope this helps, Terry Horwath

1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Thanks for sharing it Terry.

We will consider adding this tip in TruClient documentation.

Regards,

Shlomi

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.