diff --git a/IPython/html/tests/notebook/dualmode.js b/IPython/html/tests/notebook/dualmode.js
index c540cfe..8d232a1 100644
--- a/IPython/html/tests/notebook/dualmode.js
+++ b/IPython/html/tests/notebook/dualmode.js
@@ -15,8 +15,13 @@ casper.notebook_test(function () {
this.execute_cell_then(index);
this.then(function () {
+ // When running in xvfb, the Slimer window doesn't always have focus
+ // immediately. By clicking on a new element on the page we ccan force
+ // it to gain focus.
this.click_cell_editor(1);
this.click_cell_editor(0);
+
+ this.validate_notebook_state('initial state', 'edit', 0);
this.trigger_keydown('esc');
this.validate_notebook_state('esc', 'command', 0);
this.trigger_keydown('down');