CasperJS sometimes adds an empty second row with row.add(myRowData)
CasperJS sometimes adds an empty second row with row.add(myRowData)
Hello there!
I'm currently running frontend tests with CasperJS but every now and then Casper manages to add a second empty row without any data. The correct row (with data) is added too!
What Casper is supposed to do:
- fill in 2 text fields (MyText1 and MyText2)
- click on a checkbox
- click the "Add" button (uses
row().add()
, see below) - click the "Save" button (fails sometimes, see below)
The "Add" button reads the input fields, saves the values in myRowData and adds a row. If one of the text fields is empty or the checkbox is not checked, an error occurs and the row won't be added.
var myRowData = {
"mytext1": $("#text1").val(),
"mytext2": $("#text2").val(),
"mycheckbox": $("#checkbox").is(":checked"),
}
someTable().row.add(myRowData)
.order( [[ 0, 'asc' ]])
.draw();
The "Save" button saves everything but checks first if the data in the table is correct e.g. not empty/no empty rows. That's where Casper fails because Casper successfully adds the row including the data to the table and also an empty row (even though it shouldn't be possible), adding
--verbose --log-level=debug
to the casperjs command gives me this error:
[info] [remote] [alert] DataTables warning: table id=my-table-id - Requested unknown parameter 'mycolumn1' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
So Casper can successfully fill in the fields and click the "Add" button but every 100th or 200th test (as I said: sometimes) there's an empty row I can't get rid of.
Any help appreciated and many thanks in advance!
Answers
yeah this code working properly.
Ethan wilson
edited by Allan removed link. Suspected spam, but not as obvious as many...
Nothing immediately springs to mind I'm afraid. Could you add:
prior to the
row.add()
call? From what you say it should be 0 most of the time, but 1 every now and then - I think. If it is zero even when the test fails, it suggests there is some other code also adding a row - perhaps an async action from another test?Allan