Created
June 19, 2015 10:59
-
-
Save jossef/f12e5ea1ac4fc561d9be 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
| 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(); |
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
| '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