Currently, I am utilizing selenium-webdriverjs. My objective is to pause until a specific element is displayed. To accomplish this, I have implemented an explicit wait that operates effectively:
var shown = false;
driver.wait(function(){
driver.findElement(locator).isDisplayed().then(function(value){
shown = value;
});
return shown;
}, timeout);
Is this the optimal approach or is there a more effective method? The reason for my inquiry is that during the initial invocation of the wait callback (in my situation), it consistently returns false. It is only upon subsequent execution of the isDisplayed promise that the value of 'shown' is altered.