Forum Discussion

AMR013's avatar
AMR013
Contributor
2 years ago

Any way to modify object's Full Name to use variable defined in project?

Hello,

I'm trying to click an object on a screen via scripting. When I use the Object Spy, the Full Name shows as follows:

 

Aliases.browser.pageWhoa.FindElement("//td[contains(., '100')]")

 

I defined the "100" value as follows:

 

var record = '100'

 

While I could just use this name and click on it, I want to make it "universal" as the "100" value will vary. Is there any way to modify the Full Name to incorporate my record variable?

 

Appreciate the help in advance.

  • You can construct it like so,

    var num = 100;
    var param = "//td[contains(., '" + num.toString() + "')]";
    Aliases.browser.pageWhoa.FindElement(param);

     

     

2 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can construct it like so,

    var num = 100;
    var param = "//td[contains(., '" + num.toString() + "')]";
    Aliases.browser.pageWhoa.FindElement(param);

     

     

    • AMR013's avatar
      AMR013
      Contributor

      rraghvani ,

       

      Thank you for the suggestion! I tried it earlier today and it worked perfectly. I didn't think to take the FindElement attributes and define them as a new variable. I will definitely keep that approach in mind for future scripts.

       

      Thanks,

      AMR013