TC 12.53 JavaScript editor syntax

The following code snippets are from the Session 2 Object Identification TC Webinar  last month and am trying to reproduce the results of each presentation. I am using the just installed 12.53 Community version of LR. All of the code snippets worked in the demo and I have some questions about the syntax, which is often the most difficult problem to resolve using many of the LR protocols (well, at least for me).

1. In the following example why does the method call, evalXPath,  not have to include  TC., as in:TC.evalXpath?

2. Why is the closing bracket ] required without an associated opening bracket? What is its syntactical purpose? Does online help provide syntax rules?


3. Can the the single quote block, '" Args.Context.buttonText "' in the following example be replaced with escaped double quotes as in: \" Args.Context.buttonText \" ?

-Thanks, Terry Horwath

  • I am answering my own question #3; the alternative to using a single quote block is the 2nd variation in this code snippet:

    var buttonCaption = " Generate ";
      window.alert("//button[text()='"   buttonCaption   "']");
      evalXPath(   "//button[text()='"   buttonCaption   "']");       // works, sends ...' Generate ']
      window.alert("//button[text()=\""   buttonCaption   "\"]");
      evalXPath(   "//button[text()=\""   buttonCaption   "\"]");     // works sends ..." Generate "] 

    And I confirm that both variations work to indentify an object correctly.


    Having done this (best to play with text string syntax stuff like this using Windows Script Host to run a small JS script) I conclude that the single quote block that TC uses is more readable (but now I know how to do some string escape sequences).

    I hope someone will still address my questions 1 and 2 in this thread.

    -Hope this helps, Terry Horwath

  • Verified Answer

    Hi Terry,

    Regarding the first question, TruClient does not require TC prefix before evalXPath function

    AS for the second question, there is an opening bracket, you probably missed it :-)

    evalXPath("//button[text()='" buttonCaption "']");



  • re: evalXPath("//button[text()='" buttonCaption "']");

    doh! It was there all along, even in my examples above. Not sure why I kept missing it. Brain fart I guess... :-)