Module: Angular::Locator

Defined in:
lib/angular/locator.rb

Overview

TODO KI NOT USED

Instance Method Summary collapse

Instance Method Details

#bindingObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/angular/locator.rb', line 6

def binding
<<-FN
/**
 * Find an element by binding.
 *
 * @view
 * <span>{{person.name}}</span>
 * <span ng-bind="person.email"></span>
 *
 * @example
 * var span1 = element(by.binding('person.name'));
 * expect(span1.getText()).toBe('Foo');
 *
 * var span2 = element(by.binding('person.email'));
 * expect(span2.getText()).toBe('[email protected]');
 *
 * @param {string} bindingDescriptor
 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
 */
function(bindingDescriptor) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(clientSideScripts.findBindings,
            bindingDescriptor, false, using, rootSelector));
  },
  toString: function toString() {
    return 'by.binding("' + bindingDescriptor + '")';
  }
};
};
FN
end

#buttonTextObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/angular/locator.rb', line 108

def buttonText
<<-FN
/**
 * Find a button by text.
 *
 * @view
 * <button>Save</button>
 *
 * @example
 * element(by.buttonText('Save'));
 *
 * @param {string} searchText
 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
 */
function(searchText) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(clientSideScripts.findByButtonText,
            searchText, using, rootSelector));
  },
  toString: function toString() {
    return 'by.buttonText("' + searchText + '")';
  }
};
};
FN
end

#cssContainingTextObject



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/angular/locator.rb', line 285

def cssContainingText
<<-FN
/**
 * Find elements by CSS which contain a certain string.
 *
 * @view
 * <ul>
 *   <li class="pet">Dog</li>
 *   <li class="pet">Cat</li>
 * </ul>
 *
 * @example
 * // Returns the DIV for the dog, but not cat.
 * var dog = element(by.cssContainingText('.pet', 'Dog'));
 */
function(cssSelector, searchText) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
      webdriver.By.js(clientSideScripts.findByCssContainingText,
      cssSelector, searchText, using, rootSelector));
  },
  toString: function toString() {
    return 'by.cssContainingText("' + cssSelector + '", "' + searchText + '")';
  }
};
};
FN
end

#exactBindingObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/angular/locator.rb', line 41

def exactBinding
<<-FN
/**
 * Find an element by exact binding.
 *
 * @view
 * <span>{{ person.name }}</span>
 * <span ng-bind="person-email"></span>
 * <span>{{person_phone|uppercase}}</span>
 *
 * @example
 * expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
 * expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
 * expect(element(by.exactBinding('person')).isPresent()).toBe(false);
 * expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
 * expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
 * expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
 *
 * @param {string} bindingDescriptor
 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
 */
function(bindingDescriptor) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(clientSideScripts.findBindings,
            bindingDescriptor, true, using, rootSelector));
  },
  toString: function toString() {
    return 'by.exactBinding("' + bindingDescriptor + '")';
  }
};
};
FN
end

#modelObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/angular/locator.rb', line 77

def model
<<-FN
/**
 * Find an element by ng-model expression.
 *
 * @alias by.model(modelName)
 * @view
 * <input type="text" ng-model="person.name"/>
 *
 * @example
 * var input = element(by.model('person.name'));
 * input.sendKeys('123');
 * expect(input.getAttribute('value')).toBe('Foo123');
 *
 * @param {string} model ng-model expression.
 */
function(model) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(
            clientSideScripts.findByModel, model, using, rootSelector));
  },
  toString: function toString() {
    return 'by.model("' + model + '")';
  }
};
};
FN
end

#optionsObject



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/angular/locator.rb', line 315

def options
<<-FN
/**
 * Find an element by ng-options expression.
 *
 * @alias by.options(optionsDescriptor)
 * @view
 * <select ng-model="color" ng-options="c for c in colors">
 *   <option value="0" selected="selected">red</option>
 *   <option value="1">green</option>
 * </select>
 *
 * @example
 * var allOptions = element.all(by.options('c for c in colors'));
 * expect(allOptions.count()).toEqual(2);
 * var firstOption = allOptions.first();
 * expect(firstOption.getText()).toEqual('red');
 *
 * @param {string} optionsDescriptor ng-options expression.
 */
function(optionsDescriptor) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(clientSideScripts.findByOptions, optionsDescriptor,
            using, rootSelector));
  },
  toString: function toString() {
    return 'by.option("' + optionsDescriptor + '")';
  }
};
};
FN
end

#partialButtonTextObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/angular/locator.rb', line 137

