diff --git a/IPython/html/tests/casperjs/test_cases/check_interrupt.js b/IPython/html/tests/casperjs/test_cases/check_interrupt.js
index 980583a..643b27f 100644
--- a/IPython/html/tests/casperjs/test_cases/check_interrupt.js
+++ b/IPython/html/tests/casperjs/test_cases/check_interrupt.js
@@ -15,11 +15,8 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
- var result = this.evaluate(function () {
- var cell = IPython.notebook.get_cell(0);
- return cell.output_area.outputs[0].ename;
- })
- this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
+ var result = this.get_output_cell(0);
+ this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (mouseclick)');
});
// run cell 0 again, now interrupting using keyboard shortcut
@@ -36,10 +33,7 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
- var result = this.evaluate(function () {
- var cell = IPython.notebook.get_cell(0);
- return cell.output_area.outputs[0].ename;
- });
- this.test.assertEquals(result, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
+ var result = this.get_output_cell(0);
+ this.test.assertEquals(result.ename, 'KeyboardInterrupt', 'keyboard interrupt (shortcut)');
});
});
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 c962f0b..16203a0 100644
--- a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js
+++ b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js
@@ -10,13 +10,10 @@ casper.notebook_test(function () {
this.wait_for_output(0);
+ // refactor this into just a get_output(0)
this.then(function () {
- var result = this.evaluate(function () {
- var cell = IPython.notebook.get_cell(0);
- var output = cell.output_area.outputs[0].text;
- return output;
- })
- this.test.assertEquals(result, '10\n', 'cell execute (using js)')
+ var result = this.get_output_cell(0);
+ this.test.assertEquals(result.text, '10\n', 'cell execute (using js)')
});
@@ -31,12 +28,8 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
- var result = this.evaluate(function () {
- var cell = IPython.notebook.get_cell(0);
- var output = cell.output_area.outputs[0].text;
- return output;
- })
- this.test.assertEquals(result, '11\n', 'cell execute (using ctrl-enter)')
+ var result = this.get_output_cell(0);
+ this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)')
});
// do it again with the keyboard shortcut
@@ -50,11 +43,7 @@ casper.notebook_test(function () {
this.wait_for_output(0);
this.then(function () {
- var result = this.evaluate(function () {
- var cell = IPython.notebook.get_cell(0);
- var output = cell.output_area.outputs[0].text;
- return output;
- })
- this.test.assertEquals(result, '12\n', 'cell execute (using shift-enter)')
+ var result = this.get_output_cell(0);
+ this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)')
});
});
diff --git a/IPython/html/tests/casperjs/util.js b/IPython/html/tests/casperjs/util.js
index 87feeb6..b3ca357 100644
--- a/IPython/html/tests/casperjs/util.js
+++ b/IPython/html/tests/casperjs/util.js
@@ -68,6 +68,16 @@ casper.wait_for_output = function (cell_num) {
});
};
+// return the output of a given cell
+casper.get_output_cell = function (cell_num) {
+ var result = casper.evaluate(function (c) {
+ var cell = IPython.notebook.get_cell(c);
+ return cell.output_area.outputs[0];
+ },
+ {c : cell_num});
+ return result;
+};
+
// Wrap a notebook test to reduce boilerplate.
casper.notebook_test = function(test) {
this.open_new_notebook();