You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Please see [our TypeScript examples which use `async`/`await`](/exampleTypescript/asyncAwait/).
4
+
**Background**
5
+
6
+
- The Web Driver Control Flow is used to synchronize your commands so they reach
7
+
the browser in the correct order (see
8
+
[/docs/control-flow.md](/docs/control-flow.md) for details). In the future, the
9
+
control flow is being removed (see [SeleniumHQ's github issue](
10
+
https://github.com/SeleniumHQ/selenium/issues/2969) for details). Instead of the
11
+
control flow, you can synchronize your commands with promise chaining or the
12
+
upcoming ES7 feature `async`/`await`.
13
+
14
+
- Previously, we have Typescript support for `async`/`await`: Please see [TypeScript examples which use `async`/`await`](/exampleTypescript/asyncAwait/README.md).
15
+
16
+
- The latest [Node.js](https://nodejs.org/en/) provides native async/await,
17
+
which means we can get stable e2e test without using control flow in javascript test.
18
+
19
+
**Note**: To write and run native async/await test, the node.js version should be greater than or equal to 8.0, and Jasmine version should be greater than or equal to 2.7
20
+
21
+
- If we disable control flow and use async/await to write tests, we can get a
22
+
better debugging experience by using [chrome
23
+
inspector](./debugging.md#disabled-control-flow)
24
+
25
+
**How to use native async/await in test**
26
+
27
+
We have a simple example to show how to use async/await in test.
28
+
29
+
You can find the whole example in
30
+
[here](/debugging/async_await.js)
31
+
32
+
```javascript
33
+
describe('angularjs homepage', function() {
34
+
it('should greet the named user', asyncfunction() {
- Start test processwith a newargument"inspect-brk", which will enable
69
+
inspector agent, listen on default address and port (127.0.0.1:9229) and
70
+
break before user code starts
71
+
72
+
Use
73
+
74
+
```
75
+
node --inspect-brk bin/protractor <config_file>
76
+
```
77
+
78
+
- Open chrome inspector: Enter "chrome://inspect/#devices"in browser, find
79
+
the current running target and click “Inspect”
80
+
81
+

82
+
83
+
- The test will start and pause at the beginning.
84
+
85
+

86
+
87
+
- We can click F8 (resume script execution), and the test will pause at the
88
+
first line that has our “debugger” keyword. We can then add breakpoints and
89
+
debug tests.
90
+
91
+

92
+
93
+
- We can also open chrome development tool on the webdriver controlled browser
94
+
to check the html elements and do some queries while the test execution is
95
+
pausing.
96
+
97
+

98
+
99
+
- Known Issues
100
+
101
+
1. If we resume test execution after a long time pause, it will jump to next
102
+
test case even we have some other breaking points in current test case since
103
+
current test case has already been timeout. You can set
104
+
jasmine.DEFAULT_TIMEOUT_INTERVAL to an arbitrary high value so that your
105
+
test doesn't time out.
106
+
107
+
2. If we step into protractor lib code which was written in Typescript, we
108
+
cannot see the TypeScript code. In general, you can add breakpoints to each
109
+
line that you want it to pause, and use F8 (resume script execution) to
110
+
debug(To avoid step into protractor lib).
111
+
112
+
113
+
**Setting Up VSCode for Debugging**
114
+
115
+
VS Code has built-in [debugging](https://code.visualstudio.com/docs/editor/debugging) support for the Node.js runtime and can debug JavaScript, TypeScript, and any other language that gets transpiled to JavaScript.
116
+
117
+
To set up VSCode for Protractor, follow the below steps:
118
+
119
+
1. Click on the Debugging icon in the View Bar on the side of VS Code.
120
+
2. Click on the Configure gear icon on the Debug view top bar and choose nodejs environment.
121
+
3. It will generate a `launch.json` file under your workspace's `.vscode` folder.
122
+
4. Setup your launch.json file by configuring below two commands:
If you've set the `SELENIUM_PROMISE_MANAGER` config value to false to [disable the control flow](https://github.com/angular/protractor/blob/master/docs/control-flow.md),
155
-
the above methods will not work. Instead, you can now use native `debugger` statements to pause your code. However, you
156
-
will need to start your tests using Node's `--inspect-brk` option:
You will then be able to use the Chrome devtools at chrome://inspect to connect to the tests.
163
-
164
-
165
-
Setting Up VSCode for Debugging
166
-
-------------------------------
167
-
VS Code has built-in [debugging](https://code.visualstudio.com/docs/editor/debugging) support for the Node.js runtime and can debug JavaScript, TypeScript, and any other language that gets transpiled to JavaScript.
168
-
169
-
To set up VSCode for Protractor, follow the below steps:
170
-
171
-
1. Click on the Debugging icon in the View Bar on the side of VS Code.
172
-
2. Click on the Configure gear icon on the Debug view top bar and choose nodejs environment.
173
-
3. It will generate a `launch.json` file under your workspace's `.vscode` folder.
174
-
4. Setup your launch.json file by configuring below two commands:
0 commit comments