Created
March 16, 2017 15:23
-
-
Save navarroaxel/92587450baac038fb5e612ab33dbed5c 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
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