1
1
// Copyright (c) Jupyter Development Team.
2
2
// Distributed under the terms of the Modified BSD License.
3
-
3
+ var Promise = require ( 'bluebird' ) ;
4
4
var wd = require ( 'wd' ) ;
5
5
require ( 'colors' ) ;
6
6
var chai = require ( 'chai' ) ;
@@ -75,7 +75,7 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
75
75
function ( target ) { // browser or el
76
76
return target
77
77
. elementsByCssSelector ( 'div.output_area' ) . then ( function ( nodes ) {
78
- console . log ( nodes . length + "/" + outputCount )
78
+ console . log ( "output areas visible: " , nodes . length , "/" , outputCount )
79
79
nodes . should . have . length . above ( outputCount - 1 ) ;
80
80
return target ; // this will be returned by waitFor
81
81
// and ignored by waitForElement.
@@ -101,22 +101,42 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
101
101
var kernelStartTimeout = 200000 ;
102
102
var defaultTimeout = 10000 ;
103
103
var runAllCompletionTimeout = 50000 ;
104
+
105
+ function clickTheElement ( element ) {
106
+ return new Promise ( function ( resolve ) {
107
+ var newElement = element . click ( )
108
+ . elementByLinkText ( "<" , "Cell" )
109
+ . click ( )
110
+ . waitForElementByLinkText ( "Run Cells" , wd . asserters . isDisplayed , 10000 )
111
+ . elementByLinkText ( "Run Cells" )
112
+ . click ( )
113
+ . sleep ( 5000 ) ;
114
+ resolve ( newElement ) ;
115
+ } ) ;
116
+ }
117
+
118
+ function runAllCells ( elements , idx ) {
119
+ if ( idx > elements . length - 1 ) {
120
+ return ;
121
+ }
122
+
123
+ var element = elements [ idx ] ;
124
+ clickTheElement ( element ) . then ( function ( elem ) {
125
+ console . log ( "running cell: " , idx ) ;
126
+ runAllCells ( elements , idx + 1 ) ;
127
+ } )
128
+ }
129
+
104
130
this . browser . init ( desired )
105
131
. get ( startingURL || '/' )
106
132
. waitForElementByCssSelector ( "#kernel_indicator_icon.kernel_idle_icon" , wd . asserters . isDisplayed , kernelStartTimeout )
107
- . waitForElementByLinkText ( "Cell" , wd . asserters . isDisplayed , defaultTimeout )
108
- . elementByLinkText ( "Cell" )
109
- . click ( )
110
- . waitForElementByLinkText ( "Run All" , wd . asserters . isDisplayed , defaultTimeout )
111
- . elementByLinkText ( "Run All" )
112
- . click ( )
133
+ . elementsByCssSelector ( 'div.input' ) . then ( function ( elements ) {
134
+ runAllCells ( elements , 0 ) ;
135
+ } )
136
+ . waitFor ( outputAsserter , runAllCompletionTimeout * 5 , 1000 )
113
137
. eval ( "!!document.body.createShadowRoot" , function ( err , value ) {
114
138
this . browserSupportsShadowDOM = value ;
115
139
} . bind ( this ) )
116
- . waitForElementByCssSelector ( 'div.output_area' , wd . asserters . isDisplayed , defaultTimeout )
117
- . elementByCssSelector ( 'div.code_cell .input' ) . click ( ) // to keep the first code cell in view on sauce
118
- . waitFor ( outputAsserter , runAllCompletionTimeout , 1000 )
119
- . sleep ( defaultTimeout * 2 ) //FIXME: shouldn't need this?
120
140
. nodeify ( done ) ;
121
141
} . bind ( this ) ) ;
122
142
0 commit comments