Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Absent Member.. drenze Absent Member..
Absent Member..
5552 views

Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

I'm having an issue with TruClient under Vugen 11.52 identifying an object using JavaScript ID method and evalXPath.

 

I have a link that I need to identify and select based on a parameter - it's the name of a specific customer.

 

I assign the parameter name to a variable at the beginning of my TruClient script when I assign all my variables...

 

var custName = LR.getParam('Customer Name');

 ...and then I attempt to use it to identify and click on the object by setting ID Method to JavaScript and using the following statement:

evalXPath("//a[text()=\"" + custName + "\"]")

 ...which fails to identify the correct object on the page. However, the following evalXPath statement works just fine every time:

evalXPath("//a[text()=\"John Smith\"]");

 

When generate an alert box to show the XPath statement I'm building that's not working, it's identical to the one that is working.
 

I'd ask my 13-year-old what I'm doing wrong, but he's not handy at the moment. Help?

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. James Leatherma Absent Member..
Absent Member..

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

I think you need double quotes around your parameter.

 

var custName = LR.getParam("Customer Name");

 

0 Likes
10 Replies
Suerte13cr Absent Member.
Absent Member.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Sounds like custname did not capture a value. Maybe its placed before the value is captured.

 

Regards,

Mario M.

HP LR/PC Support

If you are customer you can try posting on our internal forums for more personalized support.

LoadRunner:
http://h30499.www3.hp.com/t5/LoadRunner-Support-Customer/bd-p/loadrunner-support-customer-forum

Performance Center:
http://h30499.www3.hp.com/t5/Performance-Center-Support/bd-p/performance-center-support-customer

How to:
http://www.youtube.com/watch?v=4ChlysWupWM

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
0 Likes
Absent Member.. drenze Absent Member..
Absent Member..

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Sorry - I didn't make myself clear. My bad.

 

I'm specifying the value of the 'Customer Name' parameter in the script parameters - it's not being captured. I also threw a window.alert(custName) into the script prior before executing that evalXPath statement to validate that the custName wasn't blank (and also did window.alert(xpath) for that matter to validate that I'd built it correctly).

0 Likes
Absent Member.. James Leatherma Absent Member..
Absent Member..

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

I think you need double quotes around your parameter.

 

var custName = LR.getParam("Customer Name");

 

0 Likes
Absent Member.. drenze Absent Member..
Absent Member..

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

I should have come back and marked this resolved, since I just found my own question again on a search. From the evalXPath context, it is necessary to use `ArgsContext` to reference global variables in the script. I.e.:

 

evalXPath("//a[text()=\"" + ArgsContext.custName + "\"]")

will yield the desired results.

0 Likes
Pchahar Absent Member.
Absent Member.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

drenze

 

I applied the changes suggested by you, however i am getting the error saying. there are so many sich object and loadrunner is not able to identify the object uniquikly. 

 

Waiting for your reply.

Thanks in advance.

 

 

Tags (1)
0 Likes
vivek5 Respected Contributor.
Respected Contributor.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Hi all,

Can anyone please explain me the format of the below code. Why we are using " before + sign and "\"after + sign.

This code is working fine for me but i want to know the format for this.

evalXPath("//a[text()=\"XYZ"+ArgsContext.z+"\"]")

Thanks,

Vivek

0 Likes
Edo Nir Outstanding Contributor.
Outstanding Contributor.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

In the example below, green text is JS code, while the red text sections are strings (in this case, an XPath expression).

The blue + signs are concatenating the JS value into the string parameter. 

 

evalXPath("//a[text()=\"XYZ"+ArgsContext.z+"\"]")

Note that the back-slashes are escaping characters.

 

Read more about it here: https://www.w3schools.com/js/js_strings.asp

vivek5 Respected Contributor.
Respected Contributor.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Hi Edo,

Thanks for the Reply.

I have still few doubts can you please calrify it.

Why we dont have backslash(\) after the text XYZ and after the 2nd blue+ sign??

Thanks,

Vivek

0 Likes
Edo Nir Outstanding Contributor.
Outstanding Contributor.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Hi Vivek,

I strongly suggest to learn about string manipulation in JS and specifically the topic of escaping in the link I sent above.

 

Edo 

0 Likes
Highlighted
vivek5 Respected Contributor.
Respected Contributor.

Re: Vugen 11.52 Firefox TruClient: evalXPath issue

Jump to solution

Hi Edo.

Many thanks for the reply.

I will go through the link.

~Vivek

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.