Highlighted
Frequent Contributor.
Frequent Contributor.
1801 views

Using parameters in descriptors or javascript in list boxes

I am learning how to use descriptors.  With descriptors I can randomly get values from a list box, or i can pick a specific ordinal.  But i want to use a parameter in the Desciptor editor.  I put text equals pPassengers (where the pPassengers is a parameter).  I also tried with ArgsContext.pPassengers but the object is not found. It seems like it can't interpret the parameter.  The pPassengers parameter exists and it is just a number 6.

I also tried with xpath.  The xpath cmd is //li[text()="6"]  so I just want to put a pPassengers in place of the 6.

I also tried with javascript.  The cmd was //evalXPath("//li[text()=\"6\"]");

I tried to change it to  evalXPath("//li[text()='" + ArgsContext.pPassengers + "']");

 

 

0 Likes
3 Replies
Highlighted
Super Contributor.
Super Contributor.

Hi Judy,

Are you talking about "TruClient" protocol? If so, you definitely can invoke the Parameters or any other javascript variables  in Descriptor or other text editors.

For your instance,  in Descriptor dialog,  you need to first set the text mode to "JS", and then call it by "ArgsContext.TC.getParam("xxx");"param.png

 

 Regards,

Penn

 

 

 

 

 

 

Highlighted
Frequent Contributor.
Frequent Contributor.

Yes i am in TruClient and that worked for descriptors.  Can you tell me the correct syntax for Xpath?

I see this code: //li[text()="3"]

I tried different versions of //li[text()='ArgsContext.TC.getParam(“pPassengers”)']

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

If the ID method is set with "Xpath", then the only way is to write full text xpath expression, it's not possible to embed Javascript api into it.

So use ID methond "Javascript" and call xpath using evalXPath( ), and use your javascript API as a JS variable.

For your instance, something like below, you may need to adjust it as needed.

    evalXPath("//li[text()=' " +ArgsContext.TC.getParam("myParam")+ " ']");

 

And here is a doc may help you understand more:

http://tchelp.saas.hpe.com/en/12.53/Content/TruClient/procedures/_tc_examples_iterate_over_a_web_page.htm

 

if this solved you issue, please kindly mark the thread as solved.

Thanks,

Penn

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.