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

 

  • Hi,

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

    Regards,
    Shlomi

  • Hi Shlomi,

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

    Thanks & Regards,

    Geetha

  • 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

  • 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.

     

     

  •  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.