Switch Case Statement

I do not see a command for a switch case statement. Is the only option embedded multiple if statements? If so, does anyone have an example of a best practice.

Selenium IDE and UI Vision do not have a Switch/Case statement. But you can recreate it with if - else if - else - end.

Example:

{
  "Name": "else if",
  "CreationDate": "2021-2-24",
  "Commands": [
    {
      "Command": "store",
      "Target": "aaaaa",
      "Value": "x"
    },
    {
      "Command": "if_v2",
      "Target": "${x} === \"a\"",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "x is a!",
      "Value": "green"
    },
    {
      "Command": "elseif",
      "Target": "${x} === \"b\"",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "x is b!",
      "Value": "blue"
    },
    {
      "Command": "elseif",
      "Target": "${x} === \"c\"",
      "Value": ""
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "x is something else",
      "Value": "red"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}

This looks good I will implement it tonight. Thanks again for your help.

sorry for necro old thread.

I came with the same question, but for some reason elseif dont work for me (firefox user)

there is any way to nest switch case inside executescript_sandbox and then return the matching case?

is it possible to use ‘if else’ with xclick and a picture ?

for example if you find an image with xclick , you do something else you try another command ?