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,17 b' casper.delete_current_notebook = function () {' | |||||
57 | }); |
|
66 | }); | |
58 | }; |
|
67 | }; | |
59 |
|
68 | |||
|
69 | casper.wait_for_idle = function () { | |||
|
70 | this.waitFor(function () { | |||
|
71 | return this.evaluate(function () { | |||
|
72 | return IPython._status == 'idle'; | |||
|
73 | }); | |||
|
74 | }); | |||
|
75 | }; | |||
|
76 | ||||
60 | // wait for the nth output in a given cell |
|
77 | // wait for the nth output in a given cell | |
61 | casper.wait_for_output = function (cell_num, out_num) { |
|
78 | casper.wait_for_output = function (cell_num, out_num) { | |
|
79 | this.wait_for_idle(); | |||
62 | out_num = out_num || 0; |
|
80 | out_num = out_num || 0; | |
63 | this.then(function() { |
|
81 | this.then(function() { | |
64 | this.waitFor(function (c, o) { |
|
82 | this.waitFor(function (c, o) { | |
@@ -111,7 +129,7 b' casper.set_cell_text = function(index, text){' | |||||
111 | this.evaluate(function (index, text) { |
|
129 | this.evaluate(function (index, text) { | |
112 | var cell = IPython.notebook.get_cell(index); |
|
130 | var cell = IPython.notebook.get_cell(index); | |
113 | cell.set_text(text); |
|
131 | cell.set_text(text); | |
114 |
}, index, text); |
|
132 | }, index, text); | |
115 | }; |
|
133 | }; | |
116 |
|
134 | |||
117 | // Inserts a cell at the bottom of the notebook |
|
135 | // Inserts a cell at the bottom of the notebook | |
@@ -124,7 +142,7 b' casper.insert_cell_at_bottom = function(cell_type){' | |||||
124 | return this.evaluate(function (cell_type) { |
|
142 | return this.evaluate(function (cell_type) { | |
125 | var cell = IPython.notebook.insert_cell_at_bottom(cell_type); |
|
143 | var cell = IPython.notebook.insert_cell_at_bottom(cell_type); | |
126 | return IPython.notebook.find_cell_index(cell); |
|
144 | return IPython.notebook.find_cell_index(cell); | |
127 |
}, cell_type); |
|
145 | }, cell_type); | |
128 | }; |
|
146 | }; | |
129 |
|
147 | |||
130 | // Insert a cell at the bottom of the notebook and set the cells text. |
|
148 | // Insert a cell at the bottom of the notebook and set the cells text. | |
@@ -145,7 +163,7 b' casper.execute_cell = function(index){' | |||||
145 | that.evaluate(function (index) { |
|
163 | that.evaluate(function (index) { | |
146 | var cell = IPython.notebook.get_cell(index); |
|
164 | var cell = IPython.notebook.get_cell(index); | |
147 | cell.execute(); |
|
165 | cell.execute(); | |
148 |
}, index); |
|
166 | }, index); | |
149 | }); |
|
167 | }); | |
150 | return index; |
|
168 | return index; | |
151 | }; |
|
169 | }; | |
@@ -157,7 +175,7 b' casper.execute_cell = function(index){' | |||||
157 | casper.execute_cell_then = function(index, then_callback) { |
|
175 | casper.execute_cell_then = function(index, then_callback) { | |
158 | var return_val = this.execute_cell(index); |
|
176 | var return_val = this.execute_cell(index); | |
159 |
|
177 | |||
160 |
this.wait_for_ |
|
178 | this.wait_for_idle(); | |
161 |
|
179 | |||
162 | var that = this; |
|
180 | var that = this; | |
163 | this.then(function(){ |
|
181 | this.then(function(){ |
General Comments 0
You need to be logged in to leave comments.
Login now