

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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?
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I think you need double quotes around your parameter.
var custName = LR.getParam("Customer Name");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Sounds like custname did not capture a value. Maybe its placed before the value is captured.
Regards,
Mario M.
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.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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).


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I think you need double quotes around your parameter.
var custName = LR.getParam("Customer Name");


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi 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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Edo.
Many thanks for the reply.
I will go through the link.
~Vivek