简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM