If there a way to perform .click() after the element become visible.
My function chain is built like that:
this.remote.findByXpath("//div[@data-index='blockContainer']/button[text()='Create new']").then(function(element) {
return element.click().end();
})
Sometimes I got error says 'the element is not visible', is it possible to perform click after the element displayed in browser? I know Leadfoot supplies pollUntil to do similar thing but I don't want to execute xpath at browser side, instead of I want to do until at running server side.
To solve my problem I tried following two ways but doesn't help:
I tried to pass Leadfoot Element to browser side script and check if it is visible. But it seems browser side code doesn't recognize leadfoot/element object.
command.find(...).then(function(element) { return command.then(pollUntil( function(element) { if (element.style.display == 'none') return null; return true; }, [element], 60000, 500)).then(function(el){ }); }).click().end();
Also tried to customize pollUntil myself but doesn't work as well
function pollVisible(element, timeout) { var dfd = new Deferred(); var endTime = Number(new Date()) + timeout; (function poll() { element.isDisplayed().then(function (displayed) { if (displayed) { dfd.resolve(); } else if (Number(new Date()) < endTime) { setTimeout(poll, 500); } else { var error = new Error('timed out; final url is ' + url); dfd.reject(error); } }); })(); return dfd.promise; }