Community in read only mode June 18 & 19
This community will be set in READ ONLY mode for a while on Tuesday June 18 into Wednesday June 19 while we import content and users from our Micro Focus Forums community site. MORE INFORMATION
vishansh Trusted Contributor.
Trusted Contributor.
716 views

Parameterizing using evaluate javascript

Jump to solution

Hi ,

I want to user parameters by evaluate javascript option for giving input.
I tried object.setvalue="{parametername}" and
object.value=TC.getParam("parametername"), but none of it works.
can someone help me what code should is use here.

Best Regards

Vishal

0 Likes
1 Solution

Accepted Solutions
Highlighted
Edo Nir Outstanding Contributor.
Outstanding Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

The Generic API step was added in version 12.53.

In version 12.50 you can still call the API from your JavaScript code:

var myValue=TC.getParam("ParamName");
5 Replies
Shlomi Nissim Acclaimed Contributor.
Acclaimed Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

Hi Vishal,

It is unclear what you are trying to do.
If you are trying to locate an object in the application using a value taken from a parameter and this code is going to be embedded in the Object Identification section of the step you need to use ArgsContext.TC.getParam("ParamName") concatenated to JavaScript evaluation code.

If you are trying something else please clarify in more details and attach a screenshot of the step and possibly the steps surrounding it.

Also, look at the Object Identification samples in TruClient online help. It might help as well.

Regards,
Shlomi

vishansh Trusted Contributor.
Trusted Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

HI Shlomi,

Thanks for the quick response.

I need to set different dates in a field, but truclient wasn't recording the step , neither i was able to change the action from "click" to "type" as the option "type" was not available.
I figured it out as , I used click on the object and changed the action to "evaluate javascript", 
So I used object.value="2018.10.10"
Issue : I need to pramaterize the dates or even other criteria. so how can i parameterize it using javascript from the parameters list in table form.

Please see the attachment , I wan't to parameterize the user id here using evelaluate javascript. I am not fetching the parameter values from anywhere , but i have already created the parameters in tabular form. 
Please let me know the soultion or if you have any questions.

 

Best Regards

Vishal

 

0 Likes
Edo Nir Outstanding Contributor.
Outstanding Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

You should use the TC.getParam API to extract the parameter value.

The best practice, in this case, would be to use a Generic API step to invoke this command, store the parameter value in a variable and use that value in your logic (setting the object value.

Add the Generic API step from the Toolbox manually.

See the screenshot below:

TC use param.png

Edo

0 Likes
vishansh Trusted Contributor.
Trusted Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

Thanks Edo for the solution,

Is the "Generic API step" available for LR 12.50? 

 

Best Regards

Vishal

0 Likes
Highlighted
Edo Nir Outstanding Contributor.
Outstanding Contributor.

Re: Parameterizing using evaluate javascript

Jump to solution

The Generic API step was added in version 12.53.

In version 12.50 you can still call the API from your JavaScript code:

var myValue=TC.getParam("ParamName");
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.