Skip to content

Instantly share code, notes, and snippets.

@clovisdasilvaneto
Last active December 22, 2016 17:46
Show Gist options
  • Save clovisdasilvaneto/9561473345c97e29bbbe6882abb44d06 to your computer and use it in GitHub Desktop.
Save clovisdasilvaneto/9561473345c97e29bbbe6882abb44d06 to your computer and use it in GitHub Desktop.
findElement(locator, ...expectations){
let instance = this;
let driver = instance.driver;
return new Promise(resolve => {
instance.getElementForConditions(locator, expectations, true).then(element =>{
resolve(element);
});
});
}
getElementForConditions(locator, expectations, multiple) {
let instance = this;
let driver = instance.driver;
let expectationQueue;
let element;
let promisse = new Promise(resolve => {
driver.wait(instance.until.elementsLocated(locator), timeout).then(function(){
element = driver.findElement(locator);
expectationQueue = queue(function(webdriverCondition, callback) {
driver.wait(webdriverCondition(element), timeout).then(function(){
callback();
})
}, 200);
expectationQueue.push(expectations, function(){
resolve(driver.findElement(locator));
})
});
});
return promisse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment