Skip to content

Instantly share code, notes, and snippets.

@jossef
Created June 19, 2015 10:59
Show Gist options
  • Select an option

  • Save jossef/f12e5ea1ac4fc561d9be to your computer and use it in GitHub Desktop.

Select an option

Save jossef/f12e5ea1ac4fc561d9be to your computer and use it in GitHub Desktop.
var Table = require("./table");
var async = require('asyncawait/async');
var await = require('asyncawait/await');
async(function () {
var table = Table({});
var index = 123;
var row = await(table.row(index));
// do something with row ...
console.log(row);
})();
console.log();
'use strict';
var Q = require("q");
var Row = require("./row");
var Table = function (tableElement) {
var headElement = tableElement.element(by.css('thead'));
var bodyElement = tableElement.element(by.css('tbody'));
this.row = function (index) {
var def = Q.defer();
var result = headElement
.all(by.css('th'))
.map(function (th) {
return th.getAttribute('class');
})
.then(function (clazzes) {
var rows = bodyElement.all(by.css('tr'));
var row = new Row(rows.get(index), clazzes);
def.resolve(row);
});
return def.promise;
};
};
module.exports = Table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment