DEV Community


How to Click Faster Selenium vs The World Faster Clicker

pjcalvo profile image Pablo Calvo ・2 min read

Today I discovered that a guy named Jordan Hum is the world record holder for more clicks in 5 seconds, with an amazing score of 14 CPS which means 70 clicks in 5 seconds.

So I went to Click Speed Test and tried my self.

You’re a Rabbit! Well.. You Clicked with the speed of 9.6 CPS (Clicks per seconds). You made 48 Clicks in 5 Seconds.

Automating the clicks

I wondered how fast can selenium click? I am pretty sure that a selenium script can beat this guy, but let's make sure finding some results.

This is the script:

driver = webdriver.Chrome(DRIVER_LOCATION) #driver
print('Start clicking')
id = driver.find_element_by_id('clicker')
while True: # click for ever
  except Exception as ex: # until it breaks
    print('Time is over')

time.sleep(1) # results are slow
result = driver.find_element_by_css_selector('.times')
print(f'Result: {result.text}\n') 
Enter fullscreen mode Exit fullscreen mode

I executed it several times to find an average value, but basically this was the result:

Start clicking
Time is over
Result: 190 Clicks in 5 Seconds
Enter fullscreen mode Exit fullscreen mode

Let's learn something

I wanted to have a lesson learned out of this post, so I tried and tested a couple of myths:

1) The original script finds the element once and then uses that instance to execute the clicks. But what if we try to find the element inside the loop and click it right away driver.find_element_by_id('clicker').click().

The outcome is way slower clicking as expected:

Result: 137 Clicks in 5 Seconds
Enter fullscreen mode Exit fullscreen mode

2) We can try to use a javascript executor to performs the clicks instead of the click method:

javaScript = "document.getElementById('clicker').click();"
Enter fullscreen mode Exit fullscreen mode

My lesson learned for this case is that using javascript not always trigger the click event.

3) What if I use a headless browser? Does it makes any difference:

The result is (surprisingly for me) an average faster clicking:

Result: 216 Clicks in 5 Seconds
Enter fullscreen mode Exit fullscreen mode

I executed this a lot of times and in some cases it went down to ~170, but average was mostly faster.

Final thoughts

Maybe clicking this fast is not a normal use case for selenium, but knowing how to improve tests speed and performance can save some minutes of execution on large amounts of tests.

Suggestions on what else we can test?

cheers :) and remember to keep clicking

if you liked the post:

Buy Me A Coffee

Discussion (4)

rickrdough profile image
gvrjay profile image

Actually the website is fake....the information given about the world record is not official at all. There is a wide variety of clickers who even get cps above 20! Plus, it also depends on what mouse you are using. Some mice can double click causing the cps to be twice the number. So there is no official record.

asad_ali_7a6d163088861b2b profile image
Asad Ali

i beat the world record of 15.8 clicks or 79 clicks in 5 seconds

pjcalvo profile image
Pablo Calvo Author

Niceee. Is it official???

Forem Open with the Forem app