capybara-ng 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/angular/client_script.rb +52 -23
- data/lib/angular/version.rb +1 -1
- data/lib/angular/waiter.rb +8 -0
- metadata +2 -5
- data/lib/angular/driver.rb +0 -357
- data/lib/angular/element_helper.rb +0 -899
- data/lib/angular/locator.rb +0 -350
data/lib/angular/locator.rb
DELETED
@@ -1,350 +0,0 @@
|
|
1
|
-
module Angular
|
2
|
-
#
|
3
|
-
# TODO KI NOT USED
|
4
|
-
#
|
5
|
-
module Locator
|
6
|
-
def binding
|
7
|
-
<<-FN
|
8
|
-
/**
|
9
|
-
* Find an element by binding.
|
10
|
-
*
|
11
|
-
* @view
|
12
|
-
* <span>{{person.name}}</span>
|
13
|
-
* <span ng-bind="person.email"></span>
|
14
|
-
*
|
15
|
-
* @example
|
16
|
-
* var span1 = element(by.binding('person.name'));
|
17
|
-
* expect(span1.getText()).toBe('Foo');
|
18
|
-
*
|
19
|
-
* var span2 = element(by.binding('person.email'));
|
20
|
-
* expect(span2.getText()).toBe('foo@bar.com');
|
21
|
-
*
|
22
|
-
* @param {string} bindingDescriptor
|
23
|
-
* @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
|
24
|
-
*/
|
25
|
-
function(bindingDescriptor) {
|
26
|
-
return {
|
27
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
28
|
-
return driver.findElements(
|
29
|
-
webdriver.By.js(clientSideScripts.findBindings,
|
30
|
-
bindingDescriptor, false, using, rootSelector));
|
31
|
-
},
|
32
|
-
toString: function toString() {
|
33
|
-
return 'by.binding("' + bindingDescriptor + '")';
|
34
|
-
}
|
35
|
-
};
|
36
|
-
};
|
37
|
-
FN
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def exactBinding
|
42
|
-
<<-FN
|
43
|
-
/**
|
44
|
-
* Find an element by exact binding.
|
45
|
-
*
|
46
|
-
* @view
|
47
|
-
* <span>{{ person.name }}</span>
|
48
|
-
* <span ng-bind="person-email"></span>
|
49
|
-
* <span>{{person_phone|uppercase}}</span>
|
50
|
-
*
|
51
|
-
* @example
|
52
|
-
* expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
|
53
|
-
* expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
|
54
|
-
* expect(element(by.exactBinding('person')).isPresent()).toBe(false);
|
55
|
-
* expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
|
56
|
-
* expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
|
57
|
-
* expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
|
58
|
-
*
|
59
|
-
* @param {string} bindingDescriptor
|
60
|
-
* @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
|
61
|
-
*/
|
62
|
-
function(bindingDescriptor) {
|
63
|
-
return {
|
64
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
65
|
-
return driver.findElements(
|
66
|
-
webdriver.By.js(clientSideScripts.findBindings,
|
67
|
-
bindingDescriptor, true, using, rootSelector));
|
68
|
-
},
|
69
|
-
toString: function toString() {
|
70
|
-
return 'by.exactBinding("' + bindingDescriptor + '")';
|
71
|
-
}
|
72
|
-
};
|
73
|
-
};
|
74
|
-
FN
|
75
|
-
end
|
76
|
-
|
77
|
-
def model
|
78
|
-
<<-FN
|
79
|
-
/**
|
80
|
-
* Find an element by ng-model expression.
|
81
|
-
*
|
82
|
-
* @alias by.model(modelName)
|
83
|
-
* @view
|
84
|
-
* <input type="text" ng-model="person.name"/>
|
85
|
-
*
|
86
|
-
* @example
|
87
|
-
* var input = element(by.model('person.name'));
|
88
|
-
* input.sendKeys('123');
|
89
|
-
* expect(input.getAttribute('value')).toBe('Foo123');
|
90
|
-
*
|
91
|
-
* @param {string} model ng-model expression.
|
92
|
-
*/
|
93
|
-
function(model) {
|
94
|
-
return {
|
95
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
96
|
-
return driver.findElements(
|
97
|
-
webdriver.By.js(
|
98
|
-
clientSideScripts.findByModel, model, using, rootSelector));
|
99
|
-
},
|
100
|
-
toString: function toString() {
|
101
|
-
return 'by.model("' + model + '")';
|
102
|
-
}
|
103
|
-
};
|
104
|
-
};
|
105
|
-
FN
|
106
|
-
end
|
107
|
-
|
108
|
-
def buttonText
|
109
|
-
<<-FN
|
110
|
-
/**
|
111
|
-
* Find a button by text.
|
112
|
-
*
|
113
|
-
* @view
|
114
|
-
* <button>Save</button>
|
115
|
-
*
|
116
|
-
* @example
|
117
|
-
* element(by.buttonText('Save'));
|
118
|
-
*
|
119
|
-
* @param {string} searchText
|
120
|
-
* @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
|
121
|
-
*/
|
122
|
-
function(searchText) {
|
123
|
-
return {
|
124
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
125
|
-
return driver.findElements(
|
126
|
-
webdriver.By.js(clientSideScripts.findByButtonText,
|
127
|
-
searchText, using, rootSelector));
|
128
|
-
},
|
129
|
-
toString: function toString() {
|
130
|
-
return 'by.buttonText("' + searchText + '")';
|
131
|
-
}
|
132
|
-
};
|
133
|
-
};
|
134
|
-
FN
|
135
|
-
end
|
136
|
-
|
137
|
-
def partialButtonText
|
138
|
-
<<-FN
|
139
|
-
/**
|
140
|
-
* Find a button by partial text.
|
141
|
-
*
|
142
|
-
* @view
|
143
|
-
* <button>Save my file</button>
|
144
|
-
*
|
145
|
-
* @example
|
146
|
-
* element(by.partialButtonText('Save'));
|
147
|
-
*
|
148
|
-
* @param {string} searchText
|
149
|
-
* @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
|
150
|
-
*/
|
151
|
-
function(searchText) {
|
152
|
-
return {
|
153
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
154
|
-
return driver.findElements(
|
155
|
-
webdriver.By.js(clientSideScripts.findByPartialButtonText,
|
156
|
-
searchText, using, rootSelector));
|
157
|
-
},
|
158
|
-
toString: function toString() {
|
159
|
-
return 'by.partialButtonText("' + searchText + '")';
|
160
|
-
}
|
161
|
-
};
|
162
|
-
};
|
163
|
-
FN
|
164
|
-
end
|
165
|
-
|
166
|
-
def repeater
|
167
|
-
<<-FN
|
168
|
-
/**
|
169
|
-
* Find elements inside an ng-repeat.
|
170
|
-
*
|
171
|
-
* @view
|
172
|
-
* <div ng-repeat="cat in pets">
|
173
|
-
* <span>{{cat.name}}</span>
|
174
|
-
* <span>{{cat.age}}</span>
|
175
|
-
* </div>
|
176
|
-
*
|
177
|
-
* <div class="book-img" ng-repeat-start="book in library">
|
178
|
-
* <span>{{$index}}</span>
|
179
|
-
* </div>
|
180
|
-
* <div class="book-info" ng-repeat-end>
|
181
|
-
* <h4>{{book.name}}</h4>
|
182
|
-
* <p>{{book.blurb}}</p>
|
183
|
-
* </div>
|
184
|
-
*
|
185
|
-
* @example
|
186
|
-
* // Returns the DIV for the second cat.
|
187
|
-
* var secondCat = element(by.repeater('cat in pets').row(1));
|
188
|
-
*
|
189
|
-
* // Returns the SPAN for the first cat's name.
|
190
|
-
* var firstCatName = element(by.repeater('cat in pets').
|
191
|
-
* row(0).column('{{cat.name}}'));
|
192
|
-
*
|
193
|
-
* // Returns a promise that resolves to an array of WebElements from a column
|
194
|
-
* var ages = element.all(
|
195
|
-
* by.repeater('cat in pets').column('{{cat.age}}'));
|
196
|
-
*
|
197
|
-
* // Returns a promise that resolves to an array of WebElements containing
|
198
|
-
* // all top level elements repeated by the repeater. For 2 pets rows resolves
|
199
|
-
* // to an array of 2 elements.
|
200
|
-
* var rows = element.all(by.repeater('cat in pets'));
|
201
|
-
*
|
202
|
-
* // Returns a promise that resolves to an array of WebElements containing all
|
203
|
-
* // the elements with a binding to the book's name.
|
204
|
-
* var divs = element.all(by.repeater('book in library').column('book.name'));
|
205
|
-
*
|
206
|
-
* // Returns a promise that resolves to an array of WebElements containing
|
207
|
-
* // the DIVs for the second book.
|
208
|
-
* var bookInfo = element.all(by.repeater('book in library').row(1));
|
209
|
-
*
|
210
|
-
* // Returns the H4 for the first book's name.
|
211
|
-
* var firstBookName = element(by.repeater('book in library').
|
212
|
-
* row(0).column('{{book.name}}'));
|
213
|
-
*
|
214
|
-
* // Returns a promise that resolves to an array of WebElements containing
|
215
|
-
* // all top level elements repeated by the repeater. For 2 books divs
|
216
|
-
* // resolves to an array of 4 elements.
|
217
|
-
* var divs = element.all(by.repeater('book in library'));
|
218
|
-
*/
|
219
|
-
function(repeatDescriptor) {
|
220
|
-
return {
|
221
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
222
|
-
return driver.findElements(
|
223
|
-
webdriver.By.js(clientSideScripts.findAllRepeaterRows,
|
224
|
-
repeatDescriptor, using, rootSelector));
|
225
|
-
},
|
226
|
-
toString: function toString() {
|
227
|
-
return 'by.repeater("' + repeatDescriptor + '")';
|
228
|
-
},
|
229
|
-
row: function(index) {
|
230
|
-
return {
|
231
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
232
|
-
return driver.findElements(
|
233
|
-
webdriver.By.js(clientSideScripts.findRepeaterRows,
|
234
|
-
repeatDescriptor, index, using, rootSelector));
|
235
|
-
},
|
236
|
-
toString: function toString() {
|
237
|
-
return 'by.repeater(' + repeatDescriptor + '").row("' + index + '")"';
|
238
|
-
},
|
239
|
-
column: function(binding) {
|
240
|
-
return {
|
241
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
242
|
-
return driver.findElements(
|
243
|
-
webdriver.By.js(clientSideScripts.findRepeaterElement,
|
244
|
-
repeatDescriptor, index, binding, using, rootSelector));
|
245
|
-
},
|
246
|
-
toString: function toString() {
|
247
|
-
return 'by.repeater("' + repeatDescriptor + '").row("' + index +
|
248
|
-
'").column("' + binding + '")';
|
249
|
-
}
|
250
|
-
};
|
251
|
-
}
|
252
|
-
};
|
253
|
-
},
|
254
|
-
column: function(binding) {
|
255
|
-
return {
|
256
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
257
|
-
return driver.findElements(
|
258
|
-
webdriver.By.js(clientSideScripts.findRepeaterColumn,
|
259
|
-
repeatDescriptor, binding, using, rootSelector));
|
260
|
-
},
|
261
|
-
toString: function toString() {
|
262
|
-
return 'by.repeater("' + repeatDescriptor + '").column("' +
|
263
|
-
binding + '")';
|
264
|
-
},
|
265
|
-
row: function(index) {
|
266
|
-
return {
|
267
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
268
|
-
return driver.findElements(
|
269
|
-
webdriver.By.js(clientSideScripts.findRepeaterElement,
|
270
|
-
repeatDescriptor, index, binding, using, rootSelector));
|
271
|
-
},
|
272
|
-
toString: function toString() {
|
273
|
-
return 'by.repeater("' + repeatDescriptor + '").column("' +
|
274
|
-
binding + '").row("' + index + '")';
|
275
|
-
}
|
276
|
-
};
|
277
|
-
}
|
278
|
-
};
|
279
|
-
}
|
280
|
-
};
|
281
|
-
};
|
282
|
-
FN
|
283
|
-
end
|
284
|
-
|
285
|
-
def cssContainingText
|
286
|
-
<<-FN
|
287
|
-
/**
|
288
|
-
* Find elements by CSS which contain a certain string.
|
289
|
-
*
|
290
|
-
* @view
|
291
|
-
* <ul>
|
292
|
-
* <li class="pet">Dog</li>
|
293
|
-
* <li class="pet">Cat</li>
|
294
|
-
* </ul>
|
295
|
-
*
|
296
|
-
* @example
|
297
|
-
* // Returns the DIV for the dog, but not cat.
|
298
|
-
* var dog = element(by.cssContainingText('.pet', 'Dog'));
|
299
|
-
*/
|
300
|
-
function(cssSelector, searchText) {
|
301
|
-
return {
|
302
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
303
|
-
return driver.findElements(
|
304
|
-
webdriver.By.js(clientSideScripts.findByCssContainingText,
|
305
|
-
cssSelector, searchText, using, rootSelector));
|
306
|
-
},
|
307
|
-
toString: function toString() {
|
308
|
-
return 'by.cssContainingText("' + cssSelector + '", "' + searchText + '")';
|
309
|
-
}
|
310
|
-
};
|
311
|
-
};
|
312
|
-
FN
|
313
|
-
end
|
314
|
-
|
315
|
-
def options
|
316
|
-
<<-FN
|
317
|
-
/**
|
318
|
-
* Find an element by ng-options expression.
|
319
|
-
*
|
320
|
-
* @alias by.options(optionsDescriptor)
|
321
|
-
* @view
|
322
|
-
* <select ng-model="color" ng-options="c for c in colors">
|
323
|
-
* <option value="0" selected="selected">red</option>
|
324
|
-
* <option value="1">green</option>
|
325
|
-
* </select>
|
326
|
-
*
|
327
|
-
* @example
|
328
|
-
* var allOptions = element.all(by.options('c for c in colors'));
|
329
|
-
* expect(allOptions.count()).toEqual(2);
|
330
|
-
* var firstOption = allOptions.first();
|
331
|
-
* expect(firstOption.getText()).toEqual('red');
|
332
|
-
*
|
333
|
-
* @param {string} optionsDescriptor ng-options expression.
|
334
|
-
*/
|
335
|
-
function(optionsDescriptor) {
|
336
|
-
return {
|
337
|
-
findElementsOverride: function(driver, using, rootSelector) {
|
338
|
-
return driver.findElements(
|
339
|
-
webdriver.By.js(clientSideScripts.findByOptions, optionsDescriptor,
|
340
|
-
using, rootSelector));
|
341
|
-
},
|
342
|
-
toString: function toString() {
|
343
|
-
return 'by.option("' + optionsDescriptor + '")';
|
344
|
-
}
|
345
|
-
};
|
346
|
-
};
|
347
|
-
FN
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|