1

I know this question has been answered before but none of the solutions seem to work for me.I have been on this for an entire day.I have tried all of the below:

1)wait(1000);

2)driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);

3)driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

Also, when I am executing my code on debug mode (Debug as JUnit Test to be more precise) then I am supposed to see the wait right ?

I am trying this with Chromedriver 32 bit and IEDriver 32 bit.I am using Eclipse IDE.

The main reason I am trying to make the driver wait is because the snapshots are being captured before the page has completely loaded.

Any help would be hugely appreciated.Thanks!

EDIT :

As it turns out the problem is not that the driver isn't waiting.I get an error : "Element is not clickable at point (457, 261). Other element would receive the click" I tried looking it up Debugging "Element is not clickable at point" error but there is no solution in java.

CODE :

driver.findElement(By.id("appInfoRestartBtn")).click();             capturescreenshot("C:\\webreceiver\\Screenshots\\Desktops\\Desktops3.jpg");        
//driver.findElement(By.cssSelector("div.messageBoxCancelAction > a.dialog.button")).sendKeys("");      
element = driver.findElement(By.cssSelector("div.messageBoxCancelAction > a.dialog.button"));

Actions action = new Actions(driver);
action.moveToElement(element).click().perform();
driver.findElement(By.cssSelector("div.messageBoxCancelAction > a.dialog.button")).click();   
driver.findElement(By.id("appInfoAddButton")).click();              capturescreenshot("C:\\webreceiver\\Screenshots\\Desktops\\Desktops4.jpg");

StackTrace :

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (457, 261). Other element would receive the click: <a href="#" class="messagebox overlay" id="genericMessageBoxOverlay" style="display: inline;"></a>

(Session info: chrome=43.0.2357.81) (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)

Ashish Kamble
  • 2,555
  • 3
  • 21
  • 29
Payal Agarwal
  • 47
  • 2
  • 7

4 Answers4

0

If you are using Java as language you can use Thread.sleep(4000L);

  • Hey ! Thanks for your time.As it turns out the problem is not that the driver isn't waiting.I get an error : "Element is not clickable at point (457, 261). Other element would receive the click" I tried looking it up "http://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error" but there is no solution in java. I'll edit my question too. – Payal Agarwal May 27 '15 at 04:28
0

for c#:

public static void Wait(int TimeMS)
  {
      Thread.Sleep(TimeMS);
  }
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101
0

Use explicit wait to be sure element is clickable

/**
 * Ensures that element is clickable
 * 
 * @param element Element that must be clickable
 */
public void untilElementIsClickable(WebElement element) {
    WebDriverWait wait = new WebDriverWait(driver, timeout);
    wait.until(ExpectedConditions.visibilityOf(element));
    wait.until(ExpectedConditions.elementToBeClickable(element));
}

Where timeout is number of second for which code should wait.

Priyanshu
  • 3,040
  • 3
  • 27
  • 34
0

You can wait until the element is clickable with FluentWait and ExpectedConditions

Wait<WebDriver> wait = new FluentWait<WebDriver>(yourWebdriverInstance)  
                          .withTimeout(30, TimeUnit.SECONDS)
                          .ignoring(StaleElementReferenceException.class) //Exceptiosn to ignore while pulling
                          .ignoring(NoSuchElementException.class)
                          .pollingEvery(100, TimeUnit.MILLISECONDS) 
                          .withMessage("This is an error message");
T result = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.messageBoxCancelAction > a.dialog.button"))); 

This will try if the element is clickable every 100ms for 30 seconds.While doing this it ignores NoSuchElement and StaleElement exceptions

Dude
  • 692
  • 1
  • 4
  • 25