Forum Discussion

s21_shankar's avatar
s21_shankar
New Contributor
6 years ago
Solved

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)

     

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    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)