In Selenium Webdriver, ExpectedCondition.elementToBeClickable is not waiting until the progress bar disappears
ExpectedConditions.elementToBeClickable
returns element if condition will be true means it returns element if element appears on the page and clickable, No need to find this element again, just omit last line as below :-
//Click on Create Account btn:
driver.findElement(By.id("createAccount")).click();
//Wait till "Cancel" button is showing up. At cases, it may take some time.
WebElement el = myWaitVar.until(ExpectedConditions.elementToBeClickable(By.id("cancelRegister")));
el.click();
Edited1 :- If you're unable to click due to other element receive click you can use JavascriptExecutor
to perform click as below :
//Click on Create Account btn:
driver.findElement(By.id("createAccount")).click();
//Wait till "Cancel" button is showing up. At cases, it may take some time.
WebElement el = myWaitVar.until(ExpectedConditions.elementToBeClickable(By.id("cancelRegister")));
((JavascriptExecutor)driver).executeScript("arguments[0].click()", el);
Edited2 :- It seems from provided exception, progress bar still overlay on cancelRegister
button. So best way is to wait for invisibility of progress bar first then wait for visibility of cancelRegister
button as below :
//Click on Create Account btn:
driver.findElement(By.id("createAccount")).click();
//Now wait for invisibility of progress bar first
myWaitVar.until(ExpectedConditions.invisibilityOfElementLocated(By.id("page_loader")));
//Now wait till "Cancel" button is showing up. At cases, it may take some time.
WebElement el = myWaitVar.until(ExpectedConditions.elementToBeClickable(By.id("cancelRegister")));
el.click();
Hope it works...:)
You can have a wait there to make sure that progress bar disappears.
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return (driver.findElements(By.id("progressbar")).size() == 0);
}
});