Highlighted
Absent Member.
Absent Member.
13018 views

[Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi,

 

I am using LR 11.52. I am having some trouble trying to parameterize an Object request. I want to select a gridcell object based on the content it contains. i.e. I have a grid filled with names, I want to randomly select a corresponding name from a parameter list I created, and have Truclient click on it. My problem is, I can't get the request to work.

 

Right now, I'm simply storing a value from my parameter list in a variable using Evaluate JS:

window.myGlobalVar=LR.getParam('myParam');

 Then, when I get to the step where I click on my gridcell, I use JavaScript to replace the text in the Object section, like so:

evalXPath("//td[text()=\""+window.myGlobalRep+"\"]");

 When I do this however, I get an error stating "target object was not found." I have checked to make sure that my parameter list is working correctly, window.myGlobalVar definitely is assigned a value. I'm guessing my request syntax is incorrect, but I have checked a few times already, and I don't see an issue.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi,

 

The issue with your function could be that it contains a character, written using keyboard language different from English. I made some checks in Notepad++ using different encoding and with one got:

 

evalXPath("//td[text()=\""+ArgsContext.LR.getParam​("myParam")+"\"]");

 

For example the following code

 

var myGlobalVar=LR.getParam(“myParam")

 

will also produce

 

Evaluate JavaScript code var myGlobalVar=LR.getPa...t(myGlobalVar); ** failed - exception occurred: SyntaxError: illegal character

 

because in (myParam")   is not written using English keyboard.

 

Kind regards,
Vesela

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.

View solution in original post

8 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi,

 

I have tried the same to you and also got the same error.

So I tried other way. I didn't use Evaluate JS and in the step where I click on the gridcell, I use:

 

evalXPath("//a[text()=\""+ArgsContext.LR.getParam("test")+"\"]");

 

It works for me.

I refered from this link: http://support.openview.hp.com/selfsolve/document/KM1110051

 

Regards,

Chau Nguyen

Regards,

Chau Nguyen | SW Technical Support Consultant.
LoadRunner and Performance Center


If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Okay, so I modified my code to use ArgsContext, but now I'm running into another problem. Whenever I try to use ArgsContext to obtain a value from my parameter list, I get an error stating, "SyntaxError: Invalid character    [MsgId: MERR-203252]." I tried loading the variable directly using a windows alert as well, and it seems like I must be receiving some sort of garbage character? There doesn't appear to be any problems with my parameter list file, but I'll attach it just in case. (Saved as .txt since I can't upload .dat)

 

EDIT: I felt I should note, my column delimiter is tab, not comma. It's a single column file.

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi,

 

Could you please share your code?

 

Thank you!

 

Regards,

Chau Nguyen

Regards,

Chau Nguyen | SW Technical Support Consultant.
LoadRunner and Performance Center


If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Here's the modified object js request:

evalXPath("//td[text()=\""+ArgsContext.LR.getParam("myParam")+"\"]");

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi,

 

The issue with your function could be that it contains a character, written using keyboard language different from English. I made some checks in Notepad++ using different encoding and with one got:

 

evalXPath("//td[text()=\""+ArgsContext.LR.getParam​("myParam")+"\"]");

 

For example the following code

 

var myGlobalVar=LR.getParam(“myParam")

 

will also produce

 

Evaluate JavaScript code var myGlobalVar=LR.getPa...t(myGlobalVar); ** failed - exception occurred: SyntaxError: illegal character

 

because in (myParam")   is not written using English keyboard.

 

Kind regards,
Vesela

HPE Support
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.

View solution in original post

Highlighted
Established Member..
Established Member..

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi Vesela,

I am trying parameterize a checkbox value in object section by changing the ID method to JavaScript option.

Below is the original JavaScript:

evalXPath("//input[@type=\"checkbox\" and @value=\"199999\"]");

Below is the parameterized JS option:

evalXPath("//input[@type=\"checkbox\" and @value=\'" + ArgsContext.LR.getParam("p_SellerID") + "\']");

where p_SellerID =199999

My question here:

1) Is it the correct way to parameterize? I am facing an issue which says "Target Object not found. Exception occured in JavaScript code"

Please note here that once the parameter was created the script was ran from the beginning as required. Also the similar method is being used to parameterize a different object with the same code and it works fine there. So confusing as to why it fails in this step.

2) There are 10 unique seller id's in the parameter p_SellerID and the selection of next row value is set to sequential and each occurence. Since we are selecting 10 unique seller id check boxes I am using the above mentioned value selection but in real time interactive window it doesn't selects the checkboxes in sequential manner and rather it selects in random manner. Can you provide an insight as to why its happening like this?

 

Thanks,

Bibhu Panda.

 

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

Hi Bibhu,

Can you try this statement instead 

evalXPath("//input[@type=\"checkbox\" and @value='\'" + ArgsContext.LR.getParam("p_SellerID") + "\']");

Or alternatively try Descriptors object identification. It will help avoiding the syntax issues

Regards,

Shlomi

0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: [Truclient] How to parameterize an Object Name/Path?

Jump to solution

HI Shlomi

I tried to apply this to my problem. I am testing an Angular application. I search for a customer based on zipcode and housenumber. The application wil give all possible customers in that area, and I want to click on the Business Partner number (our internal identifier).

So the xpath is

//span[text()="12345678"]

where 12345678 is the customer number. 

I do a 'Click on' action, and in the Object I select ID method - Javascript, and in the Javascript box 

evalXPath("//span[text()=\"   "+ ArgsContext.LR.getParam("var_ZP") + "     \"]");

Where var_ZP is the variable for the customer number.(variabe has been created in the main script and has tesdata).

But when I play it, it just gives an error that the object did not appear! I can't see my error here, please advise? I did try constuctions like 

evalXPath(“//a[text()=\”” + window.mydoc + “\”]”);

where windows.mydoc contains the customer numer, that also did not work.

 

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.