|
1 | 1 | The Webdriver Control Flow |
2 | 2 | ========================== |
3 | 3 |
|
4 | | -The WebDriverJS API is based on promises, which are managed by a control flow. |
5 | | -I highly recommend reading the [WebDriverJS documentation](https://code.google.com/p/selenium/wiki/WebDriverJs#Understanding_the_API) |
6 | | -on this topic. A short summary, and how Protractor interacts with the control |
7 | | -flow, is presented below. |
| 4 | +The WebDriverJS API is based on [promises](https://code.google.com/p/selenium/wiki/WebDriverJs#Promises), |
| 5 | +which are managed by a [control flow](https://code.google.com/p/selenium/wiki/WebDriverJs#Control_Flows) |
| 6 | +and adapated for [Jasmine](http://jasmine.github.io/1.3/introduction.html). |
| 7 | +A short summary about how Protractor interacts with the control flow is presented below. |
| 8 | + |
8 | 9 |
|
9 | 10 | Promises and the Control Flow |
10 | 11 | ----------------------------- |
11 | 12 |
|
12 | 13 | WebDriverJS (and thus, Protractor) APIs are entirely asynchronous. All functions |
13 | | -return [promises](https://code.google.com/p/selenium/wiki/WebDriverJs#Promises). |
| 14 | +return promises. |
14 | 15 |
|
15 | 16 | WebDriverJS maintains a queue of pending promises, called the control flow, |
16 | | -to keep execution organized. For example, consider the test |
| 17 | +to keep execution organized. For example, consider this test: |
17 | 18 |
|
18 | 19 | ```javascript |
19 | 20 | it('should find an element by text input model', function() { |
@@ -44,12 +45,10 @@ Protractor adapts Jasmine so that each spec automatically waits until the |
44 | 45 | control flow is empty before exiting. This means you don't need to worry |
45 | 46 | about calling runs() and waitsFor() blocks. |
46 | 47 |
|
47 | | -Jasmine expectations are also adapted to understand promises. That's why |
48 | | -the line |
| 48 | +Jasmine expectations are also adapted to understand promises. That's why this |
| 49 | +line works - the code actually adds an expectation task to the control flow, |
| 50 | +which will run after the other tasks: |
49 | 51 |
|
50 | 52 | ```javascript |
51 | 53 | expect(name.getText()).toEqual('Jane Doe'); |
52 | 54 | ``` |
53 | | - |
54 | | -works - this code actually adds an expectation task to the control flow, |
55 | | -which will run after the other tasks. |
0 commit comments