Testing DataTables with CasperJS
Testing DataTables with CasperJS
ve7tcc
Posts: 25Questions: 8Answers: 0
Anyone trying testing DataTables with CasperJS ?
I have some tables with server side / ajax, and trying to do some kind of casper.waitFor() to catch when the table has been reloaded. If you have had any luck with that, what were you looking for?
Example: I've been trying to filter the data and count the rows returned to see if something exists or not.
this.fillSelectors('form#RESULT_FILTERS_EXP_CLIENT', {
'input[type="search"]': testClient
}, false);
this.waitForText('No data available', function() {
test.assertTextExists('No data available in table', 'Confirmed that ' + testClient + ' does not exist');
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Perhaps you could wait for the
init
event before checking the DOM? I haven't used CasperJS myself I'm afraid, doeswaitForText
just keep polling the document?Allan
I am not sure how waitForText() is implemented under the hood in CasperJS.
I got something to work, I used waitForResource() to wait for the ajax response to come back, and added a half second after that.
So, this test, enters the name of a test client into the search box, which triggers an ajax/serverside request. The waitForResource() catches the response, and the assertTextExists() checks that there is no match.
By the way for DataTables server side, when there is no match you get
and when it is not server side, you get
"No data available in table" is
language.emptyTable
and is shown when there is no data at all."No matching records found" is
language.zeroRecords
and is shown when there is data in the table, but the filtering applied to the table has removed it all.In the case of server-side processing,
emptyTable
is used if therecordsTotal
property is returned as 0.Allan