I'm looking for more help in relation to the SO question get an array of elements from findElement(By.className())
This is about using the javascript implementation of the Selenium Webdriver to automate a website component.
From the example given in the referenced question, I can't figure out how to pass the allHtml array back out to the calling methods and up to the gherkin step definition where the test logic resides.
I've tried several approaches (too many to document), with many hours of Googling. I'm just not getting how to pass anything back from a promise (once it is resolved and we have allHtml defined). Yes, I can output to the console, but that doesn't help in a real world testing scenario where I need to assert a pass or fail based on a comparison of actual vs expected.
Promises are painful. They are new to me, and will hurt until I wrap my head around them.
As a last resort (and probably only solution) I'm going to look into using webdriver-sync in order to avoid promises which are native to the javascript version of webdriver.
Any help or guidance would be appreciated in understanding how to pass things back from a promise once it is fully resolved, if it's possible. Promises seem to me to be about using things when they're ready, and not before, or after.
Thank, Al.
AddApplicationPage.prototype.getFilteredAppLibraryTemplates = function (context) {
var eleArray = this.getAppLibraryTemplateIcons(context);
return eleArray;
}
AddApplicationPage.prototype.getAppLibraryTemplateIcons = function (context) {
var pendingElements = context.driver.findElements(By.className('appLibrary-templateIcon'))
pendingElements.then(function (elements) {
var pendingHtml = elements.map(function (elem) {
return elem.getInnerHtml();
});
promise.all(pendingHtml).then(function (allHtml) {
// how do i pass allHtml back up the food chain
// so i can do some comparison to the expected list
});
});
}