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.. shivp Absent Member..
Absent Member..
3103 views

How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hello HPE Experts,

I'm having an object on a web page for which 'visible text' property keep changing on every iteration with known value as pre stored in a .dat file.

(Data file - Opportunity.dat ;; Field Name: Opportunity)

For this, I'm trying to call a parameter value from prestored parameter table to the TruClient object having ID Method JavaScript.

The javascript has been written as below:

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

But object is not getting idenetified.

 

Please help me out in resolving the issue. And welcoming other approaches as well.

Thanks in advance.

Shiv

0 Likes
7 Replies
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hello,

You should stop relying on that predefined value stored in the parameter data file. Instead I recommend switching the object identification to Descriptors and try to modify the properties not to rely on the object text.

Check this webinar: https://www.youtube.com/watch?v=PStYMuphfqE around the 35th minute for an example of something similar, not identical though. By the way, I recommend watching the whole webinar and other ones in the series.

Regards,

Shlomi

 

 

Absent Member.. shivp Absent Member..
Absent Member..

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hi Shlomi,

Thanks for your prompt reply along with providing the link.

In my scenario, the available properies for a link text are very limited.

Let me explain the scenario with an example:

While creating a new request, the request name "Request_001" has been passed from a predefined .dat file. Once the request get generated, it get displayed as a link text "Request_001" on the list pane, where other requests also available but with different names (say: Request_002, Request_003 and so on...).

Now I want to click on the newly created request link (say: "Request_001") in the scenario flow. Here the visible text already stored in the .dat file, so we can use it as a parameter in Object-JavaScript.

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

Actually I'm using the same link at multiple places in a single scenario flow, that why paramterized approach looks easy to me.

As I'm getting the issue in the above script, please suggest, where I'm doing wrong while calling the parameter in the above script approach.

Thanks in advance.

Shiv

0 Likes
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hi Shiv,

It looks like you are doing it right then. Maybe the value returned from the parameter is not the correct value?

Maybe you should save the value from the parameter to a variable in the script and change the xpath evaluation to use that variable.

Regards,

Shlomi

0 Likes
Absent Member.. shivp Absent Member..
Absent Member..

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hello Shlomi,

The script has been written in Evaluate JavaScript Code is as below

var abc = TC.getParam("Opportunity");

 

I'm trying to do in a similar way, as to store the parameter value in a variable. But while running the step individually for verification of the step, getting below error:

** 66: Evaluate JavaScript code var abc = TC.getParam("Opportunity"); ** failed - exception occurred: API_ERROR_INVALID_ARGUMENTS_RUNTIME: TC.getParam("Opportunity") APIError: Can not be used in "Play this step only" mode

 

There might be some tips which is unknown to me, Please see if you can help in resolving this issue.

Thanks

Shiv

 

 

 

0 Likes
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

TC.getParam requires running the whole script. It does not work when playing a single step since the data is fetched from a different process which is being invoked only when running the whole script.

I suggest watching TruClient Webinars on YouTube. There are a lot of handy tips, the above one was covered there as well.

Regards,

Shlomi

0 Likes
Highlighted
vivek5 Respected Contributor.
Respected Contributor.

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Hello all,

I have similar kind of issue.

For my case link to be clicked is - kumar123, vivek

123 is coming from parameter file and will change everytime.

I have passed parameter value to a variable x. It is working fine till here.

But when i am trying to click on the link using below xpath it is not able to identify it -

evalXPath("//a[text()='kumar"+ArgsContext.x+", vivek']");

Is my format correct?

Please help me with this.

0 Likes
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: How to call parameter in XPath/JavaScript of an object in TruClient VuGen Script

Your syntax seems OK. How did you define x? Did you replay the step in which x is being initialized before trying to higlight the object?

Shlomi

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.