Skip to content

Instantly share code, notes, and snippets.

@CaseyHaralson
Last active February 12, 2016 03:38
Show Gist options
  • Save CaseyHaralson/7153be9f437f4e3a7f5c to your computer and use it in GitHub Desktop.
Save CaseyHaralson/7153be9f437f4e3a7f5c to your computer and use it in GitHub Desktop.
var currentPage = 0;
var promises = [];
var nextPage;
element.all(by.css('#tableid td')).then(function (pages) {
for (var i = 0; i < pages.length; i++) {
var page = pages[i];
var deferred = protractor.promise.defer();
promises.push(deferred.promise);
page.getInnerHtml().then(function (html) {
if (html.indexOf('<span>') > -1) {
currentPage = parseInt(html.replace('<span>', '').replace('</span>', ''));
}
page.getText().then(function (text) {
if (currentPage != 0 && parseInt(text) == currentPage + 1) {
nextPage = page;
}
deferred.fulfill(true);
});
});
return protractor.promise.all(promises);
}).then(function () {
var test = ''; //won't make it here
// I assume if it did that I could then click on "nextPage" a element
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment