Last active
December 22, 2016 17:46
-
-
Save clovisdasilvaneto/9561473345c97e29bbbe6882abb44d06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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