@@ -19,33 +19,52 @@ var driver, ptor;
19
19
driver . manage ( ) . timeouts ( ) . setScriptTimeout ( 10000 ) ;
20
20
} ( ) ) ;
21
21
22
+ var catchPromiseErrors = function ( done ) {
23
+ webdriver . promise . controlFlow ( ) .
24
+ on ( 'uncaughtException' , function ( e ) {
25
+ done ( e ) ;
26
+ } ) ;
27
+ } ;
28
+
22
29
describe ( 'test application' , function ( ) {
23
30
describe ( 'finding elements in forms' , function ( ) {
24
31
beforeEach ( function ( ) {
25
32
ptor . get ( 'http://localhost:8000/app/index.html#/form' ) ;
26
33
} ) ;
27
34
28
35
it ( 'should find an element by binding' , function ( done ) {
36
+ catchPromiseErrors ( done ) ;
29
37
ptor . findElement ( protractor . By . binding ( '{{greeting}}' ) ) .
30
38
getText ( ) . then ( function ( text ) {
31
39
expect ( text ) . toEqual ( 'Hiya' ) ;
32
40
done ( ) ;
33
41
} ) ;
34
42
} ) ;
35
43
44
+ it ( 'should find an element by binding with attribute' , function ( done ) {
45
+ catchPromiseErrors ( done ) ;
46
+ ptor . findElement ( protractor . By . binding ( 'username' ) ) .
47
+ getText ( ) . then ( function ( text ) {
48
+ expect ( text ) . toEqual ( 'Anon' ) ;
49
+ done ( ) ;
50
+ } ) ;
51
+ } ) ;
52
+
36
53
it ( 'should find an element by text input model' , function ( done ) {
54
+ catchPromiseErrors ( done ) ;
37
55
var username = ptor . findElement ( protractor . By . input ( 'username' ) ) ;
38
56
username . clear ( ) ;
39
57
username . sendKeys ( 'Jane Doe' ) ;
40
58
41
- ptor . findElement ( protractor . By . binding ( '{{ username}} ' ) ) .
59
+ ptor . findElement ( protractor . By . binding ( 'username' ) ) .
42
60
getText ( ) . then ( function ( text ) {
43
61
expect ( text ) . toEqual ( 'Jane Doe' ) ;
44
62
done ( ) ;
45
63
} ) ;
46
64
} ) ;
47
65
48
66
it ( 'should find an element by checkbox input model' , function ( done ) {
67
+ catchPromiseErrors ( done ) ;
49
68
ptor . findElement ( protractor . By . id ( 'shower' ) ) .
50
69
isDisplayed ( ) . then ( function ( displayed ) {
51
70
expect ( displayed ) . toBe ( true ) ;
@@ -58,6 +77,66 @@ describe('test application', function() {
58
77
done ( ) ;
59
78
} ) ;
60
79
} ) ;
80
+
81
+ xit ( 'should find a repeater using data-ng-repeat' , function ( done ) {
82
+ catchPromiseErrors ( done ) ;
83
+ ptor . findElement ( protractor . By . repeater ( 'day in days' ) . row ( 3 ) ) .
84
+ getText ( ) . then ( function ( text ) {
85
+ expect ( text ) . toEqual ( 'Wed' ) ;
86
+ done ( ) ;
87
+ } ) ;
88
+ ptor . findElement ( protractor . By . repeater ( 'day in days' ) . row ( 3 ) .
89
+ column ( 'day' ) ) .
90
+ getText ( ) . then ( function ( text ) {
91
+ expect ( text ) . toEqual ( 'Wed' ) ;
92
+ done ( ) ;
93
+ } ) ;
94
+ } ) ;
95
+
96
+ xit ( 'should find a repeater using ng:repeat' , function ( done ) {
97
+ catchPromiseErrors ( done ) ;
98
+ ptor . findElement ( protractor . By . repeater ( 'bar in days' ) . row ( 3 ) ) .
99
+ getText ( ) . then ( function ( text ) {
100
+ expect ( text ) . toEqual ( 'Wed' ) ;
101
+ done ( ) ;
102
+ } ) ;
103
+ ptor . findElement ( protractor . By . repeater ( 'bar in days' ) . row ( 3 ) .
104
+ column ( 'bar' ) ) .
105
+ getText ( ) . then ( function ( text ) {
106
+ expect ( text ) . toEqual ( 'Wed' ) ;
107
+ done ( ) ;
108
+ } ) ;
109
+ } ) ;
110
+
111
+ xit ( 'should find a repeater using ng_repeat' , function ( done ) {
112
+ catchPromiseErrors ( done ) ;
113
+ ptor . findElement ( protractor . By . repeater ( 'foo in days' ) . row ( 3 ) ) .
114
+ getText ( ) . then ( function ( text ) {
115
+ expect ( text ) . toEqual ( 'Wed' ) ;
116
+ done ( ) ;
117
+ } ) ;
118
+ ptor . findElement ( protractor . By . repeater ( 'foo in days' ) . row ( 3 ) ) .
119
+ column ( 'foo' ) .
120
+ getText ( ) . then ( function ( text ) {
121
+ expect ( text ) . toEqual ( 'Wed' ) ;
122
+ done ( ) ;
123
+ } ) ;
124
+ } ) ;
125
+
126
+ xit ( 'should find a repeater using x-ng-repeat' , function ( done ) {
127
+ catchPromiseErrors ( done ) ;
128
+ ptor . findElement ( protractor . By . repeater ( 'qux in days' ) . row ( 3 ) ) .
129
+ getText ( ) . then ( function ( text ) {
130
+ expect ( text ) . toEqual ( 'Wed' ) ;
131
+ done ( ) ;
132
+ } ) ;
133
+ ptor . findElement ( protractor . By . repeater ( 'qux in days' ) . row ( 3 ) ) .
134
+ column ( 'quz' ) .
135
+ getText ( ) . then ( function ( text ) {
136
+ expect ( text ) . toEqual ( 'Wed' ) ;
137
+ done ( ) ;
138
+ } ) ;
139
+ } ) ;
61
140
} ) ;
62
141
63
142
describe ( 'finding elements' , function ( ) {
@@ -66,6 +145,7 @@ describe('test application', function() {
66
145
} ) ;
67
146
68
147
it ( 'should find elements using a select' , function ( done ) {
148
+ catchPromiseErrors ( done ) ;
69
149
ptor . findElement ( protractor . By . selectedOption ( 'planet' ) ) .
70
150
getText ( ) . then ( function ( text ) {
71
151
expect ( text ) . toEqual ( 'Mercury' ) ;
@@ -83,6 +163,7 @@ describe('test application', function() {
83
163
} ) ;
84
164
85
165
it ( 'should find elements using a repeater' , function ( done ) {
166
+ catchPromiseErrors ( done ) ;
86
167
// Returns the element for the entire row.
87
168
ptor . findElement ( protractor . By . repeater ( 'ball in planets' ) . row ( 3 ) ) .
88
169
getText ( ) . then ( function ( text ) {
@@ -111,6 +192,7 @@ describe('test application', function() {
111
192
} ) ;
112
193
113
194
it ( 'should find multiple elements by binding' , function ( done ) {
195
+ catchPromiseErrors ( done ) ;
114
196
// There must be a better way to do this.
115
197
ptor . findElement ( protractor . By . select ( 'planet' ) )
116
198
. findElement ( protractor . By . css ( 'option[value="4"]' ) ) . click ( ) ;
@@ -149,6 +231,7 @@ describe('test application', function() {
149
231
} ) ;
150
232
151
233
it ( 'should override services via mock modules' , function ( done ) {
234
+ catchPromiseErrors ( done ) ;
152
235
ptor . addMockModule ( 'moduleA' , mockModuleA ) ;
153
236
154
237
ptor . get ( 'http://localhost:8000/app/index.html' ) ;
@@ -161,6 +244,7 @@ describe('test application', function() {
161
244
} ) ;
162
245
163
246
it ( 'should have the version of the last loaded module' , function ( done ) {
247
+ catchPromiseErrors ( done ) ;
164
248
ptor . addMockModule ( 'moduleA' , mockModuleA ) ;
165
249
ptor . addMockModule ( 'moduleB' , mockModuleB ) ;
166
250
@@ -181,6 +265,7 @@ describe('test application', function() {
181
265
} ) ;
182
266
183
267
it ( 'should wait for slow RPCs' , function ( done ) {
268
+ catchPromiseErrors ( done ) ;
184
269
var sample1Button = driver . findElement ( protractor . By . id ( 'sample1' ) ) ;
185
270
var sample2Button = driver . findElement ( protractor . By . id ( 'sample2' ) ) ;
186
271
sample1Button . click ( ) ;
@@ -220,14 +305,17 @@ describe('test application', function() {
220
305
} ) ;
221
306
222
307
it ( 'should synchronize with a slow action' , function ( done ) {
308
+ catchPromiseErrors ( done ) ;
223
309
var addOneButton = ptor . findElement ( protractor . By . id ( 'addone' ) ) ;
224
310
addOneButton . click ( ) ;
225
- ptor . findElement ( protractor . By . repeater ( "foo in foos | orderBy:'a':true" ) . row ( 1 ) .
311
+ ptor . findElement (
312
+ protractor . By . repeater ( "foo in foos | orderBy:'a':true" ) . row ( 1 ) .
226
313
column ( '{{foo.b}}' ) ) . getText ( ) . then ( function ( text ) {
227
314
expect ( text ) . toEqual ( '14930352' ) ;
228
315
} ) ;
229
316
addOneButton . click ( ) ;
230
- ptor . findElement ( protractor . By . repeater ( "foo in foos | orderBy:'a':true" ) . row ( 1 ) .
317
+ ptor . findElement (
318
+ protractor . By . repeater ( "foo in foos | orderBy:'a':true" ) . row ( 1 ) .
231
319
column ( '{{foo.b}}' ) ) . getText ( ) . then ( function ( text ) {
232
320
expect ( text ) . toEqual ( '24157817' ) ;
233
321
done ( ) ;
0 commit comments