Click buttons randomly

Hi,
I have 3 buttons and each time I launch the script I want it to pick one of the buttons randomly and click it, how can I do that?

Thank you

Need to see the page to detect xpath, this job is more easy to do but need to see the page to detect a xpath

Very simple to do

this is the macro code to click random button from 1 to 3 and notify the number of button clicked

Alreadu tested working like a charm

{
“Name”: “Random Button”,
“CreationDate”: “2021-9-6”,
“Commands”: [
{
“Command”: “bringBrowserToForeground”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “var min = 1; var max = 3; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; return randomNumber;”,
“Value”: “Random_Number”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=(//input[@name=‘Color’]/following-sibling::label)[${Random_Number}]”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “Clicked Button Number ${Random_Number}”,
“Value”: “#shownotification”,
“Description”: “”
}
]
}

Edit: I fixed it, thank you so much for your help

1 Like