diff --git a/IPython/html/tests/notebook/dualmode.js b/IPython/html/tests/notebook/dualmode.js
index 0c1d0be..8f7d54c 100644
--- a/IPython/html/tests/notebook/dualmode.js
+++ b/IPython/html/tests/notebook/dualmode.js
@@ -269,8 +269,8 @@ casper.notebook_test(function () {
this.select_cell(0);
this.trigger_keydown('a', 'enter'); // Create cell above and enter edit mode.
this.validate_state('a, enter', 'edit', 0);
- this.trigger_keydown('a', 'b', 'c', 'd', 'left', 'left'); // Type 'abcd' and place the cursor in the middle.
- this.validate_state('a, enter', 'edit', 0);
+ this.set_cell_text(0, 'abcd');
+ this.set_cell_editor_cursor(0, 0, 2);
this.test.assertEquals(this.get_cell_text(0), 'abcd', 'Verify that cell 0 has the new contents.');
this.trigger_keydown('alt+-'); // Split
this.test.assertEquals(this.get_cell_text(0), 'ab', 'split; Verify that cell 0 has the first half.');
diff --git a/IPython/html/tests/util.js b/IPython/html/tests/util.js
index eb40b76..2ebf112 100644
--- a/IPython/html/tests/util.js
+++ b/IPython/html/tests/util.js
@@ -246,12 +246,19 @@ casper.click_cell_editor = function(index) {
// the code used in Code Mirror that handles the mousedown event on a
// region of codemirror that the user can focus.
this.evaluate(function (i) {
- cm = IPython.notebook.get_cell(i).code_mirror;
+ var cm = IPython.notebook.get_cell(i).code_mirror;
if (cm.options.readOnly != "nocursor" && (document.activeElement != cm.display.input))
cm.display.input.focus();
}, {i: index});
};
+casper.set_cell_editor_cursor = function(index, line_index, char_index) {
+ // Set the Code Mirror instance cursor's location.
+ this.evaluate(function (i, l, c) {
+ IPython.notebook.get_cell(i).code_mirror.setCursor(l, c);
+ }, {i: index, l: line_index, c: char_index});
+};
+
casper.focus_notebook = function() {
this.evaluate(function (){
$('#notebook').focus();