0

I want to be able to click a logout button twice very rapidly like a user would?

WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{

  if(logout.isDisplayed()){
    logout.click();

I want to be able to click on the logout button twice at less than a second like a user would? Is this possible in selenium webdriver?

Speedychuck
  • 400
  • 9
  • 29
  • 1
    Possible duplicate of [how to double click on a list of webElements in Selenium webdriver](http://stackoverflow.com/questions/18908556/how-to-double-click-on-a-list-of-webelements-in-selenium-webdriver) – Atri Jan 08 '16 at 16:19
  • WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label")); Actions action = new Actions(driver);{ if(logout.isDisplayed()){ action.doubleClick(logout); action.perform(); Reporter.log("Logout Successful | "); } This doesn't work do I need to use a try/catch block? @Atri – Speedychuck Jan 08 '16 at 16:47

1 Answers1

1

EDIT:

Make sure the dom is loaded

Like atri said, you could use the double click function according to This thread.

WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{

  if(logout.isDisplayed()){
    logout.doubleClick();

if you don't want to use the doubleClick function, I would recommend the ExplicitWait from Selemium Selenium: Implicit and explicit Wait

If you want to do this manually, could add a delay between your click using javascript Thread and selenium wait. Based on This thread

WebElement logout = driver.findElement(By.id("dijit_form_Button_0_label"));{

  if(logout.isDisplayed()){
    logout.click();
    Thread.sleep(100);
    logout.click();
}

Better way is to use ExplicitWaits which you means you will wait exactly as long as some action happens or some element gets rendered on the page. - petr-mensik

An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is Thread.sleep(), which sets the condition to an exact time period to wait. - Selenium

Community
  • 1
  • 1
Alegrowin
  • 321
  • 1
  • 14