Last active
August 29, 2015 14:01
-
-
Save oberlies/a854f9af6a84d6a860ea to your computer and use it in GitHub Desktop.
Flip through pages of SAPUI5 table using WebdriverJS
This file contains 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 webdriverjs = require('webdriverjs'); | |
var client = webdriverjs.remote({ desiredCapabilities: {browserName: 'phantomjs', screenResolution: '1024x768'} }); | |
client.init(); | |
function goToLastPage(tableId, currentPage) { | |
client.click('#'+tableId+'-paginator--forwardLink', function(err) { | |
if (err) { | |
if (err.status === 7) { | |
// there is no paginator element so we already are on the last page | |
} else if (err.status === 10) { | |
// workaround for https://github.com/camme/webdriverjs/issues/194 | |
console.log('Click on next page button failed; retrying...'); | |
goToLastPage(tableId, currentPage); | |
} else { | |
// TODO: fail | |
} | |
} else { | |
client.waitFor('#'+tableId+'-paginator-li--' + (currentPage+1) + '.sapUiPagCurrentPage', 1000, function(err) { | |
if (err) { | |
// page didn't change so we reached the last page | |
} else { | |
console.log('Switched to page ' + (currentPage+1)); | |
goToLastPage(tableId, currentPage+1); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment