UNPKG

31.3 kBTypeScriptView Raw
1import { By, promise as wdpromise, WebElement, WebElementPromise } from 'selenium-webdriver';
2import { ElementHelper, ProtractorBrowser } from './browser';
3import { Locator } from './locators';
4export declare class WebdriverWebElement {
5}
6export interface WebdriverWebElement extends WebElement {
7 [key: string]: any;
8}
9/**
10 * ElementArrayFinder is used for operations on an array of elements (as opposed
11 * to a single element).
12 *
13 * The ElementArrayFinder is used to set up a chain of conditions that identify
14 * an array of elements. In particular, you can call all(locator) and
15 * filter(filterFn) to return a new ElementArrayFinder modified by the
16 * conditions, and you can call get(index) to return a single ElementFinder at
17 * position 'index'.
18 *
19 * Similar to jquery, ElementArrayFinder will search all branches of the DOM
20 * to find the elements that satisfy the conditions (i.e. all, filter, get).
21 * However, an ElementArrayFinder will not actually retrieve the elements until
22 * an action is called, which means it can be set up in helper files (i.e.
23 * page objects) before the page is available, and reused as the page changes.
24 *
25 * You can treat an ElementArrayFinder as an array of WebElements for most
26 * purposes, in particular, you may perform actions (i.e. click, getText) on
27 * them as you would an array of WebElements. The action will apply to
28 * every element identified by the ElementArrayFinder. ElementArrayFinder
29 * extends Promise, and once an action is performed on an ElementArrayFinder,
30 * the latest result can be accessed using then, and will be returned as an
31 * array of the results; the array has length equal to the length of the
32 * elements found by the ElementArrayFinder and each result represents the
33 * result of performing the action on the element. Unlike a WebElement, an
34 * ElementArrayFinder will wait for the angular app to settle before
35 * performing finds or actions.
36 *
37 * @alias element.all(locator)
38 * @view
39 * <ul class="items">
40 * <li>First</li>
41 * <li>Second</li>
42 * <li>Third</li>
43 * </ul>
44 *
45 * @example
46 * element.all(by.css('.items li')).then(function(items) {
47 * expect(items.length).toBe(3);
48 * expect(items[0].getText()).toBe('First');
49 * });
50 *
51 * // Or using the shortcut $$() notation instead of element.all(by.css()):
52 *
53 * $$('.items li').then(function(items) {
54 * expect(items.length).toBe(3);
55 * expect(items[0].getText()).toBe('First');
56 * });
57 *
58 * @constructor
59 * @param {ProtractorBrowser} browser A browser instance.
60 * @param {function(): Array.<webdriver.WebElement>} getWebElements A function
61 * that returns a list of the underlying Web Elements.
62 * @param {webdriver.Locator} locator The most relevant locator. It is only
63 * used for error reporting and ElementArrayFinder.locator.
64 * @param {Array.<webdriver.promise.Promise>} opt_actionResults An array
65 * of promises which will be retrieved with then. Resolves to the latest
66 * action result, or null if no action has been called.
67 * @returns {ElementArrayFinder}
68 */
69export declare class ElementArrayFinder extends WebdriverWebElement {
70 browser_: ProtractorBrowser;
71 getWebElements: () => wdpromise.Promise<WebElement[]>;
72 locator_: any;
73 actionResults_: wdpromise.Promise<any>;
74 constructor(browser_: ProtractorBrowser, getWebElements?: () => wdpromise.Promise<WebElement[]>, locator_?: any, actionResults_?: wdpromise.Promise<any>);
75 /**
76 * Create a shallow copy of ElementArrayFinder.
77 *
78 * @returns {!ElementArrayFinder} A shallow copy of this.
79 */
80 clone(): ElementArrayFinder;
81 /**
82 * Calls to ElementArrayFinder may be chained to find an array of elements
83 * using the current elements in this ElementArrayFinder as the starting
84 * point. This function returns a new ElementArrayFinder which would contain
85 * the children elements found (and could also be empty).
86 *
87 * @alias element.all(locator).all(locator)
88 * @view
89 * <div id='id1' class="parent">
90 * <ul>
91 * <li class="foo">1a</li>
92 * <li class="baz">1b</li>
93 * </ul>
94 * </div>
95 * <div id='id2' class="parent">
96 * <ul>
97 * <li class="foo">2a</li>
98 * <li class="bar">2b</li>
99 * </ul>
100 * </div>
101 *
102 * @example
103 * let foo = element.all(by.css('.parent')).all(by.css('.foo'));
104 * expect(foo.getText()).toEqual(['1a', '2a']);
105 * let baz = element.all(by.css('.parent')).all(by.css('.baz'));
106 * expect(baz.getText()).toEqual(['1b']);
107 * let nonexistent = element.all(by.css('.parent'))
108 * .all(by.css('.NONEXISTENT'));
109 * expect(nonexistent.getText()).toEqual(['']);
110 *
111 * // Or using the shortcut $$() notation instead of element.all(by.css()):
112 *
113 * let foo = $$('.parent').$$('.foo');
114 * expect(foo.getText()).toEqual(['1a', '2a']);
115 * let baz = $$('.parent').$$('.baz');
116 * expect(baz.getText()).toEqual(['1b']);
117 * let nonexistent = $$('.parent').$$('.NONEXISTENT');
118 * expect(nonexistent.getText()).toEqual(['']);
119 *
120 * @param {webdriver.Locator} subLocator
121 * @returns {ElementArrayFinder}
122 */
123 all(locator: Locator): ElementArrayFinder;
124 /**
125 * Apply a filter function to each element within the ElementArrayFinder.
126 * Returns a new ElementArrayFinder with all elements that pass the filter
127 * function. The filter function receives the ElementFinder as the first
128 * argument and the index as a second arg. This does not actually retrieve
129 * the underlying list of elements, so it can be used in page objects.
130 *
131 * @alias element.all(locator).filter(filterFn)
132 * @view
133 * <ul class="items">
134 * <li class="one">First</li>
135 * <li class="two">Second</li>
136 * <li class="three">Third</li>
137 * </ul>
138 *
139 * @example
140 * element.all(by.css('.items li')).filter(function(elem, index) {
141 * return elem.getText().then(function(text) {
142 * return text === 'Third';
143 * });
144 * }).first().click();
145 *
146 * // Or using the shortcut $$() notation instead of element.all(by.css()):
147 *
148 * $$('.items li').filter(function(elem, index) {
149 * return elem.getText().then(function(text) {
150 * return text === 'Third';
151 * });
152 * }).first().click();
153 *
154 * @param {function(ElementFinder, number): webdriver.WebElement.Promise}
155 * filterFn
156 * Filter function that will test if an element should be returned.
157 * filterFn can either return a boolean or a promise that resolves to a
158 * boolean
159 * @returns {!ElementArrayFinder} A ElementArrayFinder that represents an
160 * array
161 * of element that satisfy the filter function.
162 */
163 filter(filterFn: (element: ElementFinder, index?: number) => boolean | wdpromise.Promise<boolean>): ElementArrayFinder;
164 /**
165 * Get an element within the ElementArrayFinder by index. The index starts at 0.
166 * Negative indices are wrapped (i.e. -i means ith element from last)
167 * This does not actually retrieve the underlying element.
168 *
169 * @alias element.all(locator).get(index)
170 * @view
171 * <ul class="items">
172 * <li>First</li>
173 * <li>Second</li>
174 * <li>Third</li>
175 * </ul>
176 *
177 * @example
178 * let list = element.all(by.css('.items li'));
179 * expect(list.get(0).getText()).toBe('First');
180 * expect(list.get(1).getText()).toBe('Second');
181 *
182 * // Or using the shortcut $$() notation instead of element.all(by.css()):
183 *
184 * let list = $$('.items li');
185 * expect(list.get(0).getText()).toBe('First');
186 * expect(list.get(1).getText()).toBe('Second');
187 *
188 * @param {number|webdriver.promise.Promise} index Element index.
189 * @returns {ElementFinder} finder representing element at the given index.
190 */
191 get(index: number | wdpromise.Promise<number>): ElementFinder;
192 /**
193 * Get the first matching element for the ElementArrayFinder. This does not
194 * actually retrieve the underlying element.
195 *
196 * @alias element.all(locator).first()
197 * @view
198 * <ul class="items">
199 * <li>First</li>
200 * <li>Second</li>
201 * <li>Third</li>
202 * </ul>
203 *
204 * @example
205 * let first = element.all(by.css('.items li')).first();
206 * expect(first.getText()).toBe('First');
207 *
208 * // Or using the shortcut $$() notation instead of element.all(by.css()):
209 *
210 * let first = $$('.items li').first();
211 * expect(first.getText()).toBe('First');
212 *
213 * @returns {ElementFinder} finder representing the first matching element
214 */
215 first(): ElementFinder;
216 /**
217 * Get the last matching element for the ElementArrayFinder. This does not
218 * actually retrieve the underlying element.
219 *
220 * @alias element.all(locator).last()
221 * @view
222 * <ul class="items">
223 * <li>First</li>
224 * <li>Second</li>
225 * <li>Third</li>
226 * </ul>
227 *
228 * @example
229 * let last = element.all(by.css('.items li')).last();
230 * expect(last.getText()).toBe('Third');
231 *
232 * // Or using the shortcut $$() notation instead of element.all(by.css()):
233 *
234 * let last = $$('.items li').last();
235 * expect(last.getText()).toBe('Third');
236 *
237 * @returns {ElementFinder} finder representing the last matching element
238 */
239 last(): ElementFinder;
240 /**
241 * Shorthand function for finding arrays of elements by css.
242 * `element.all(by.css('.abc'))` is equivalent to `$$('.abc')`
243 *
244 * @alias $$(cssSelector)
245 * @view
246 * <div class="count">
247 * <span class="one">First</span>
248 * <span class="two">Second</span>
249 * </div>
250 *
251 * @example
252 * // The following two blocks of code are equivalent.
253 * let list = element.all(by.css('.count span'));
254 * expect(list.count()).toBe(2);
255 * expect(list.get(0).getText()).toBe('First');
256 * expect(list.get(1).getText()).toBe('Second');
257 *
258 * // Or using the shortcut $$() notation instead of element.all(by.css()):
259 *
260 * let list = $$('.count span');
261 * expect(list.count()).toBe(2);
262 * expect(list.get(0).getText()).toBe('First');
263 * expect(list.get(1).getText()).toBe('Second');
264 *
265 * @param {string} selector a css selector
266 * @returns {ElementArrayFinder} which identifies the
267 * array of the located {@link webdriver.WebElement}s.
268 */
269 $$(selector: string): ElementArrayFinder;
270 /**
271 * Returns an ElementFinder representation of ElementArrayFinder. It ensures
272 * that the ElementArrayFinder resolves to one and only one underlying
273 * element.
274 *
275 * @returns {ElementFinder} An ElementFinder representation
276 * @private
277 */
278 toElementFinder_(): ElementFinder;
279 /**
280 * Count the number of elements represented by the ElementArrayFinder.
281 *
282 * @alias element.all(locator).count()
283 * @view
284 * <ul class="items">
285 * <li>First</li>
286 * <li>Second</li>
287 * <li>Third</li>
288 * </ul>
289 *
290 * @example
291 * let list = element.all(by.css('.items li'));
292 * expect(list.count()).toBe(3);
293 *
294 * // Or using the shortcut $$() notation instead of element.all(by.css()):
295 *
296 * let list = $$('.items li');
297 * expect(list.count()).toBe(3);
298 *
299 * @returns {!webdriver.promise.Promise} A promise which resolves to the
300 * number of elements matching the locator.
301 */
302 count(): wdpromise.Promise<number>;
303 /**
304 * Returns true if there are any elements present that match the finder.
305 *
306 * @alias element.all(locator).isPresent()
307 *
308 * @example
309 * expect($('.item').isPresent()).toBeTruthy();
310 *
311 * @returns {Promise<boolean>}
312 */
313 isPresent(): wdpromise.Promise<boolean>;
314 /**
315 * Returns the most relevant locator.
316 *
317 * @example
318 * // returns by.css('#ID1')
319 * $('#ID1').locator();
320 *
321 * // returns by.css('#ID2')
322 * $('#ID1').$('#ID2').locator();
323 *
324 * // returns by.css('#ID1')
325 * $$('#ID1').filter(filterFn).get(0).click().locator();
326 *
327 * @returns {webdriver.Locator}
328 */
329 locator(): Locator;
330 /**
331 * Apply an action function to every element in the ElementArrayFinder,
332 * and return a new ElementArrayFinder that contains the results of the
333 * actions.
334 *
335 * @param {function(ElementFinder)} actionFn
336 *
337 * @returns {ElementArrayFinder}
338 * @private
339 */
340 private applyAction_(actionFn);
341 /**
342 * Represents the ElementArrayFinder as an array of ElementFinders.
343 *
344 * @returns {Array.<ElementFinder>} Return a promise, which resolves to a list
345 * of ElementFinders specified by the locator.
346 */
347 asElementFinders_(): wdpromise.Promise<ElementFinder[]>;
348 /**
349 * Retrieve the elements represented by the ElementArrayFinder. The input
350 * function is passed to the resulting promise, which resolves to an
351 * array of ElementFinders.
352 *
353 * @alias element.all(locator).then(thenFunction)
354 * @view
355 * <ul class="items">
356 * <li>First</li>
357 * <li>Second</li>
358 * <li>Third</li>
359 * </ul>
360 *
361 * @example
362 * element.all(by.css('.items li')).then(function(arr) {
363 * expect(arr.length).toEqual(3);
364 * });
365 *
366 * // Or using the shortcut $$() notation instead of element.all(by.css()):
367 *
368 * $$('.items li').then(function(arr) {
369 * expect(arr.length).toEqual(3);
370 * });
371 *
372 * @param {function(Array.<ElementFinder>)} fn
373 * @param {function(Error)} errorFn
374 *
375 * @returns {!webdriver.promise.Promise} A promise which will resolve to
376 * an array of ElementFinders represented by the ElementArrayFinder.
377 */
378 then<T>(fn?: (value: ElementFinder[] | any[]) => T | wdpromise.IThenable<T>, errorFn?: (error: any) => any): wdpromise.Promise<T>;
379 /**
380 * Calls the input function on each ElementFinder represented by the
381 * ElementArrayFinder.
382 *
383 * @alias element.all(locator).each(eachFunction)
384 * @view
385 * <ul class="items">
386 * <li>First</li>
387 * <li>Second</li>
388 * <li>Third</li>
389 * </ul>
390 *
391 * @example
392 * element.all(by.css('.items li')).each(function(element, index) {
393 * // Will print 0 First, 1 Second, 2 Third.
394 * element.getText().then(function (text) {
395 * console.log(index, text);
396 * });
397 * });
398 *
399 * // Or using the shortcut $$() notation instead of element.all(by.css()):
400 *
401 * $$('.items li').each(function(element, index) {
402 * // Will print 0 First, 1 Second, 2 Third.
403 * element.getText().then(function (text) {
404 * console.log(index, text);
405 * });
406 * });
407 *
408 * @param {function(ElementFinder)} fn Input function
409 *
410 * @returns {!webdriver.promise.Promise} A promise that will resolve when the
411 * function has been called on all the ElementFinders. The promise will
412 * resolve to null.
413 */
414 each(fn: (elementFinder?: ElementFinder, index?: number) => any): wdpromise.Promise<any>;
415 /**
416 * Apply a map function to each element within the ElementArrayFinder. The
417 * callback receives the ElementFinder as the first argument and the index as
418 * a second arg.
419 *
420 * @alias element.all(locator).map(mapFunction)
421 * @view
422 * <ul class="items">
423 * <li class="one">First</li>
424 * <li class="two">Second</li>
425 * <li class="three">Third</li>
426 * </ul>
427 *
428 * @example
429 * let items = element.all(by.css('.items li')).map(function(elm, index) {
430 * return {
431 * index: index,
432 * text: elm.getText(),
433 * class: elm.getAttribute('class')
434 * };
435 * });
436 * expect(items).toEqual([
437 * {index: 0, text: 'First', class: 'one'},
438 * {index: 1, text: 'Second', class: 'two'},
439 * {index: 2, text: 'Third', class: 'three'}
440 * ]);
441 *
442 * // Or using the shortcut $$() notation instead of element.all(by.css()):
443 *
444 * let items = $$('.items li').map(function(elm, index) {
445 * return {
446 * index: index,
447 * text: elm.getText(),
448 * class: elm.getAttribute('class')
449 * };
450 * });
451 * expect(items).toEqual([
452 * {index: 0, text: 'First', class: 'one'},
453 * {index: 1, text: 'Second', class: 'two'},
454 * {index: 2, text: 'Third', class: 'three'}
455 * ]);
456 *
457 * @param {function(ElementFinder, number)} mapFn Map function that
458 * will be applied to each element.
459 * @returns {!webdriver.promise.Promise} A promise that resolves to an array
460 * of values returned by the map function.
461 */
462 map<T>(mapFn: (elementFinder?: ElementFinder, index?: number) => T | any): wdpromise.Promise<T[]>;
463 /**
464 * Apply a reduce function against an accumulator and every element found
465 * using the locator (from left-to-right). The reduce function has to reduce
466 * every element into a single value (the accumulator). Returns promise of
467 * the accumulator. The reduce function receives the accumulator, current
468 * ElementFinder, the index, and the entire array of ElementFinders,
469 * respectively.
470 *
471 * @alias element.all(locator).reduce(reduceFn)
472 * @view
473 * <ul class="items">
474 * <li class="one">First</li>
475 * <li class="two">Second</li>
476 * <li class="three">Third</li>
477 * </ul>
478 *
479 * @example
480 * let value = element.all(by.css('.items li')).reduce(function(acc, elem) {
481 * return elem.getText().then(function(text) {
482 * return acc + text + ' ';
483 * });
484 * }, '');
485 *
486 * expect(value).toEqual('First Second Third ');
487 *
488 * // Or using the shortcut $$() notation instead of element.all(by.css()):
489 *
490 * let value = $$('.items li').reduce(function(acc, elem) {
491 * return elem.getText().then(function(text) {
492 * return acc + text + ' ';
493 * });
494 * }, '');
495 *
496 * expect(value).toEqual('First Second Third ');
497 *
498 * @param {function(number, ElementFinder, number, Array.<ElementFinder>)}
499 * reduceFn Reduce function that reduces every element into a single
500 * value.
501 * @param {*} initialValue Initial value of the accumulator.
502 * @returns {!webdriver.promise.Promise} A promise that resolves to the final
503 * value of the accumulator.
504 */
505 reduce(reduceFn: Function, initialValue: any): wdpromise.Promise<any>;
506 /**
507 * Evaluates the input as if it were on the scope of the current underlying
508 * elements.
509 *
510 * @view
511 * <span class="foo">{{letiableInScope}}</span>
512 *
513 * @example
514 * let value = element.all(by.css('.foo')).evaluate('letiableInScope');
515 *
516 * // Or using the shortcut $$() notation instead of element.all(by.css()):
517 *
518 * let value = $$('.foo').evaluate('letiableInScope');
519 *
520 * @param {string} expression
521 *
522 * @returns {ElementArrayFinder} which resolves to the
523 * evaluated expression for each underlying element.
524 * The result will be resolved as in
525 * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
526 * be resolved as is, functions will be converted to string, and elements
527 * will be returned as a WebElement.
528 */
529 evaluate(expression: string): ElementArrayFinder;
530 /**
531 * Determine if animation is allowed on the current underlying elements.
532 * @param {string} value
533 *
534 * @example
535 * // Turns off ng-animate animations for all elements in the <body>
536 * element(by.css('body')).allowAnimations(false);
537 *
538 * // Or using the shortcut $() notation instead of element(by.css()):
539 *
540 * $('body').allowAnimations(false);
541 *
542 * @returns {ElementArrayFinder} which resolves to whether animation is
543 * allowed.
544 */
545 allowAnimations(value: boolean): ElementArrayFinder;
546}
547/**
548 * The ElementFinder simply represents a single element of an
549 * ElementArrayFinder (and is more like a convenience object). As a result,
550 * anything that can be done with an ElementFinder, can also be done using
551 * an ElementArrayFinder.
552 *
553 * The ElementFinder can be treated as a WebElement for most purposes, in
554 * particular, you may perform actions (i.e. click, getText) on them as you
555 * would a WebElement. Once an action is performed on an ElementFinder, the
556 * latest result from the chain can be accessed using the then method.
557 * Unlike a WebElement, an ElementFinder will wait for angular to settle before
558 * performing finds or actions.
559 *
560 * ElementFinder can be used to build a chain of locators that is used to find
561 * an element. An ElementFinder does not actually attempt to find the element
562 * until an action is called, which means they can be set up in helper files
563 * before the page is available.
564 *
565 * @alias element(locator)
566 * @view
567 * <span>{{person.name}}</span>
568 * <span ng-bind="person.email"></span>
569 * <input type="text" ng-model="person.name"/>
570 *
571 * @example
572 * // Find element with {{scopelet}} syntax.
573 * element(by.binding('person.name')).getText().then(function(name) {
574 * expect(name).toBe('Foo');
575 * });
576 *
577 * // Find element with ng-bind="scopelet" syntax.
578 * expect(element(by.binding('person.email')).getText()).toBe('foo@bar.com');
579 *
580 * // Find by model.
581 * let input = element(by.model('person.name'));
582 * input.sendKeys('123');
583 * expect(input.getAttribute('value')).toBe('Foo123');
584 *
585 * @constructor
586 * @extends {webdriver.WebElement}
587 * @param {ProtractorBrowser} browser_ A browser instance.
588 * @param {ElementArrayFinder} elementArrayFinder The ElementArrayFinder
589 * that this is branched from.
590 * @returns {ElementFinder}
591 */
592export declare class ElementFinder extends WebdriverWebElement {
593 browser_: ProtractorBrowser;
594 parentElementArrayFinder: ElementArrayFinder;
595 elementArrayFinder_: ElementArrayFinder;
596 then?: (fn: (value: any) => any | wdpromise.IThenable<any>, errorFn?: (error: any) => any) => wdpromise.Promise<any>;
597 constructor(browser_: ProtractorBrowser, elementArrayFinder: ElementArrayFinder);
598 static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator?: Locator): ElementFinder;
599 /**
600 * Create a shallow copy of ElementFinder.
601 *
602 * @returns {!ElementFinder} A shallow copy of this.
603 */
604 clone(): ElementFinder;
605 /**
606 * @see ElementArrayFinder.prototype.locator
607 *
608 * @returns {webdriver.Locator}
609 */
610 locator(): any;
611 /**
612 * Returns the WebElement represented by this ElementFinder.
613 * Throws the WebDriver error if the element doesn't exist.
614 *
615 * @alias element(locator).getWebElement()
616 * @view
617 * <div class="parent">
618 * some text
619 * </div>
620 *
621 * @example
622 * // The following four expressions are equivalent.
623 * $('.parent').getWebElement();
624 * element(by.css('.parent')).getWebElement();
625 * browser.driver.findElement(by.css('.parent'));
626 * browser.findElement(by.css('.parent'));
627 *
628 * @returns {webdriver.WebElementPromise}
629 */
630 getWebElement(): WebElementPromise;
631 /**
632 * Calls to {@code all} may be chained to find an array of elements within a
633 * parent.
634 *
635 * @alias element(locator).all(locator)
636 * @view
637 * <div class="parent">
638 * <ul>
639 * <li class="one">First</li>
640 * <li class="two">Second</li>
641 * <li class="three">Third</li>
642 * </ul>
643 * </div>
644 *
645 * @example
646 * let items = element(by.css('.parent')).all(by.tagName('li'));
647 *
648 * // Or using the shortcut $() notation instead of element(by.css()):
649 *
650 * let items = $('.parent').all(by.tagName('li'));
651 *
652 * @param {webdriver.Locator} subLocator
653 * @returns {ElementArrayFinder}
654 */
655 all(subLocator: Locator): ElementArrayFinder;
656 /**
657 * Calls to {@code element} may be chained to find elements within a parent.
658 *
659 * @alias element(locator).element(locator)
660 * @view
661 * <div class="parent">
662 * <div class="child">
663 * Child text
664 * <div>{{person.phone}}</div>
665 * </div>
666 * </div>
667 *
668 * @example
669 * // Chain 2 element calls.
670 * let child = element(by.css('.parent')).
671 * element(by.css('.child'));
672 * expect(child.getText()).toBe('Child text\n555-123-4567');
673 *
674 * // Chain 3 element calls.
675 * let triple = element(by.css('.parent')).
676 * element(by.css('.child')).
677 * element(by.binding('person.phone'));
678 * expect(triple.getText()).toBe('555-123-4567');
679 *
680 * // Or using the shortcut $() notation instead of element(by.css()):
681 *
682 * // Chain 2 element calls.
683 * let child = $('.parent').$('.child');
684 * expect(child.getText()).toBe('Child text\n555-123-4567');
685 *
686 * // Chain 3 element calls.
687 * let triple = $('.parent').$('.child').
688 * element(by.binding('person.phone'));
689 * expect(triple.getText()).toBe('555-123-4567');
690 *
691 * @param {webdriver.Locator} subLocator
692 * @returns {ElementFinder}
693 */
694 element(subLocator: Locator): ElementFinder;
695 /**
696 * Calls to {@code $$} may be chained to find an array of elements within a
697 * parent.
698 *
699 * @alias element(locator).all(selector)
700 * @view
701 * <div class="parent">
702 * <ul>
703 * <li class="one">First</li>
704 * <li class="two">Second</li>
705 * <li class="three">Third</li>
706 * </ul>
707 * </div>
708 *
709 * @example
710 * let items = element(by.css('.parent')).$$('li');
711 *
712 * // Or using the shortcut $() notation instead of element(by.css()):
713 *
714 * let items = $('.parent').$$('li');
715 *
716 * @param {string} selector a css selector
717 * @returns {ElementArrayFinder}
718 */
719 $$(selector: string): ElementArrayFinder;
720 /**
721 * Calls to {@code $} may be chained to find elements within a parent.
722 *
723 * @alias element(locator).$(selector)
724 * @view
725 * <div class="parent">
726 * <div class="child">
727 * Child text
728 * <div>{{person.phone}}</div>
729 * </div>
730 * </div>
731 *
732 * @example
733 * // Chain 2 element calls.
734 * let child = element(by.css('.parent')).
735 * $('.child');
736 * expect(child.getText()).toBe('Child text\n555-123-4567');
737 *
738 * // Chain 3 element calls.
739 * let triple = element(by.css('.parent')).
740 * $('.child').
741 * element(by.binding('person.phone'));
742 * expect(triple.getText()).toBe('555-123-4567');
743 *
744 * // Or using the shortcut $() notation instead of element(by.css()):
745 *
746 * // Chain 2 element calls.
747 * let child = $('.parent').$('.child');
748 * expect(child.getText()).toBe('Child text\n555-123-4567');
749 *
750 * // Chain 3 element calls.
751 * let triple = $('.parent').$('.child').
752 * element(by.binding('person.phone'));
753 * expect(triple.getText()).toBe('555-123-4567');
754 *
755 * @param {string} selector A css selector
756 * @returns {ElementFinder}
757 */
758 $(selector: string): ElementFinder;
759 /**
760 * Determine whether the element is present on the page.
761 *
762 * @view
763 * <span>{{person.name}}</span>
764 *
765 * @example
766 * // Element exists.
767 * expect(element(by.binding('person.name')).isPresent()).toBe(true);
768 *
769 * // Element not present.
770 * expect(element(by.binding('notPresent')).isPresent()).toBe(false);
771 *
772 * @returns {webdriver.promise.Promise<boolean>} which resolves to whether
773 * the element is present on the page.
774 */
775 isPresent(): wdpromise.Promise<boolean>;
776 /**
777 * Same as ElementFinder.isPresent(), except this checks whether the element
778 * identified by the subLocator is present, rather than the current element
779 * finder, i.e.: `element(by.css('#abc')).element(by.css('#def')).isPresent()`
780 * is identical to `element(by.css('#abc')).isElementPresent(by.css('#def'))`.
781 *
782 * // Or using the shortcut $() notation instead of element(by.css()):
783 *
784 * `$('#abc').$('#def').isPresent()` is identical to
785 * `$('#abc').isElementPresent($('#def'))`.
786 *
787 * @see ElementFinder.isPresent
788 *
789 * @param {webdriver.Locator} subLocator Locator for element to look for.
790 * @returns {webdriver.promise.Promise<boolean>} which resolves to whether
791 * the subelement is present on the page.
792 */
793 isElementPresent(subLocator: Locator): wdpromise.Promise<boolean>;
794 /**
795 * Evaluates the input as if it were on the scope of the current element.
796 * @see ElementArrayFinder.prototype.evaluate
797 *
798 * @view
799 * <span id="foo">{{letiableInScope}}</span>
800 *
801 * @example
802 * let value = element(by.id('foo')).evaluate('letiableInScope');
803 *
804 * @param {string} expression
805 *
806 * @returns {ElementFinder} which resolves to the evaluated expression.
807 */
808 evaluate(expression: string): ElementFinder;
809 /**
810 * @see ElementArrayFinder.prototype.allowAnimations.
811 * @param {string} value
812 *
813 * @returns {ElementFinder} which resolves to whether animation is allowed.
814 */
815 allowAnimations(value: boolean): ElementFinder;
816 /**
817 * Compares an element to this one for equality.
818 *
819 * @param {!ElementFinder|!webdriver.WebElement} The element to compare to.
820 *
821 * @returns {!webdriver.promise.Promise.<boolean>} A promise that will be
822 * resolved to whether the two WebElements are equal.
823 */
824 equals(element: ElementFinder | WebElement): wdpromise.Promise<any>;
825}
826/**
827 * Shortcut for querying the document directly with css.
828 * `element(by.css('.abc'))` is equivalent to `$('.abc')`
829 *
830 * @alias $(cssSelector)
831 * @view
832 * <div class="count">
833 * <span class="one">First</span>
834 * <span class="two">Second</span>
835 * </div>
836 *
837 * @example
838 * let item = $('.count .two');
839 * expect(item.getText()).toBe('Second');
840 *
841 * @param {string} selector A css selector
842 * @returns {ElementFinder} which identifies the located
843 * {@link webdriver.WebElement}
844 */
845export declare let build$: (element: ElementHelper, by: typeof By) => (selector: string) => ElementFinder;
846/**
847 * Shortcut for querying the document directly with css.
848 * `element.all(by.css('.abc'))` is equivalent to `$$('.abc')`
849 *
850 * @alias $$(cssSelector)
851 * @view
852 * <div class="count">
853 * <span class="one">First</span>
854 * <span class="two">Second</span>
855 * </div>
856 *
857 * @example
858 * // The following protractor expressions are equivalent.
859 * let list = element.all(by.css('.count span'));
860 * expect(list.count()).toBe(2);
861 *
862 * list = $$('.count span');
863 * expect(list.count()).toBe(2);
864 * expect(list.get(0).getText()).toBe('First');
865 * expect(list.get(1).getText()).toBe('Second');
866 *
867 * @param {string} selector a css selector
868 * @returns {ElementArrayFinder} which identifies the
869 * array of the located {@link webdriver.WebElement}s.
870 */
871export declare let build$$: (element: ElementHelper, by: typeof By) => (selector: string) => ElementArrayFinder;