Click all checkboxes on a page at once

Hello,

I created a script which basically checks all checkboxes on a page one after another. However I would really like to speed up this process because sometimes there are 300+ checkboxes.
Currently I just work with a click command and the loop variable to loop through all checkboxes.

Is there a way to do this?

Thank you in advance!

1 Like

Instead of using the LOOP button, create a loop inside the macro e. g. with While and make sure you set the replayspeed to fast. => This will be much faster, as it avoids the macro restart and initialization at every loop start.

1 Like

Hello. My task is very similar to this one.
I need to find the same caption “Illustration” on the page one by one, and click on each. There are 100 of them.
I do not know the syntax to do this.

How can we make a script that clicks on all checkboxes and we dont know the count?
Can you lead me to an example code?
Thanks :slight_smile:

there are no more than 100 per page

There are no problems even if they were 1000 checkboxes, a well made macro can automate anything even 1000 checkboxes and even more.

How can I make a request window for a variable number of cycles?

Explain better what you need to do, I can’t understand, if you can add an image to explain well what you want to do

How can I make a request window for a variable number of cycles?
{
“Name”: “canstock”,
“CreationDate”: “2020-3-22”,
“Commands”: [
{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!replayspeed”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “Loop_Counter”
},
{
“Command”: “label”,
“Target”: “Engine_Code”,
“Value”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number ({Loop_Counter}) + 1", “Value”: “Loop_Counter” }, { “Command”: “click”, “Target”: "xpath=(//label[contains(.,‘Illustration’)])[{Loop_Counter}]”,
“Value”: “”
},
{
“Command”: “pause”,
“Target”: “1”,
“Value”: “”
},
{
“Command”: “gotoIf_v2”,
“Target”: “${Loop_Counter} < 100”,
“Value”: “Engine_Code”
}
]
}

Use command input

{
  "Command": "prompt",
  "Target": "Add The Number Of Loop To do @1",
  "Value": "LoopMax"
},

Read Here

Thanks, that helped!

I don’t recommend using UI Vision looping for this. You can check all checkboxes instantly without any user input by using executeScript. This will all be in one line and it will be significantly faster and more accurate.

executeScript| var inputs = document.querySelectorAll(“input[type=‘checkbox’]”);for(var i = 0; i < inputs.length; i++) { inputs[i].checked = true;}

Obviously this assumes you’re using the element.

@ggreene09

How work this script i tried and it seems do not work and do not check nothing.

Can you add more info, screen and page where this script work please

Thanks

@newuserkantu this was more directed to the original poster, and it’s not a “one size fits all” deal. From your screenshot, you don’t appear to be using checkboxes. Those look like radio buttons, but the resolution in the screenshot you shared makes it hard to tell.

I’d need to see screenshots of these from your side along with ID, classes, or name attributes if possible. Is this a public-facing page? If so, send a link

Your script if work is very interested i add some link if you can try your code, i tried your code but nothing action was do

https://www.ericmmartin.com/code/jquery/checkbox.html

https://stevefaulkner.github.io/html-mapping-tests/browser-tests/checkbox-states.html

https://faculty.washington.edu/chudler/java/boxes.html

Oh I see. If you copied from here, it would paste in the “curly” quotes which Javascript can’t read. Try from the block below.

var inputs = document.querySelectorAll("input[type ='checkbox']"); for (var i = 0; i < inputs.length; i++) { inputs[i].checked = true; }
1 Like

The script works great, you are great, thank you very much is a great tip to speed up automation, thank you very much

Of course! I’d definitely suggest getting strong with Javascript the more you use UI Vision. You can certainly do quite a bit without JS, but your macros will be an a whole other level when you have this in your arsenal.

You are perfectly right with javascript many automations are faster and easier to do, I will study it more, thanks again the tip