Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
How to click a lot of elements in Javascript without errors?

I have been trying to download all USA and CANADA servers here on Nord VPN website: https://nordvpn.com/ovpn/

I tried to manually download it but it is time consuming to scroll down every time and identify each US related servers, so i just wrote simple Javascript that can be run on Chrome Inspect Element Console:

var servers = document.getElementsByClassName("mr-2");
var inc_servers = [];
for (var i = 0; i < servers.length; i++) {
  var main_server = servers[i];
  var server = servers[i].innerText;
  if(server.includes("ca")){
        var parent_server = main_server.parentElement.parentElement;
        parent_server.querySelector(".Button.Button--primary.Button--small").click();
        inc_servers.push(server);
  }
}
console.log(JSON.stringify(inc_servers));

I also wrote simple python script that automatically click "save" file:

while True:
    try:
        app2 = pywinauto.Application().connect(title=u'Save As', found_index=0)
        app2.SaveAs.Save.click()
    except:
        pass

It gets all the elements, it works there, however, when I let javascript click each element, maybe because of too many elements, it returns an error:

VM15575:8 Throttling navigation to prevent the browser from hanging. See https://crbug.com/1038223. Command line switch --disable-ipc-flooding-protection can be used to bypass the protection

Are there any other best alternative for my problem? Or maybe how to fix the error message above? I tried running this command in my command prompt: switch --disable-ipc-flooding-protection

but it returns also an error: 'switch' is not recognized as an internal or external command, operable program or batch file.

I only know basic Javascript and Python. Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So right off the bat, your program is simply downloading files too fast.

Adding a small delay between each file download allows your JavaScript to run.

var servers = document.getElementsByClassName("mr-2");
var inc_servers = [];
for (var i = 0; i < servers.length; i++) {
  var main_server = servers[i];
  var server = servers[i].innerText;
  if(server.includes("ca")){
        var parent_server = main_server.parentElement.parentElement;
        // Add 1 second delay between each download (fast enough on my computer.. Might be too fast for yours.)
        await new Promise(resolve => setTimeout(resolve, 1000));
        parent_server.querySelector(".Button.Button--primary.Button--small").click();


  }
}
// Remove the logging. Just tell the user that it's worked
console.log("Done downloading all files.");

This is more of a temporary solution, but this script seems like it only needs to be run once, so it'll work for now.

(your python code runs fine. Nothing to do there)

Hope this helped.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!