Forum Discussion

mgreen's avatar
mgreen
Contributor
6 years ago

"Run This Routine" Greyed out in script mode

Hey All,

 

Hello.  I have a block of code I want to reuse multiple times with a parameter on the "Test Items" page.  

It's for navigating to specific buttons on a nav bar.

 

When I run the test through the Test Items page (via right click + run Focused Test item) it works just as I expect, which is great...I can select the param as a string and put a value in and its good to go. 

 

but when Im editing in the script mode editor, I cannot do the "run this routine" option, and is making me think there is an error in the code somewhere? Its greyed out and apparently is suggesting to click Code Completion, which Im not sure what it's trying to do there. Any thoughts would be very appreaciated! 

 

I've isolated a small chunk and  thought if I made it this basic it would work, but no - it is still greyed out.  

 

function teleport(NEWPARAM) {
Indicator.PushText("Navigating to Blade...");
let navigate = Aliases.browser.page.nav
let navbar = Aliases.browser.page.header
//Clear any open blades
Aliases.browser.page.header.button3.HoverMouse();
delay(200)
Aliases.browser.page.header.button3.Click();
delay(200)
Log.Message(NEWPARAM);
}

  • The routine has a parameter.  You can't run a parameterized routine using the right-click context menu because you need to have some way of indicating the value of the parameter.  Work-around: create a "harness" function that, all it does is call your routine with the proper parameter value.

  • Bobik's avatar
    Bobik
    Frequent Contributor

    You can't run function with parameters by 'Run this routine' action. 

    Try to create an additional function to run need test manually from the script.

    teleport_debug()

    {

       teleport("myTestItem")

    }

     

    • mgreen's avatar
      mgreen
      Contributor

      It appears I can run the routine when I'm on the Test items page, and if I make a keyword test with params then convert it to script mode it looks just like what I'm trying to do above.. so I'm not entirely sure.

       

      Are you saying that I can achieve what I'm trying to do by making the params in a function INSIDE of a parent function? 

      • Marsha_R's avatar
        Marsha_R
        Moderator

        Inside of a parent with no parameters I think is the point.  You can't run it the way you have it because there's no way to give it the parameters.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The routine has a parameter.  You can't run a parameterized routine using the right-click context menu because you need to have some way of indicating the value of the parameter.  Work-around: create a "harness" function that, all it does is call your routine with the proper parameter value.