Last active
January 5, 2017 21:04
-
-
Save marcelmokos/fb1d00223ecffe28ee522ac6707dbc68 to your computer and use it in GitHub Desktop.
Async await example
This file contains 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
/*-------- Promise.then() syntax ---------*/ | |
/** | |
* @param inputElementWithLabel {ElementFinder} | |
* @returns {Promise.<ElementFinder>} | |
*/ | |
export const getInputsLabelElement = (inputElementWithLabel) => { | |
inputElementWithLabel.getAttribute("id").then((inputId) => { | |
return $(`[for='${inputId}']`); | |
}); | |
}; | |
/*-------- async await syntax ------------*/ | |
/** | |
* @param inputElementWithLabel {ElementFinder} | |
* @returns {Promise.<ElementFinder>} | |
*/ | |
export const getInputsLabelElement = async (inputElementWithLabel) => { | |
const inputId = await inputElementWithLabel.getAttribute("id"); | |
return $(`[for='${inputId}']`); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment