11// Copyright (c) Jupyter Development Team.
22// Distributed under the terms of the Modified BSD License.
3-
3+ var Promise = require ( 'bluebird' ) ;
44var wd = require ( 'wd' ) ;
55require ( 'colors' ) ;
66var chai = require ( 'chai' ) ;
@@ -81,7 +81,7 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
8181 function ( target ) { // browser or el
8282 return target
8383 . elementsByCssSelector ( 'div.output_area' ) . then ( function ( nodes ) {
84- console . log ( nodes . length + "/" + outputCount )
84+ console . log ( "output areas visible: " , nodes . length , "/" , outputCount )
8585 nodes . should . have . length . above ( outputCount - 1 ) ;
8686 return target ; // this will be returned by waitFor
8787 // and ignored by waitForElement.
@@ -107,26 +107,48 @@ Boilerplate.prototype.setup = function(testName, startingURL, outputCount){
107107 var kernelStartTimeout = 200000 ;
108108 var defaultTimeout = 10000 ;
109109 var runAllCompletionTimeout = 50000 ;
110+
111+ function clickTheElement ( element ) {
112+ return new Promise ( function ( resolve ) {
113+ var newElement = element . click ( )
114+ . elementByLinkText ( "<" , "Cell" )
115+ . click ( )
116+ . waitForElementByLinkText ( "Run Cells" , wd . asserters . isDisplayed , 10000 )
117+ . elementByLinkText ( "Run Cells" )
118+ . click ( )
119+ . sleep ( 5000 ) ;
120+ resolve ( newElement ) ;
121+ } ) ;
122+ }
123+
124+ function runAllCells ( elements , idx ) {
125+ if ( idx > elements . length - 1 ) {
126+ return ;
127+ }
128+
129+ var element = elements [ idx ] ;
130+ clickTheElement ( element ) . then ( function ( elem ) {
131+ console . log ( "running cell: " , idx ) ;
132+ runAllCells ( elements , idx + 1 ) ;
133+ } )
134+ }
135+
110136 this . browser . init ( desired )
111137 . get ( startingURL || '/' )
112138 . waitForElementByCssSelector ( "#kernel_indicator_icon.kernel_idle_icon" , wd . asserters . isDisplayed , kernelStartTimeout )
113- . waitForElementByLinkText ( "Cell" , wd . asserters . isDisplayed , defaultTimeout )
114139 . safeExecute ( 'localStorage.clear()' )
115- . elementByLinkText ( "Cell" )
116- . click ( )
117- . waitForElementByLinkText ( "Run All" , wd . asserters . isDisplayed , defaultTimeout )
118- . elementByLinkText ( "Run All" )
119- . click ( )
120- . eval ( '!!document.body.createShadowRoot' , function ( err , value ) {
140+ . waitForElementByCssSelector ( 'div.output_area' , wd . asserters . isDisplayed , defaultTimeout )
141+ . setAsyncScriptTimeout ( 15000 )
142+ . waitForConditionInBrowser ( 'window.Urth && Urth.kernel && Urth.kernel.is_connected()' , defaultTimeout )
143+ . waitForElementByCssSelector ( '#kernel_indicator_icon.kernel_idle_icon' , wd . asserters . isDisplayed , kernelStartTimeout )
144+ . waitForConditionInBrowser ( 'typeof Urth.whenReady === "function"' , kernelStartTimeout )
145+ . elementsByCssSelector ( 'div.input' ) . then ( function ( elements ) {
146+ runAllCells ( elements , 0 ) ;
147+ } )
148+ . waitFor ( outputAsserter , runAllCompletionTimeout * 5 , defaultTimeout )
149+ . eval ( "!!document.body.createShadowRoot" , function ( err , value ) {
121150 this . browserSupportsShadowDOM = value ;
122151 } . bind ( this ) )
123- . waitForElementByCssSelector ( 'div.output_area' , wd . asserters . isDisplayed , 10000 )
124- . setAsyncScriptTimeout ( 15000 )
125- . waitForConditionInBrowser ( 'window.Urth && Urth.kernel && Urth.kernel.is_connected()' , 10000 )
126- . waitForElementByCssSelector ( '#kernel_indicator_icon.kernel_idle_icon' , wd . asserters . isDisplayed , 20000 )
127- . waitForConditionInBrowser ( 'typeof Urth.whenReady === "function"' , 10000 )
128- . elementByCssSelector ( 'div.code_cell .input' ) . click ( ) // to keep the first code cell in view on sauce
129- . waitFor ( outputAsserter , runAllCompletionTimeout , 1000 )
130152 . nodeify ( done ) ;
131153 } . bind ( this ) ) ;
132154
0 commit comments