How to use protractor to check if an element is visible without waiting? I'm from Java + WebDriver background and new to Protractor. In Java I used the following solution. I'm looking for a similar functionality.
More Information: Currently if I use isDisplayed(), WebDriver will wait until the element is visible (if it is not already displayed). I want to get the visibility status without waiting.
protected void turnOffImplicitWaits() {
driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
}
protected void turnOnImplicitWaits() {
driver.manage().timeouts().implicitlyWait(StartupConstants.TIMEOUT, TimeUnit.SECONDS);
}
protected boolean isElementHiddenNow(By by) {
turnOffImplicitWaits();
boolean result = ExpectedConditions.invisibilityOfElementLocated(by).apply(driver);
turnOnImplicitWaits();
return result;
}
If you don't want any default waits while checking for visibility of element, do one thing, that is just perform any operation like click() on target element and add then() function with two functions as parameters - one for success and other for failure. You follow the code below:
Add below code in Conf.js