Randomly select a Kind

Here you can ask anything related to JavaScript as applied to Helium Scraper.
Post Reply
Posts: 1
Joined: Mon Nov 21, 2016 7:59 pm

Randomly select a Kind

Post by JSalt » Mon Nov 21, 2016 8:10 pm


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!

Post Reply