TestProject Forum

In the Action of "Execute Java Script" how do you use "Arg"?

In the Action of “Execute Java Script” how do you use “Arg”?

Hi @carlos.roa ,
“Args” is a way of giving values outside the code to the code at the end of every script we will put this method: .value=arguments[0] please follow this example:

  1. First, I’ve copied this element JS Path:

  2. Now, I’ve pasted the path to the input, and I added .value=arguments[0] at the end, as you see here:

  3. Now, in the “Args” section, I will put some value for this example, I put “Alex”
    and now, in simple words, “Alex” is the first argument, so Alex=[0] now let’s look at it practically:

  4. If you want to add another argument, all you have to do is to add another value to the Args section in this example, I will put the value “Tal”, so basically, Tal=[1] this GIF should help you understand:

  5. and that’s it if you looking for more information about the “Execute javaScript” addon you have In this link: Expanding UI Automation Capabilities with Javascript - TestProject Documentation

  6. Please let me know if it helped you, if you have more questions feel free to ask :slight_smile:

1 Like

Thank you very much for all your collaboration…

You are welcome :slightly_smiling_face: .