Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 2048182

Browse files
authored
docs(timeout): Update timeout error message and docs (#3723)
1 parent e9061b3 commit 2048182

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

docs/faq.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ How do I deal with my log-in page?
3434

3535
If your app needs log-in, there are a couple ways to deal with it. If your login
3636
page is not written with Angular, you'll need to interact with it via
37-
unwrapped webdriver, which can be accessed like `browser.driver.get()`.
37+
unwrapped webdriver, which can be accessed like `browser.driver.get()`. You can also use
38+
`browser.ignoreSynchronization` as explained [here](/docs/timeouts.md#how-to-disable-waiting-for-angular).
3839

39-
You can put your log-in code into an `onPrepare` function, which will be run
40+
Another option is to put your log-in code into an `onPrepare` function, which will be run
4041
once before any of your tests. See this example ([withLoginConf.js](https://github.com/angular/protractor/blob/master/spec/withLoginConf.js))
4142

4243
Which browsers are supported?
@@ -165,10 +166,6 @@ var remote = require('selenium-webdriver/remote');
165166
browser.setFileDetector(new remote.FileDetector());
166167
```
167168

168-
Why is browser.debugger(); not pausing the test?
169-
-----------------------------------------------
170-
The most likely reason is that you are not running the test in debug mode. To do this you run: `protractor debug` followed by the path to your protractor configuration file.
171-
172169
I get an error: Page reload detected during async script. What does this mean?
173170
------------------------------------------------------------------------------
174171
This means that there was a navigation or reload event while a command was pending

docs/timeouts.md

+22-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Because WebDriver tests are asynchronous and involve many components, there are
66
Timeouts from Protractor
77
------------------------
88

9-
**Waiting for Page to Load**
9+
### Waiting for Page to Load
1010

1111
When navigating to a new page using `browser.get`, Protractor waits for the page to
1212
be loaded and the new URL to appear before continuing.
@@ -17,48 +17,51 @@ be loaded and the new URL to appear before continuing.
1717

1818
- How to change: To change globally, add `getPageTimeout: timeout_in_millis` to your Protractor configuration file. For an individual call to `get`, pass an additional parameter: `browser.get(address, timeout_in_millis)`
1919

20-
**Waiting for Page Synchronization**
20+
### Waiting for Angular
2121

22-
Before performing any action, Protractor asks Angular to wait until the page is synchronized. This means that all timeouts and http requests are finished. If your application continuously polls $timeout or $http, it will
23-
never be registered as completely loaded. You should use the
24-
$interval service ([interval.js](https://github.com/angular/angular.js/blob/master/src/ng/interval.js)) for anything that polls continuously (introduced in Angular 1.2rc3).
22+
Before performing any action, Protractor waits until there are no pending asynchronous tasks in your Angular application. This means that all timeouts and http requests are finished. If your application continuously polls $timeout or $http, Protractor will wait indefinitely and time out. You should use the
23+
[$interval](https://github.com/angular/angular.js/blob/master/src/ng/interval.js) for anything that polls continuously (introduced in Angular 1.2rc3).
2524

26-
- Looks like: an error in your test results - `Timed out waiting for Protractor to synchronize with the page after 11 seconds.`
25+
You can also disable waiting for angular, [see below](#how-to-disable-waiting-for-angular).
26+
27+
- Looks like: an error in your test results - `Timed out waiting for asynchronous Angular tasks to finish after 11 seconds.`
2728

2829
- Default timeout: 11 seconds
2930

3031
- How to change: Add `allScriptsTimeout: timeout_in_millis` to your Protractor configuration file.
3132

32-
**Waiting for Angular**
33+
### Waiting for Angular on Page Load
3334

34-
Protractor only works with Angular applications, so it waits for the `angular` variable to be present when it is loading a new page.
35+
Protractor waits for the `angular` variable to be present when loading a new page.
3536

3637
- Looks like: an error in your test results - `Angular could not be found on the page: retries looking for angular exceeded`
3738

3839
- Default timeout: 10 seconds
3940

4041
- How to change: To change globally, add `getPageTimeout: timeout_in_millis` to your Protractor configuration file. For an individual call to `get`, pass an additional parameter: `browser.get(address, timeout_in_millis)`
4142

42-
_*How to disable waiting for Angular*_
43+
### _How to disable waiting for Angular_
4344

4445
If you need to navigate to a page which does not use Angular, you can turn off waiting for Angular by setting
4546
`browser.ignoreSynchronization = true`. For example:
4647

4748
```js
48-
browser.get('page-containing-angular');
49-
navigateToVanillaPage.click();
5049
browser.ignoreSynchronization = true;
51-
otherButton.click();
52-
navigateToAngularPage.click();
50+
browser.get('/non-angular-login-page.html');
51+
52+
element(by.id('username')).sendKeys('Jane');
53+
element(by.id('password')).sendKeys('1234');
54+
element(by.id('clickme')).click();
55+
5356
browser.ignoreSynchronization = false;
57+
browser.get('/page-containing-angular.html');
5458
```
5559

5660

57-
5861
Timeouts from WebDriver
5962
-----------------------
6063

61-
**Asynchronous Script Timeout**
64+
### Asynchronous Script Timeout
6265

6366
Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.
6467

@@ -72,7 +75,7 @@ Sets the amount of time to wait for an asynchronous script to finish execution b
7275
Timeouts from Jasmine
7376
---------------------
7477

75-
**Spec Timeout**
78+
### Spec Timeout
7679

7780
If a spec (an 'it' block) takes longer than the Jasmine timeout for any reason, it will fail.
7881

@@ -87,7 +90,7 @@ Timeouts from Sauce Labs
8790
------------------------
8891
If you are using Sauce Labs, there are a couple additional ways your test can time out. See [Sauce Labs Timeouts Documentation](https://docs.saucelabs.com/reference/test-configuration/#timeouts) for more information.
8992

90-
**Maximum Test Duration**
93+
### Maximum Test Duration
9194

9295
Sauce Labs limits the maximum total duration for a test.
9396

@@ -97,7 +100,7 @@ Sauce Labs limits the maximum total duration for a test.
97100

98101
- How to change: Edit the "max-duration" key in the capabilities object.
99102

100-
**Command Timeout**
103+
### Command Timeout
101104

102105
As a safety measure to prevent Selenium crashes from making your tests run indefinitely, Sauce limits how long Selenium can take to run a command in browsers. This is set to 300 seconds by default.
103106

@@ -107,7 +110,7 @@ As a safety measure to prevent Selenium crashes from making your tests run indef
107110

108111
- How to change: Edit the "command-timeout" key in the capabilities object.
109112

110-
**Idle Timeout**
113+
### Idle Timeout
111114

112115
As a safety measure to prevent tests from running too long after something has gone wrong, Sauce limits how long a browser can wait for a test to send a new command. This is set to 90 seconds by default. You can adjust this limit on a per-job basis.
113116

lib/browser.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,10 @@ export class ProtractorBrowser extends Webdriver {
491491
timeout = /-?[\d\.]*\ ms/.exec(err.message);
492492
}
493493
if (timeout) {
494-
let errMsg = 'Timed out waiting for Protractor to synchronize with ' +
495-
'the page after ' + timeout + '. Please see ' +
496-
'https://github.com/angular/protractor/blob/master/docs/faq.md';
494+
let errMsg = `Timed out waiting for asynchronous Angular tasks to finish after ` +
495+
`${timeout}. This may be because the current page is not an Angular ` +
496+
`application. Please see the FAQ for more details: ` +
497+
`https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular`;
497498
if (description.indexOf(' - Locator: ') == 0) {
498499
errMsg += '\nWhile waiting for element with locator' + description;
499500
}

scripts/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeout
138138
executor.addCommandlineTest('node built/cli.js spec/angular2TimeoutConf.js')
139139
.expectExitCode(1)
140140
.expectErrors([
141-
{message: 'Timed out waiting for Protractor to synchronize with the page'},
141+
{message: 'Timed out waiting for asynchronous Angular tasks to finish'},
142142
]);
143143

144144
executor.execute();

0 commit comments

Comments
 (0)