Creating an array for multiple instances targeting IDs with non static members

41 Views Asked by At

I am trying to automate text boxes to fill with a certain value, however the text boxes names are not static so they will always change. I am looking to find a way to always populate them even though they do not have a static name and how to find the second, third, fourth etc instance of the boxes and be able to also fill them without overwriting the previous text boxes

i have tried using the _collect function in sahi pro but could not find how to target the class correctly

I expect to be able to populate any textbox using the same class name without overwriting the first instance of this class.

I am using Sahi pro.

1

There are 1 best solutions below

0
globalworming On

The sahi documentation on _collect seems to be you exactly what you are looking for

// Collect all textboxes matching any identifier, in table "listing".
// Note the use of match all regular expression "/.*/"
var $textboxes = _collect("_textbox", "/.*/", _in(_table("listing"));
// Iterate and set values on all textboxes
for (var $i=0; $i<$textboxes.length; $i++) {
  _setValue($textboxes[$i], "value");
}

If this does not solve your problem, please provide an example of the html and of your _collect code