Page 1 of 1

Randomly select a Kind

Posted: Mon Nov 21, 2016 8:10 pm
by JSalt

I am trying to create a javascript action that will select a button (ranging from 1-5; in this example I included 3). Each of these buttons are separate Kinds. I have very limited (or no experience with coding), but have managed to come up with the following based on various forums online:

Code: Select all

var Bt1 = Global.Browser.SelectKind("button1")
var Bt2 = Global.Browser.SelectKind("button2")
var Bt3 = Global.Browser.SelectKind("button3")

	var myArray = ['Bt1' , 'Bt2', 'Bt3']; 
    var rand = myArray[Math.floor(Math.random() * myArray.length)];
This selects a kind, unfortunately, I'm not sure if it is doing it properly, because if I try it again, it continues to select the same one (or it is stuck on that particular kind). Also, these particular buttons have to have "simulated clicks", so my intention was to have a child action of "navigate to selection" (with "simulate click" checked).

Any help with this would be greatly appreciated!