Highlighted
Absent Member.
Absent Member.
539 views

TC 12.53 JavaScript editor syntax

Jump to solution

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?

 

t.jpg

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 + \" ?

t.jpg

-Thanks, Terry Horwath

1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: TC 12.53 JavaScript editor syntax

Jump to solution

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 + "']");

Regards,

Shlomi

View solution in original post

3 Replies
Highlighted
Absent Member.
Absent Member.

Re: TC 12.53 JavaScript editor syntax

Jump to solution

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

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: TC 12.53 JavaScript editor syntax

Jump to solution

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 + "']");

Regards,

Shlomi

View solution in original post

Highlighted
Absent Member.
Absent Member.

Re: TC 12.53 JavaScript editor syntax

Jump to solution

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... 🙂

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.