From 51fa2fc256cdb74d7388723ddbe5d44ac45ef71e 2014-01-29 22:37:00 From: MinRK Date: 2014-01-29 22:37:00 Subject: [PATCH] add wait_for_output(cell, index) so you can wait for at least n outputs --- diff --git a/IPython/html/tests/casperjs/util.js b/IPython/html/tests/casperjs/util.js index d8da2da..8abf656 100644 --- a/IPython/html/tests/casperjs/util.js +++ b/IPython/html/tests/casperjs/util.js @@ -57,15 +57,18 @@ casper.delete_current_notebook = function () { }); }; -// wait for output in a given cell -casper.wait_for_output = function (cell_num) { - this.waitFor(function (c) { - return this.evaluate(function get_output(c) { - var cell = IPython.notebook.get_cell(c); - return cell.output_area.outputs.length != 0; - }, - // pass parameter from the test suite js to the browser code js - {c : cell_num}); +// wait for the nth output in a given cell +casper.wait_for_output = function (cell_num, out_num) { + out_num = out_num || 0; + this.then(function() { + this.waitFor(function (c, o) { + return this.evaluate(function get_output(c, o) { + var cell = IPython.notebook.get_cell(c); + return cell.output_area.outputs.length > o; + }, + // pass parameter from the test suite js to the browser code js + {c : cell_num, o : out_num}); + }); }, function then() { }, function timeout() {