Let's speed up Protractor's data lookup

Michael Holleran

Protractor is the favored testing framework for end-to-end testing of AngularJS apps. It's quite good, and I especially like the smooth integration with Sauce Labs.

But Protractor can sometimes be very slow. For instance, if we have a page that shows a data table with (say) 3 columns (name, balance and creditLimit) and 20 rows, and I want to get all the values displayed in that table, the "normal" way to retrieve the data in that table would be something like:

// Parameters:
// tableSelector: the css selector for the table rows, e.g. "#leftGridContainer .ngRow"
// columnSelector: the additional css selector for the columns in a row, e.g. ".ng-binding"
// colNames: an array of strings with the names of the columns
var getTableValues = function(tableSelector, columnSelector, colNames) {
return element.all(by.css(tableSelector)).map(function(row, index) {
var columns = row.all(by.css(columnSelector));
return columns.then(function(cols){
var result = {};
cols.forEach(function(col, idx) {
result[colNames[idx]] = col.getText();
result.rowElm = row;
return result;

What would you like to chat about?
Call us at +1-800-225-5224
Call us at +1-800-225-5224
Contact Us