Skip to content

Instantly share code, notes, and snippets.

@marcelmokos
Last active January 5, 2017 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelmokos/fb1d00223ecffe28ee522ac6707dbc68 to your computer and use it in GitHub Desktop.
Save marcelmokos/fb1d00223ecffe28ee522ac6707dbc68 to your computer and use it in GitHub Desktop.
Async await example
/*-------- 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