Forum Discussion

s21_shankar's avatar
s21_shankar
New Contributor
7 years ago

Perform an action stored in a variable over an object

Imagine the below scenario.

Set myObj = Browser.Page.Obj

Var myAction = "click"

I want to perform the click action in the below fasion

"myObj .myAction "

 

Can someone let me know how this can be done. I have tried to use Eval as well but no luck.

  • And if myObj is an object, like in your example, then something like this should work:

    eval(myObj.FullName + '.' + myAction)

     

  • if myObj and myAction are both strings, then something like this should work:

    eval(myObj + '.' + myAction) 

     

     

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      And if myObj is an object, like in your example, then something like this should work:

      eval(myObj.FullName + '.' + myAction)