def partialButtonText
<<-FN
/**
 * Find a button by partial text.
 *
 * @view
 * <button>Save my file</button>
 *
 * @example
 * element(by.partialButtonText('Save'));
 *
 * @param {string} searchText
 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}
 */
function(searchText) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
        webdriver.By.js(clientSideScripts.findByPartialButtonText,
            searchText, using, rootSelector));
  },
  toString: function toString() {
    return 'by.partialButtonText("' + searchText + '")';
  }
};
};
FN
end

#repeaterObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/angular/locator.rb', line 166

def repeater
<<-FN
/**
 * Find elements inside an ng-repeat.
 *
 * @view
 * <div ng-repeat="cat in pets">
 *   <span>{{cat.name}}</span>
 *   <span>{{cat.age}}</span>
 * </div>
 *
 * <div class="book-img" ng-repeat-start="book in library">
 *   <span>{{$index}}</span>
 * </div>
 * <div class="book-info" ng-repeat-end>
 *   <h4>{{book.name}}</h4>
 *   <p>{{book.blurb}}</p>
 * </div>
 *
 * @example
 * // Returns the DIV for the second cat.
 * var secondCat = element(by.repeater('cat in pets').row(1));
 *
 * // Returns the SPAN for the first cat's name.
 * var firstCatName = element(by.repeater('cat in pets').
 *     row(0).column('{{cat.name}}'));
 *
 * // Returns a promise that resolves to an array of WebElements from a column
 * var ages = element.all(
 *     by.repeater('cat in pets').column('{{cat.age}}'));
 *
 * // Returns a promise that resolves to an array of WebElements containing
 * // all top level elements repeated by the repeater. For 2 pets rows resolves
 * // to an array of 2 elements.
 * var rows = element.all(by.repeater('cat in pets'));
 *
 * // Returns a promise that resolves to an array of WebElements containing all
 * // the elements with a binding to the book's name.
 * var divs = element.all(by.repeater('book in library').column('book.name'));
 *
 * // Returns a promise that resolves to an array of WebElements containing
 * // the DIVs for the second book.
 * var bookInfo = element.all(by.repeater('book in library').row(1));
 *
 * // Returns the H4 for the first book's name.
 * var firstBookName = element(by.repeater('book in library').
 *     row(0).column('{{book.name}}'));
 *
 * // Returns a promise that resolves to an array of WebElements containing
 * // all top level elements repeated by the repeater. For 2 books divs
 * // resolves to an array of 4 elements.
 * var divs = element.all(by.repeater('book in library'));
 */
function(repeatDescriptor) {
return {
  findElementsOverride: function(driver, using, rootSelector) {
    return driver.findElements(
      webdriver.By.js(clientSideScripts.findAllRepeaterRows,
          repeatDescriptor, using, rootSelector));
  },
  toString: function toString() {
    return 'by.repeater("' + repeatDescriptor + '")';
  },
  row: function(index) {
    return {
      findElementsOverride: function(driver, using, rootSelector) {
        return driver.findElements(
          webdriver.By.js(clientSideScripts.findRepeaterRows,
              repeatDescriptor, index, using, rootSelector));
      },
      toString: function toString() {
        return 'by.repeater(' + repeatDescriptor + '").row("' + index + '")"';
      },
      column: function(binding) {
        return {
          findElementsOverride: function(driver, using, rootSelector) {
            return driver.findElements(
                webdriver.By.js(clientSideScripts.findRepeaterElement,
                    repeatDescriptor, index, binding, using, rootSelector));
          },
          toString: function toString() {
            return 'by.repeater("' + repeatDescriptor + '").row("' + index +
              '").column("' + binding + '")';
          }
        };
      }
    };
  },
  column: function(binding) {
    return {
      findElementsOverride: function(driver, using, rootSelector) {
        return driver.findElements(
            webdriver.By.js(clientSideScripts.findRepeaterColumn,
                repeatDescriptor, binding, using, rootSelector));
      },
      toString: function toString() {
        return 'by.repeater("' + repeatDescriptor + '").column("' +
          binding + '")';
      },
      row: function(index) {
        return {
          findElementsOverride: function(driver, using, rootSelector) {
            return driver.findElements(
                webdriver.By.js(clientSideScripts.findRepeaterElement,
                    repeatDescriptor, index, binding, using, rootSelector));
          },
          toString: function toString() {
            return 'by.repeater("' + repeatDescriptor + '").column("' +
              binding + '").row("' + index + '")';
          }
        };
      }
    };
  }
};
};
FN
end