##// END OF EJS Templates
add utils.wait_for_idle in js tests...
MinRK -
Show More
@@ -30,6 +30,15 b' casper.open_new_notebook = function () {'
30 this.waitForSelector('.CodeMirror-code');
30 this.waitForSelector('.CodeMirror-code');
31 // and make sure the kernel has started
31 // and make sure the kernel has started
32 this.waitFor( this.kernel_running );
32 this.waitFor( this.kernel_running );
33 // track the IPython busy/idle state
34 this.thenEvaluate(function () {
35 $([IPython.events]).on('status_idle.Kernel',function () {
36 IPython._status = 'idle';
37 });
38 $([IPython.events]).on('status_busy.Kernel',function () {
39 IPython._status = 'busy';
40 });
41 });
33 };
42 };
34
43
35 // return whether or not the kernel is running
44 // return whether or not the kernel is running
@@ -57,8 +66,19 b' casper.delete_current_notebook = function () {'
57 });
66 });
58 };
67 };
59
68
69 casper.wait_for_idle = function () {
70 this.then(function () {
71 this.waitFor(function () {
72 return this.evaluate(function () {
73 return IPython._status == 'idle';
74 });
75 });
76 });
77 };
78
60 // wait for the nth output in a given cell
79 // wait for the nth output in a given cell
61 casper.wait_for_output = function (cell_num, out_num) {
80 casper.wait_for_output = function (cell_num, out_num) {
81 this.wait_for_idle();
62 out_num = out_num || 0;
82 out_num = out_num || 0;
63 this.then(function() {
83 this.then(function() {
64 this.waitFor(function (c, o) {
84 this.waitFor(function (c, o) {
@@ -111,7 +131,7 b' casper.set_cell_text = function(index, text){'
111 this.evaluate(function (index, text) {
131 this.evaluate(function (index, text) {
112 var cell = IPython.notebook.get_cell(index);
132 var cell = IPython.notebook.get_cell(index);
113 cell.set_text(text);
133 cell.set_text(text);
114 }, index, text);
134 }, index, text);
115 };
135 };
116
136
117 // Inserts a cell at the bottom of the notebook
137 // Inserts a cell at the bottom of the notebook
@@ -124,7 +144,7 b' casper.insert_cell_at_bottom = function(cell_type){'
124 return this.evaluate(function (cell_type) {
144 return this.evaluate(function (cell_type) {
125 var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
145 var cell = IPython.notebook.insert_cell_at_bottom(cell_type);
126 return IPython.notebook.find_cell_index(cell);
146 return IPython.notebook.find_cell_index(cell);
127 }, cell_type);
147 }, cell_type);
128 };
148 };
129
149
130 // Insert a cell at the bottom of the notebook and set the cells text.
150 // Insert a cell at the bottom of the notebook and set the cells text.
@@ -145,7 +165,7 b' casper.execute_cell = function(index){'
145 that.evaluate(function (index) {
165 that.evaluate(function (index) {
146 var cell = IPython.notebook.get_cell(index);
166 var cell = IPython.notebook.get_cell(index);
147 cell.execute();
167 cell.execute();
148 }, index);
168 }, index);
149 });
169 });
150 return index;
170 return index;
151 };
171 };
@@ -157,7 +177,7 b' casper.execute_cell = function(index){'
157 casper.execute_cell_then = function(index, then_callback) {
177 casper.execute_cell_then = function(index, then_callback) {
158 var return_val = this.execute_cell(index);
178 var return_val = this.execute_cell(index);
159
179
160 this.wait_for_output(index);
180 this.wait_for_idle();
161
181
162 var that = this;
182 var that = this;
163 this.then(function(){
183 this.then(function(){
General Comments 0
You need to be logged in to leave comments. Login now