How to click on a same button multiple times

2,549 views
Skip to first unread message

Danish Shah

unread,
Jan 28, 2014, 12:45:32 PM1/28/14
to seleniu...@googlegroups.com
Hi everyone, 
I tried searching for this topic but had 0 luck with it. I know it's a novice question but I can't seem to figure it out, any help will be much appreciated.
So I have a button my webpage which needs to be clicked in order to generate some data. I want to automate this so I can keep clicking on this button every two seconds to see that the data is being generated properly. How do I formulate my for loop to achieve this? 

Doug Dragon

unread,
Jan 29, 2014, 1:00:43 PM1/29/14
to seleniu...@googlegroups.com
Here is one way of doing it in Python:

button = driver.find_element_by_css_selector("input#id_of_button")
count = 10
while count > 1:
  button.click()
  # do your verification
  count -= 1
  time.sleep(2)

nani.thrinath.info

unread,
Jan 31, 2014, 1:45:38 AM1/31/14
to seleniu...@googlegroups.com
WorkAround? try this!

for (int i = 0; i < 50; i++) {
driver.findElement(By.id("xyz")).click();
Thread.sleep(1000);
}

Regards,
Thrinath


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5530af93-2fc2-4d73-993f-b82ca7960203%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Thirnath

ani0...@gmail.com

unread,
Jan 31, 2014, 4:05:37 PM1/31/14
to seleniu...@googlegroups.com
Yes u r correct
------Original Message------
From: Danish Shah
Sender: seleniu...@googlegroups.com
To: seleniu...@googlegroups.com
ReplyTo: seleniu...@googlegroups.com
Subject: [selenium-users] How to click on a same button multiple times
Sent: Jan 28, 2014 11:15 PM

Hi everyone,  I tried searching for this topic but had 0 luck with it. I know it's a novice question but I can't seem to figure it out, any help will be much appreciated. So I have a button my webpage which needs to be clicked in order to generate some data. I want to automate this so I can keep clicking on this button every two seconds to see that the data is being generated properly. How do I formulate my for loop to achieve this?  -- You received this message because you are subscribed to the Google Groups "Selenium Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com. To post to this group, send email to seleniu...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8376d97c-1bd1-4c09-a2b4-e2a7586cd93d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Sent from BlackBerry® on Airtel
Reply all
Reply to author
Forward
0 new messages