Highlighted
Captain
Captain
2402 views

LR TruClient - Unable to get evalXPath to work correctly

Jump to solution

Not sure if the below is a bug or something I’m doing incorrectly, I have a number of elements that need to utilize similar logic, so any / all assistance would be much appreciated!

Here is the exact error I’m getting, along with the code I’m using.

 This code works in Selenium, so not quite sure what’s going on with TruClient.

Link to sample page (may take a while to load - known issue)

UPDATE: Using LR 12.55 and the code is in a Function Library element if that helps

 

Code

//Define Objects
var imagePickerArray;
var imageSelectedArray;


//Search for existence of Image Picker Object
imagePickerArray = evalXPath("//IMG[@class='gwt-image-picker-option-image']");
  
//Search for Selected Image Object
imageSelectedArray = evalXPath("//IMG[@class='gwt-image-picker-option-image-selected']");
   
//If image pickers exist AND no image is currently selected, select the first image picker object
if ((imagePickerArray.length > 0) && (imageSelectedArray.length == 0)) {
  imagePickerArray[1].click();
  }

 

Error Message and Element Identification Information

TruClkient Error Message.pngelement id.png

Element Identification Information

0 Likes
1 Solution

Accepted Solutions
Highlighted
Admiral
Admiral

Hi again,

Sorry if I wasn't clear.

The evalXPath function can only be used in the Javascript object identification method, as part of the object identification code in the "Object" section of a step.

See the image below:

2017-12-11 18_32_53-TruClient Lite - Untitled.png

Edo

View solution in original post

0 Likes
5 Replies
Admiral
Admiral

Hi, kjackey,

The evalXPath function is only available in the scope of Javascript object identification method.

It is not defined in an "Evaluate JavaScript" code step, so it cannot function there.

If you are trying to perform an operation on an object, I'd suggest using an "Evaluate JS on Object" or a "Generic Object Action" step.

 

Edo

Highlighted
Captain
Captain

Thanks for the reply! Will take a stab at this today.

Highlighted
Captain
Captain

Hmm.. no luck, the Evaluate on Object is also giving me the evalXPath is not defined error (screenshot attached)

 

12-11-2017 11-02-14 AM.png

 

Here's what I'm trying to do, maybe there's a better way [do I possibly need to break this up into multiple TruClient steps]?

1) Go to the indicated page 

2) Check to see if there is at least one image selector on the screen (as seen in picture attached to first post and identified by the

(//*[@class='gwt-image-picker-option-image'])[1]

xpath

3) If Image picker is present, determine if any of the images have been detected xpath id is 

//*[@class='gwt-image-picker-option-image-selected']

 

4) A second option (If selector is present),  would be to  determine if the Selected Color Info Text (attached screenshot, xpath is 

(//*[@class="gwt-product-option-panel-chosen-selection"])[1]

 

12-11-2017 11-09-52 AM.png 

0 Likes
Highlighted
Admiral
Admiral

Hi again,

Sorry if I wasn't clear.

The evalXPath function can only be used in the Javascript object identification method, as part of the object identification code in the "Object" section of a step.

See the image below:

2017-12-11 18_32_53-TruClient Lite - Untitled.png

Edo

View solution in original post

0 Likes
Highlighted
Captain
Captain

Ahh.. I understand now, back to the planning board.... thanks!

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.