For some reason I'm getting ElementNotVisibleException when I try to click on visible component:
WebElement quickSearchInputEl = uiContext.waitUntilElementExists(By.name("QuickSearch"));
quickSearchInputEl.click(); // exception happens here
Screen and DOM-structure:
Looks like this is some selenium issue.
There is workaround to click within field:
WebElement quickSearchInputEl = uiContext.waitUntilElementExists(By.name("QuickSearch"));
((JavascriptExecutor)cc.getDriver()).executeScript("arguments[0].focus(true);", quickSearchInputEl);
This solution looks fine, but I wonder if the focus() call really solved it? Or if that is a coincidence and it really worked because that gave it enough time to become visible? For example, I wonder if something like this would have worked just as well:
context.waitUntil(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
return quickSearchInputEl.isDisplayed() ? quickSearchInputEl : null;
}
});
@greghmerrill: I think the problem is with the WebElement.click()
method itself, because we had to do the same thing within TextField.setValue()
; we commented out the click()
call and instead used JS to focus the element before using WebElement.sendKeys()
.