Is there a way to select options from a dropdown menu randomly?

Hey,
is there a way to select options from a dropdown menu randomly?

It’s easy. Use execute Script to generate a random number. This macro selects a random drop down box value:

{
  "Name": "random",
  "CreationDate": "2021-2-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/contact",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=ContactName",
      "Value": "Random test"
    },
    {
      "Command": "comment",
      "Target": "Create random number between 0 - 4",
      "Value": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Math.floor(Math.random()*4);",
      "Value": "randomvalue"
    },
    {
      "Command": "echo",
      "Target": "${randomvalue}",
      "Value": "blue"
    },
    {
      "Command": "select",
      "Target": "id=WhatSoftware",
      "Value": "index=${randomvalue}"
    }
  ]
}

See also TYPE random from CSV - #11 by newuserkantu

1 Like

Thank you Plankton, that worked. I have another question if you don’t mind, in the example you gave you assigned the number of options but in my case I have two drop menus the number of options in the first one are static(your example works perfectly on it) but the second one changes according to the selected option in the first one. is there a way to randomly select an option in that case?

So the challenge is to find the number of entries in the second dropdown, or?

=> see here: Select the last item option on a menu - #5 by Plankton => This gives you the index of the last entry. That is equal to the number of items in dropdown.