This repository was archived by the owner on Jul 29, 2024. It is now read-only.
File tree 5 files changed +39
-5
lines changed
5 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,26 @@ describe('timeout possibilities', function() {
29
29
expect ( true ) . toEqual ( true ) ;
30
30
} ) ;
31
31
32
+ describe ( 'waitForAngular' , function ( ) {
33
+ it ( 'should timeout and give a reasonable message' , function ( ) {
34
+
35
+ ptor . driver . manage ( ) . timeouts ( ) . setScriptTimeout ( 55 ) ;
36
+
37
+ ptor . get ( 'app/index.html#/async' ) ;
38
+
39
+
40
+ var status =
41
+ ptor . findElement ( protractor . By . binding ( 'slowHttpStatus' ) ) ;
42
+ var button = ptor . findElement ( protractor . By . css ( '[ng-click="slowHttp()"]' ) ) ;
43
+
44
+ expect ( status . getText ( ) ) . toEqual ( 'not started' ) ;
45
+
46
+ button . click ( ) ;
47
+
48
+ expect ( status . getText ( ) ) . toEqual ( 'done' ) ;
49
+ } , 5000 ) ; // The 5000 here sets the Jasmine spec timeout.
50
+ } ) ;
51
+
32
52
it ( 'should timeout due to Jasmine spec timeout' , function ( ) {
33
53
ptor . driver . sleep ( 1000 ) ;
34
54
expect ( true ) . toBe ( true ) ;
Original file line number Diff line number Diff line change @@ -104,8 +104,14 @@ Jasmine tests have a timeout which can be set
104
104
` it('should pass', function() {...}, 5555); `
105
105
106
106
Webdriver has a timeout for script execution, which can be set with
107
- ` driver.manage().timeouts().setScriptTimeout ` . Protractor sets this to 100
108
- seconds by default, so usually Jasmine will time out first.
107
+ ` driver.manage().timeouts().setScriptTimeout ` . Protractor sets this to 5
108
+ seconds by default.
109
+
110
+ Protractor attempts to synchronize with your page before performing actions.
111
+ This means waiting for all $timeout or $http requests to resolve, as well as
112
+ letting the current $digest cycle finish. If your page has not synchronized
113
+ within the script execution timeout, Protractor will fail with the message
114
+ 'Timed out waiting for Protractor to synchronize with the page'.
109
115
110
116
If your website uses $timeout or $http to continuously poll, Protractor will
111
117
interpret that as your site being busy and will time out on all requests. See
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ var startJasmineTests = function() {
146
146
withCapabilities ( config . capabilities ) . build ( ) ;
147
147
148
148
driver . getSession ( ) . then ( function ( session ) {
149
- driver . manage ( ) . timeouts ( ) . setScriptTimeout ( 100000 ) ;
149
+ driver . manage ( ) . timeouts ( ) . setScriptTimeout ( 5000 ) ;
150
150
151
151
id = session . getId ( ) ;
152
152
Original file line number Diff line number Diff line change @@ -108,7 +108,15 @@ Protractor.prototype.waitForAngular = function() {
108
108
return webdriver . promise . fulfilled ( ) ;
109
109
}
110
110
return this . driver . executeAsyncScript (
111
- clientSideScripts . waitForAngular , this . rootEl ) ;
111
+ clientSideScripts . waitForAngular , this . rootEl ) . then ( null , function ( err ) {
112
+ console . log ( 'Error was: ' + util . inspect ( err ) ) ;
113
+ if ( ! / a s y n c h r o n o u s s c r i p t t i m e o u t / . test ( err . message ) ) {
114
+ throw err ;
115
+ }
116
+ var timeout = / [ \d \. ] * \ s e c o n d s / . exec ( err . message ) ;
117
+ throw 'Timed out waiting for Protractor to synchronize with ' +
118
+ 'the page after ' + timeout ;
119
+ } ) ;
112
120
} ;
113
121
114
122
// TODO: activeelement also returns a WebElement.
Original file line number Diff line number Diff line change @@ -82,6 +82,6 @@ exports.config = {
82
82
// If true, include stack traces in failures.
83
83
includeStackTrace : true ,
84
84
// Default time to wait in ms before a test fails.
85
- defaultTimeoutInterval : 5000
85
+ defaultTimeoutInterval : 30000
86
86
}
87
87
} ;
You can’t perform that action at this time.
0 commit comments