Highlighted
Trusted Contributor.
Trusted Contributor.
1234 views

To correlate in LR Truclient 12.55

Hi,

I want to corelate an object for the below script scenario

There are list of items, my script will search for an item by typing it in a text box, and should select a checkbox as a result of search.

Based on the "Input value" in the search text box, the result will vary.

I need to correlate the result , so my script will select the appropriate item as a result of search.

Currenlty it is selecting the hardcoded checkbox iutem irrespective of the search input value.

How to correlate the search result item based on the search input value.

I can see, in the Xpath and on JavaScript on the Object, it has a list with number eg. div/li(n)/div

LI need to correlate that list li(n).

I am using Evaluatr Javascript, but not sure which code to be included to customise the list to corelate or select the result dynamically based on the input search.

Kindly help to resolve this issue.

Thanks,

Geetha

 

0 Likes
5 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: To correlate in LR Truclient 12.55

Hi,

Please check this example in TruClient online help. It might help you understanding the concept.

Regards,
Shlomi

Highlighted
Trusted Contributor.
Trusted Contributor.

Re: To correlate in LR Truclient 12.55

Hi Shlomi,

Thank you for sharing the link, I have correlated using ArgsContext.TC.getParam

Thanks & Regards,

Geetha

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: To correlate in LR Truclient 12.55

Glad to hear.

Now that you have this one working try to get the data you wish from the web page itself and feed it into the object identification method. Once you are capable of doing that with TruClient you will be to overcome any scripting challenge.

Regards,
Shomi

0 Likes
Highlighted
Contributor.
Contributor.

Re: To correlate in LR Truclient 12.55

Hi,

Please can you share how you included the ArgsContext.TC.getParam("i").

Actually my xpath is = (//div[@class="b-product_tile product-tile js-product_tile "]/div[1]/div[2])[1]

and i want to append the ArgsContext.TC.getParam("i") to the last square bracket "[1]"

something like this:

(//div[@class="b-product_tile product-tile js-product_tile "]/div[1]/div[2])ArgsContext.TC.getParam("i")

In javascript when i am giving this,

evalXPath("(//div[@class="b-product_tile product-tile js-product_tile "]/div[1]/div[2])[\""+ ArgsContext.TC.getParam("i") + "\"]");

But i am getting an error ; Exception occurred in the JavaScript code: SyntaxError: missing ) after argument list.

 

 

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: To correlate in LR Truclient 12.55

@SushmithaQT Take your actual xpath expression and escape every " in the expression before moving it over to java script code.

You can also place a javascript string between ' and ' so, you do not need to escape the " in the actual xpath expression.

It looks like you did it correctly escaped the strings near the end when you added the ArgsContext.TC.getParam() code. But your actual xpath expression did not put the value of the parameter between " and ", so that might be an other bug.

P.S.

Programming by example is difficult because you need to discover what is part of the example and what is part of the context.

Signature:
Reward community members who take time to respond and help.
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.