The only way to increment for a WHILE_V2 loop is a call to Javascript, is that right?

The documentation for WHILE_V2 (while, endWhile - FlowControl - Selenium IDE Commands Tutorial) doesn’t demonstrate how to increment a variable. That is, it demonstrates an incremented loop only with the deprecated WHILE command.

As near as I can tell, the only way to increment a variable is to make an external call to Javascript with “executeScript_Sandbox” (such as I did in the loop below). Is that correct, there’s no way to increment natively?

{
  "Name": "example",
  "CreationDate": "2020-2-28",
  "Commands": [
    {
      "Command": "store",
      "Target": "1",
      "Value": "k"
    },
    {
      "Command": "while_v2",
      "Target": "${k} <= 5",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "${k}",
      "Value": "green"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${k}) + 1",
      "Value": "k"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}
1 Like

JS would be the way to do it.
More info:

https://forum.ui.vision/search?q=counter
https://forum.ui.vision/search?q=loop
https://forum.ui.vision/search?q=increment

Correct! See also How to increase value of the type per loop? - #5 by admin