Professional Documents
Culture Documents
How To Automate Clicks Using JavaScript - by Thomas Molnar-Brock - The Startup - Medium
How To Automate Clicks Using JavaScript - by Thomas Molnar-Brock - The Startup - Medium
Sonoplastia IASDBV
bvsonoplastia@gmail.com
Published in The Startup
Save
112 3
https://medium.com/swlh/how-to-automate-clicks-using-javascript-4855f0f42b60 1/6
25/03/2023, 14:38 How to Automate Clicks Using JavaScript | by Thomas Molnar-Brock | The Startup | Medium
If you are like me, you probably use a computer at least once a day. Maybe even
several. Of the time you spend on your computer, I’m willing to wager that a large
portion is spent online. Of that time, quite a lot might be spent clicking on stuff.
This guide will show you how to click in an easier, less repetitive way, which can be
easily customized to your precise clicking needs.
The first thing to do is to open your Chrome browser. Then, navigate to a website on
which you want to click the same button multiple times.
Step Two: Gain Access to The Mainframe (Well Actually Just The JS Console)
Open the console by right-clicking the element you wish to automate clicks for and
selecting the inspect option. You should see a lot of highlighted lines of HyperText
Markup Language (HTML).
https://medium.com/swlh/how-to-automate-clicks-using-javascript-4855f0f42b60 2/6
25/03/2023, 14:38 How to Automate Clicks Using JavaScript | by Thomas Molnar-Brock | The Startup | Medium
Now the button should be visible in code on the side of your browser. Find it’s
identification tag by looking at the button element’s properties. We need this id to
write the code that will click it. It should look like the bold part below.
Next navigate over to the console tab. It should be on the right of the Elements tab
you were just in.
https://medium.com/swlh/how-to-automate-clicks-using-javascript-4855f0f42b60 3/6
25/03/2023, 14:38 How to Automate Clicks Using JavaScript | by Thomas Molnar-Brock | The Startup | Medium
document.getElementById("clickMe").click();
Note that if you are using this on your own application then “clickMe” should be
replaced by the element id you found in step two.
If you have followed along on my webpage, you should now see that the line below
the button reads: “You have clicked: 1 times”. Fantastic! But, sadly this took
substantially more work than just clicking the button with your mouse. The next
step will remedy this flaw.
To do this, type the following code into your console, being sure to replace
“clickMe” with the id of your chosen button. Press enter when it is all typed out.
Now, if all went well, you should rapidly see the counter resting at a healthy 1001.
Congratulations! You have single-handedly automated a common and boring task.
Play around with the 1000 in the loop to make it iterate more or less, and think
about any modifications you might make.
Get smarter at building your thing. Join 176,621+ others who receive The Startup's top 5 stories, tools, ideas, books —
delivered straight into your inbox, once a week. Take a look.
Your email
By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our
privacy practices.
https://medium.com/swlh/how-to-automate-clicks-using-javascript-4855f0f42b60 6/6