diff --git a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js index 4ba8356..c962f0b 100644 --- a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js +++ b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js @@ -8,12 +8,7 @@ casper.notebook_test(function () { cell.execute(); }); - this.waitFor(function () { - return this.evaluate(function get_output() { - var cell = IPython.notebook.get_cell(0); - return cell.output_area.outputs.length != 0; - }) - }); + this.wait_for_output(0); this.then(function () { var result = this.evaluate(function () { @@ -33,12 +28,7 @@ casper.notebook_test(function () { IPython.utils.press_ctrl_enter(); }); - this.waitFor(function () { - return this.evaluate(function get_output() { - var cell = IPython.notebook.get_cell(0); - return cell.output_area.outputs.length != 0; - }) - }); + this.wait_for_output(0); this.then(function () { var result = this.evaluate(function () { @@ -57,12 +47,7 @@ casper.notebook_test(function () { IPython.utils.press_shift_enter(); }); - this.waitFor(function () { - return this.evaluate(function get_output() { - var cell = IPython.notebook.get_cell(0); - return cell.output_area.outputs.length != 0; - }) - }); + this.wait_for_output(0); this.then(function () { var result = this.evaluate(function () { diff --git a/IPython/html/tests/casperjs/util.js b/IPython/html/tests/casperjs/util.js index fc7709d..87feeb6 100644 --- a/IPython/html/tests/casperjs/util.js +++ b/IPython/html/tests/casperjs/util.js @@ -54,6 +54,20 @@ casper.delete_current_notebook = function () { }); }; +// wait for output in a given cell +casper.wait_for_output = function (cell_num) { + this.then(function() { + 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}); + }); + }); +}; + // Wrap a notebook test to reduce boilerplate. casper.notebook_test = function(test) { this.open_new_notebook();