Skip to content

Instantly share code, notes, and snippets.

@navarroaxel
Created March 16, 2017 15:23
Show Gist options
  • Save navarroaxel/92587450baac038fb5e612ab33dbed5c to your computer and use it in GitHub Desktop.
Save navarroaxel/92587450baac038fb5e612ab33dbed5c to your computer and use it in GitHub Desktop.
const {reduce} = require('async');
this.sumColumn = function (rowsNumber, columnPosition,callback) {
var total = 0, value;
reduce(rowsNumber, 0, (acum, i) => {
browser.getText(ELEMENTS.ROW.locator + ':nth-child(' + i + ') td:nth-child(' + columnPosition + ')',
result => {
value = parseInt(JSON.stringify(result.value).replace(/\D/g, ''));
callback(null, acum + (value || 0));
console.log('counting... '+acum);
}
);
}, callback);
for (i = 1; i <= rowsNumber; i++) {
}
browser.perform(function(){console.log('outside loop total: '+total)})
return total;
};
var user = browser.globals.users.SUPERVISOR;
var dwellings = browser.page.dwellings();
browser.page.login().loginUser(user)
.page.navBar().goToMonitoring()
.page.monitoring().goToDwellings()
dwellings.clickScope(1)
dwellings.clickScope(1);
var total2 = dwellings.sumColumn(8, 2, (err, result) => {
console.log(result);
});
browser.perform(function(){console.log('please don\'t screw up: '+total2)})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment