Hey All I have an issue that I am facing. I want to create a method that will get element id, and wait until it will be clickable. (the issue is since the element is intercepted, I do not want to user wait clickable). the issue is that the element is seen after a while and clickable after another. I printed to consul the times of pulling and saw it is not printed, meaning it not event once try to pull.
public static void waitForElementSeenAndClick (String elementId)
{
WebDriver driver2 = WebDriverMgr.getDriver();
Wait wait = new FluentWait(driver2)
.withTimeout(FLUENT_WAIT_MAX, TimeUnit.SECONDS)
.pollingEvery(FLUENT_WAIT_PULLING, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class,
Exception.class);
wait.until(new Function<WebDriver , Boolean>() {
public Boolean apply (WebDriver driver2) {
WebElement element = driver2.findElement(By.id(elementId));
System.out.println("Try to click_1");
element.click();
if(element.isDisplayed()) {
System.out.println("Try to click_2");
element.click();
return true;
}
System.out.println("Try to click_3");
return false;
}
});
}
This is what I get from consul (The id is: "header-account-logout" )
ERROR: no such element: Unable to locate element: {"method":"css selector","selector":"#header\-account\-logout"}
(Session info: chrome=77.0.3865.120)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
Try to click 1 not printed at all Try to click 2 not printed at all Try to click 3 not printed at all Its not entered to the loop and not try to pull