2
votes

My script is failing because of the following exception.

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (355, 160)

While loading the page if the element appears in the background, selenium tries to click and fails. I have used webdriverwait. Out of 10 times it fails around 3 times minimum.

How can I avoid/handle this without using Thread.sleep();

enter image description here

2
u can wait untill invisibility of element (please wait loading...) - noor
Thanks. Let me try this. - Prakash P
let me know what happens - noor
Thanks for that. As of now it's working. I have to observe for a while. - Prakash P
if that worked i will convert it to answer but u already accept an answer which is like my comment - noor

2 Answers

4
votes

You should wait until invisibility of element using invisibilityOfElementLocated as below :-

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath('xpath of please wait loading...')));

After this you could perform click on target element

Hope it will work..:)

0
votes

Use explicit wait

WebDriver driver = new FirefoxDriver();
driver.get("http://somedomain/url_that_delays_loading");
WebElement myElement = (new WebDriverWait(driver, 10))
  .until(ExpectedConditions.presenceOfElementLocated(By.id("myElement")));
// or (new WebDriverWait(driver, 10)).until(
    //    ExpectedConditions.visibilityOfElementLocated(By.id("myElement")));
myElement .click();