UNPKG

28.3 kBJavaScriptView Raw
1// Used to provide better protractor documentation for webdriver. These files
2// are not used to provide code for protractor and are only used for the website.
3
4/**
5 * @fileoverview The heart of the WebDriver JavaScript API.
6 */
7
8goog.provide('webdriver');
9
10/**
11 * Class for defining sequences of complex user interactions.
12 * @external webdriver.ActionSequence
13 * @see http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/actions_exports_ActionSequence.html
14 */
15webdriver.ActionSequence = function() {};
16
17/**
18 * Class for defining sequences of user touch interactions.
19 * @external webdriver.TouchSequence
20 * @see http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_TouchSequence.html
21 */
22webdriver.TouchSequence = function() {};
23
24// //////////////////////////////////////////////////////////////////////////////
25// //
26// // webdriver.WebDriver
27// //
28// /////////////////////////////////////////////////////////////////////////////
29/**
30 * Protractor's `browser` object is a wrapper for `selenium-webdriver` WebDriver.
31 * It inherits call of WebDriver's methods, but only the methods most useful to
32 * Protractor users are documented here.
33 *
34 * A full list of all functions available on WebDriver can be found
35 * in the selenium-webdriver
36 * <a href="http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html">documentation</a>
37 * @constructor
38 */
39webdriver.WebDriver = function() {};
40
41/**
42 * Creates a sequence of user actions using this driver. The sequence will not be
43 * scheduled for execution until {@link webdriver.ActionSequence#perform} is
44 * called.
45 *
46 * See the selenium webdriver docs <a href="http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/actions_exports_ActionSequence.html">
47 * for more details on action sequences</a>.
48 *
49 * Mouse actions do not work on Chrome with the HTML5 Drag and Drop API due to a known <a href="https://bugs.chromium.org/p/chromedriver/issues/detail?id=841">
50 * Chromedriver issue</a>
51 *
52 * @example
53 * // Dragging one element to another.
54 * browser.actions().
55 * mouseDown(element1).
56 * mouseMove(element2).
57 * mouseUp().
58 * perform();
59 *
60 * // You can also use the `dragAndDrop` convenience action.
61 * browser.actions().
62 * dragAndDrop(element1, element2).
63 * perform();
64 *
65 * // Instead of specifying an element as the target, you can specify an offset
66 * // in pixels. This example double-clicks slightly to the right of an element.
67 * browser.actions().
68 * mouseMove(element).
69 * mouseMove({x: 50, y: 0}).
70 * doubleClick().
71 * perform();
72 *
73 * @returns {!webdriver.ActionSequence} A new action sequence for this instance.
74 */
75webdriver.WebDriver.prototype.actions = function() {};
76
77/**
78 * Creates a new touch sequence using this driver. The sequence will not be
79 * scheduled for execution until {@link actions.TouchSequence#perform} is
80 * called.
81 *
82 * See the selenium webdriver docs <a href="http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_TouchSequence.html">
83 * for more details on touch sequences</a>.
84 *
85 * @example
86 * browser.touchActions().
87 * tap(element1).
88 * doubleTap(element2).
89 * perform();
90 *
91 * @return {!webdriver.TouchSequence} A new touch sequence for this instance.
92 */
93webdriver.WebDriver.prototype.touchActions = function() {};
94
95/**
96 * Schedules a command to execute JavaScript in the context of the currently
97 * selected frame or window. The script fragment will be executed as the body
98 * of an anonymous function. If the script is provided as a function object,
99 * that function will be converted to a string for injection into the target
100 * window.
101 *
102 * Any arguments provided in addition to the script will be included as script
103 * arguments and may be referenced using the {@code arguments} object.
104 * Arguments may be a boolean, number, string, or {@linkplain WebElement}.
105 * Arrays and objects may also be used as script arguments as long as each item
106 * adheres to the types previously mentioned.
107 *
108 * The script may refer to any variables accessible from the current window.
109 * Furthermore, the script will execute in the window's context, thus
110 * {@code document} may be used to refer to the current document. Any local
111 * variables will not be available once the script has finished executing,
112 * though global variables will persist.
113 *
114 * If the script has a return value (i.e. if the script contains a return
115 * statement), then the following steps will be taken for resolving this
116 * functions return value:
117 *
118 * - For a HTML element, the value will resolve to a {@linkplain WebElement}
119 * - Null and undefined return values will resolve to null</li>
120 * - Booleans, numbers, and strings will resolve as is</li>
121 * - Functions will resolve to their string representation</li>
122 * - For arrays and objects, each member item will be converted according to
123 * the rules above
124 *
125 * @example
126 * var el = element(by.module('header'));
127 * var tag = browser.executeScript('return arguments[0].tagName', el);
128 * expect(tag).toEqual('h1');
129 *
130 * @param {!(string|Function)} script The script to execute.
131 * @param {...*} var_args The arguments to pass to the script.
132 * @return {!promise.Promise<T>} A promise that will resolve to the
133 * scripts return value.
134 * @template T
135 */
136webdriver.WebDriver.prototype.executeScript = function(script, var_args) {};
137
138/**
139 * Schedules a command to execute asynchronous JavaScript in the context of the
140 * currently selected frame or window. The script fragment will be executed as
141 * the body of an anonymous function. If the script is provided as a function
142 * object, that function will be converted to a string for injection into the
143 * target window.
144 *
145 * Any arguments provided in addition to the script will be included as script
146 * arguments and may be referenced using the {@code arguments} object.
147 * Arguments may be a boolean, number, string, or {@code WebElement}.
148 * Arrays and objects may also be used as script arguments as long as each item
149 * adheres to the types previously mentioned.
150 *
151 * Unlike executing synchronous JavaScript with {@link #executeScript},
152 * scripts executed with this function must explicitly signal they are finished
153 * by invoking the provided callback. This callback will always be injected
154 * into the executed function as the last argument, and thus may be referenced
155 * with {@code arguments[arguments.length - 1]}. The following steps will be
156 * taken for resolving this functions return value against the first argument
157 * to the script's callback function:
158 *
159 * - For a HTML element, the value will resolve to a
160 * {@link WebElement}
161 * - Null and undefined return values will resolve to null
162 * - Booleans, numbers, and strings will resolve as is
163 * - Functions will resolve to their string representation
164 * - For arrays and objects, each member item will be converted according to
165 * the rules above
166 *
167 * @example
168 * // Example 1
169 * // Performing a sleep that is synchronized with the currently selected window
170 * var start = new Date().getTime();
171 * browser.executeAsyncScript(
172 * 'window.setTimeout(arguments[arguments.length - 1], 500);').
173 * then(function() {
174 * console.log(
175 * 'Elapsed time: ' + (new Date().getTime() - start) + ' ms');
176 * });
177 *
178 * // Example 2
179 * // Synchronizing a test with an AJAX application:
180 * var button = element(by.id('compose-button'));
181 * button.click();
182 * browser.executeAsyncScript(
183 * 'var callback = arguments[arguments.length - 1];' +
184 * 'mailClient.getComposeWindowWidget().onload(callback);');
185 * browser.switchTo().frame('composeWidget');
186 * element(by.id('to')).sendKeys('dog@example.com');
187 *
188 * // Example 3
189 * // Injecting a XMLHttpRequest and waiting for the result. In this example,
190 * // the inject script is specified with a function literal. When using this
191 * // format, the function is converted to a string for injection, so it should
192 * // not reference any symbols not defined in the scope of the page under test.
193 * browser.executeAsyncScript(function() {
194 * var callback = arguments[arguments.length - 1];
195 * var xhr = new XMLHttpRequest();
196 * xhr.open("GET", "/resource/data.json", true);
197 * xhr.onreadystatechange = function() {
198 * if (xhr.readyState == 4) {
199 * callback(xhr.responseText);
200 * }
201 * };
202 * xhr.send('');
203 * }).then(function(str) {
204 * console.log(JSON.parse(str)['food']);
205 * });
206 *
207 * @param {!(string|Function)} script The script to execute.
208 * @param {...*} var_args The arguments to pass to the script.
209 * @return {!promise.Promise<T>} A promise that will resolve to the
210 * scripts return value.
211 * @template T
212 */
213webdriver.WebDriver.prototype.executeAsyncScript = (script, var_args) => {};
214
215/**
216 * Schedules a command to execute a custom function within the context of
217 * webdriver's control flow.
218 *
219 * Most webdriver actions are asynchronous, but the control flow makes sure that
220 * commands are executed in the order they were received. By running your
221 * function in the control flow, you can ensure that it is executed before/after
222 * other webdriver actions. Additionally, Protractor will wait until the
223 * control flow is empty before deeming a test finished.
224 *
225 * @example
226 * var logText = function(el) {
227 * return el.getText().then((text) => {
228 * console.log(text);
229 * });
230 * };
231 * var counter = element(by.id('counter'));
232 * var button = element(by.id('button'));
233 * // Use `browser.call()` to make sure `logText` is run before and after
234 * // `button.click()`
235 * browser.call(logText, counter);
236 * button.click();
237 * browser.call(logText, counter);
238 *
239 * @param {function(...): (T|promise.Promise<T>)} fn The function to
240 * execute.
241 * @param {Object=} opt_scope The object in whose scope to execute the function
242 * (i.e. the `this` object for the function).
243 * @param {...*} var_args Any arguments to pass to the function. If any of the
244 * arguments are promised, webdriver will wait for these promised to resolve
245 * and pass the resulting value onto the function.
246 * @return {!promise.Promise<T>} A promise that will be resolved
247 * with the function's result.
248 * @template T
249 */
250webdriver.WebDriver.prototype.call = function(fn, opt_scope, var_args) {};
251
252/**
253 * Schedules a command to wait for a condition to hold or {@link
254 * webdriver.promise.Promise promise} to be resolved.
255 *
256 * This function blocks WebDriver's control flow, not the javascript runtime.
257 * It will only delay future webdriver commands from being executed (e.g. it
258 * will cause Protractor to wait before sending future commands to the selenium
259 * server), and only when the webdriver control flow is enabled.
260 *
261 * This function returnes a promise, which can be used if you need to block
262 * javascript execution and not just the control flow.
263 *
264 * See also {@link ExpectedConditions}
265 *
266 * *Example:* Suppose you have a function, `startTestServer`, that returns a
267 * promise for when a server is ready for requests. You can block a `WebDriver`
268 * client on this promise with:
269 *
270 * @example
271 * var started = startTestServer();
272 * browser.wait(started, 5 * 1000, 'Server should start within 5 seconds');
273 * browser.get(getServerUrl());
274 *
275 * @param {!(webdriver.promise.Promise<T>|
276 * webdriver.until.Condition<T>|
277 * function(!webdriver.WebDriver): T)} condition The condition to
278 * wait on, defined as a promise, condition object, or a function to
279 * evaluate as a condition.
280 * @param {number=} opt_timeout How long to wait for the condition to be true. Will default 30 seconds, or to the jasmineNodeOpts.defaultTimeoutInterval in your protractor.conf.js file.
281 * @param {string=} opt_message An optional message to use if the wait times
282 * out.
283 * @returns {!webdriver.promise.Promise<T>} A promise that will be fulfilled
284 * with the first truthy value returned by the condition function, or
285 * rejected if the condition times out.
286 */
287webdriver.WebDriver.prototype.wait = function() {};
288
289/**
290 * Schedules a command to make the driver sleep for the given amount of time.
291 * @param {number} ms The amount of time, in milliseconds, to sleep.
292 * @returns {!webdriver.promise.Promise.<void>} A promise that will be resolved
293 * when the sleep has finished.
294 */
295webdriver.WebDriver.prototype.sleep = function() {};
296
297/**
298 * Schedules a command to retrieve the current page's source. The page source
299 * returned is a representation of the underlying DOM: do not expect it to be
300 * formatted or escaped in the same way as the response sent from the web
301 * server.
302 * @return {!promise.Promise<string>} A promise that will be
303 * resolved with the current page source.
304 */
305webdriver.WebDriver.prototype.getPageSource = function() {};
306
307/**
308 * Schedules a command to close the current window.
309 * @return {!promise.Promise<void>} A promise that will be resolved
310 * when this command has completed.
311 */
312webdriver.WebDriver.prototype.close = function() {};
313
314/**
315 * Schedules a command to retrieve the URL of the current page.
316 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
317 * resolved with the current URL.
318 */
319webdriver.WebDriver.prototype.getCurrentUrl = function() {};
320
321/**
322 * Schedules a command to retrieve the current page's title.
323 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
324 * resolved with the current page's title.
325 */
326webdriver.WebDriver.prototype.getTitle = function() {};
327
328/**
329 * Schedule a command to take a screenshot. The driver makes a best effort to
330 * return a screenshot of the following, in order of preference:
331 * <ol>
332 * <li>Entire page
333 * <li>Current window
334 * <li>Visible portion of the current frame
335 * <li>The screenshot of the entire display containing the browser
336 * </ol>
337 *
338 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
339 * resolved to the screenshot as a base-64 encoded PNG.
340 */
341webdriver.WebDriver.prototype.takeScreenshot = function() {};
342
343/**
344 * Used to switch WebDriver's focus to a frame or window (e.g. an alert, an
345 * iframe, another window).
346 *
347 * See [WebDriver's TargetLocator Docs](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_TargetLocator.html)
348 * for more information.
349 *
350 * @example
351 * browser.switchTo().frame(element(by.tagName('iframe')).getWebElement());
352 *
353 * @return {!TargetLocator} The target locator interface for this
354 * instance.
355 */
356webdriver.WebDriver.prototype.switchTo = function() {}
357
358// /////////////////////////////////////////////////////////////////////////////
359// //
360// // webdriver.WebElement
361// //
362// /////////////////////////////////////////////////////////////////////////////
363//
364//
365//
366/**
367 * Protractor's ElementFinders are wrappers for selenium-webdriver WebElement.
368 * A full list of all functions available on WebElement can be found
369 * in the selenium-webdriver
370 * <a href="http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebElement.html">documentation</a>.
371 *
372 * @param {!webdriver.WebDriver} driver The webdriver driver or the parent WebDriver instance for this
373 * element.
374 * @param {!(webdriver.promise.Promise.<webdriver.WebElement.Id>|
375 * webdriver.WebElement.Id)} id The server-assigned opaque ID for the
376 * underlying DOM element.
377 * @constructor
378 */
379webdriver.WebElement = function(driver, id) {};
380
381/**
382 * Gets the parent web element of this web element.
383 *
384 * @view
385 * <ul class="pet">
386 * <li class="dog">Dog</li>
387 * <li class="cat">Cat</li>
388 * </ul>
389 *
390 * @example
391 * // Using getDriver to find the parent web element to find the cat li
392 * var liDog = element(by.css('.dog')).getWebElement();
393 * var liCat = liDog.getDriver().findElement(by.css('.cat'));
394 *
395 * @returns {!webdriver.WebDriver} The parent driver for this instance.
396 */
397webdriver.WebElement.prototype.getDriver = function() {};
398
399
400/**
401 * Gets the WebDriver ID string representation for this web element.
402 *
403 * @view
404 * <ul class="pet">
405 * <li class="dog">Dog</li>
406 * <li class="cat">Cat</li>
407 * </ul>
408 *
409 * @example
410 * // returns the dog web element
411 * var dog = element(by.css('.dog')).getWebElement();
412 * expect(dog.getId()).not.toBe(undefined);
413 *
414 * @returns {!webdriver.promise.Promise.<webdriver.WebElement.Id>} A promise
415 * that resolves to this element's JSON representation as defined by the
416 * WebDriver wire protocol.
417 * @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
418 */
419webdriver.WebElement.prototype.getId = function() {};
420
421/**
422 * Use {@link ElementFinder.prototype.element} instead
423 *
424 * @see ElementFinder.prototype.element
425 *
426 * @param {webdriver.Locator} subLocator
427 *
428 * @returns {!webdriver.WebElement}
429 */
430webdriver.WebElement.prototype.findElement = function(subLocator) {};
431
432
433/**
434 * Schedules a command to click on this element.
435 *
436 * @view
437 * <ul>
438 * <li><a href="https://en.wikipedia.org/wiki/Doge_(meme)">Doge meme</a></li>
439 * <li>Cat</li>
440 * </ul>
441 *
442 * @example
443 * // Clicks on the web link
444 * element(by.partialLinkText('Doge')).click();
445 *
446 * @returns {!webdriver.promise.Promise.<void>} A promise that will be resolved
447 * when the click command has completed.
448 */
449webdriver.WebElement.prototype.click = function() {};
450
451
452/**
453 * Schedules a command to type a sequence on the DOM element represented by this
454 * instance.
455 *
456 * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
457 * processed in the keysequence, that key state is toggled until one of the
458 * following occurs:
459 *
460 * - The modifier key is encountered again in the sequence. At this point the
461 * state of the key is toggled (along with the appropriate keyup/down events).
462 * - The {@link webdriver.Key.NULL} key is encountered in the sequence. When
463 * this key is encountered, all modifier keys current in the down state are
464 * released (with accompanying keyup events). The NULL key can be used to
465 * simulate common keyboard shortcuts:
466 *
467 * element.sendKeys("text was",
468 * protractor.Key.CONTROL, "a", protractor.Key.NULL,
469 * "now text is");
470 * // Alternatively:
471 * element.sendKeys("text was",
472 * protractor.Key.chord(protractor.Key.CONTROL, "a"),
473 * "now text is");
474 *
475 * - The end of the keysequence is encountered. When there are no more keys
476 * to type, all depressed modifier keys are released (with accompanying keyup
477 * events).
478 *
479 * If this element is a file input ({@code <input type="file">}), the
480 * specified key sequence should specify the path to the file to attach to
481 * the element. This is analgous to the user clicking "Browse..." and entering
482 * the path into the file select dialog.
483 *
484 * var form = driver.findElement(By.css('form'));
485 * var element = form.findElement(By.css('input[type=file]'));
486 * element.sendKeys('/path/to/file.txt');
487 * form.submit();
488 *
489 * For uploads to function correctly, the entered path must reference a file
490 * on the _browser's_ machine, not the local machine running this script. When
491 * running against a remote Selenium server, a {@link webdriver.FileDetector}
492 * may be used to transparently copy files to the remote machine before
493 * attempting to upload them in the browser.
494 *
495 * __Note:__ On browsers where native keyboard events are not supported
496 * (e.g. Firefox on OS X), key events will be synthesized. Special
497 * punctionation keys will be synthesized according to a standard QWERTY en-us
498 * keyboard layout.
499 *
500 * @param {...(string|!webdriver.promise.Promise<string>)} var_args The sequence
501 * of keys to type. All arguments will be joined into a single sequence.
502 * @returns {!webdriver.promise.Promise.<void>} A promise that will be resolved
503 * when all keys have been typed.
504 */
505webdriver.WebElement.prototype.sendKeys = function(var_args) {};
506
507
508/**
509 * Gets the tag/node name of this element.
510 *
511 * @view
512 * <span>{{person.name}}</span>
513 *
514 * @example
515 * expect(element(by.binding('person.name')).getTagName()).toBe('span');
516 *
517 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
518 * resolved with the element's tag name.
519 */
520webdriver.WebElement.prototype.getTagName = function() {};
521
522
523/**
524 * Gets the computed style of an element. If the element inherits the named
525 * style from its parent, the parent will be queried for its value. Where
526 * possible, color values will be converted to their hex representation (e.g.
527 * #00ff00 instead of rgb(0, 255, 0)).
528 *
529 * _Warning:_ the value returned will be as the browser interprets it, so
530 * it may be tricky to form a proper assertion.
531 *
532 * @view
533 * <span style='color: #000000'>{{person.name}}</span>
534 *
535 * @example
536 * expect(element(by.binding('person.name')).getCssValue('color')).toBe('#000000');
537 *
538 * @param {string} cssStyleProperty The name of the CSS style property to look
539 * up.
540 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
541 * resolved with the requested CSS value.
542 */
543webdriver.WebElement.prototype.getCssValue = function(cssStyleProperty) {};
544
545
546/**
547 * Schedules a command to query for the value of the given attribute of the
548 * element. Will return the current value, even if it has been modified after
549 * the page has been loaded. More exactly, this method will return the value of
550 * the given attribute, unless that attribute is not present, in which case the
551 * value of the property with the same name is returned. If neither value is
552 * set, null is returned (for example, the "value" property of a textarea
553 * element). The "style" attribute is converted as best can be to a
554 * text representation with a trailing semi-colon. The following are deemed to
555 * be "boolean" attributes and will return either "true" or null:
556 *
557 * async, autofocus, autoplay, checked, compact, complete, controls, declare,
558 * defaultchecked, defaultselected, defer, disabled, draggable, ended,
559 * formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,
560 * loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,
561 * paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
562 * selected, spellcheck, truespeed, willvalidate
563 *
564 * Finally, the following commonly mis-capitalized attribute/property names
565 * are evaluated as expected:
566 *
567 * - "class"
568 * - "readonly"
569 *
570 * @view
571 * <div id="foo" class="bar"></div>
572 *
573 * @example
574 * var foo = element(by.id('foo'));
575 * expect(foo.getAttribute('class')).toEqual('bar');
576 *
577 * @param {string} attributeName The name of the attribute to query.
578 * @returns {!webdriver.promise.Promise.<?string>} A promise that will be
579 * resolved with the attribute's value. The returned value will always be
580 * either a string or null.
581 */
582webdriver.WebElement.prototype.getAttribute = function(attributeName) {};
583
584
585/**
586 * Get the visible innerText of this element, including sub-elements, without
587 * any leading or trailing whitespace. Visible elements are not hidden by CSS.
588 *
589 * @view
590 * <div id="foo" class="bar">Inner text</div>
591 *
592 * @example
593 * var foo = element(by.id('foo'));
594 * expect(foo.getText()).toEqual('Inner text');
595 *
596 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
597 * resolved with the element's visible text.
598 */
599webdriver.WebElement.prototype.getText = function() {};
600
601
602/**
603 * Schedules a command to compute the size of this element's bounding box, in
604 * pixels.
605 *
606 * @view
607 * <div id="foo" style="width:50px; height: 20px">
608 * Inner text
609 * </div>
610 *
611 * @example
612 * var foo = element(by.id('foo'));
613 * expect(foo.getSize()).toEqual(jasmine.objectContaining({
614 * width: 50,
615 * height: 20
616 * });
617 *
618 * @returns {!webdriver.promise.Promise.<{width: number, height: number}>} A
619 * promise that will be resolved with the element's size as a
620 * {@code {width:number, height:number}} object.
621 */
622webdriver.WebElement.prototype.getSize = function() {};
623
624
625/**
626 * Schedules a command to compute the location of this element in page space.
627 *
628 * @view
629 * <div id="foo" style="position: absolute; top:20px; left: 15px">
630 * Inner text
631 * </div>
632 *
633 * @example
634 * var foo = element(by.id('foo'));
635 * expect(foo.getLocation()).toEqual(jasmine.objectContaining({
636 * x: 15,
637 * y: 20
638 * });
639 *
640 * @returns {!webdriver.promise.Promise.<{x: number, y: number}>} A promise that
641 * will be resolved to the element's location as a
642 * {@code {x:number, y:number}} object.
643 */
644webdriver.WebElement.prototype.getLocation = function() {};
645
646
647/**
648 * Schedules a command to query whether the DOM element represented by this
649 * instance is enabled, as dicted by the {@code disabled} attribute.
650 *
651 * @view
652 * <input id="foo" disabled=true>
653 *
654 * @example
655 * var foo = element(by.id('foo'));
656 * expect(foo.isEnabled()).toBe(false);
657 *
658 * @returns {!webdriver.promise.Promise.<boolean>} A promise that will be
659 * resolved with whether this element is currently enabled.
660 */
661webdriver.WebElement.prototype.isEnabled = function() {};
662
663
664/**
665 * Schedules a command to query whether this element is selected.
666 *
667 * @view
668 * <input id="foo" type="checkbox">
669 *
670 * @example
671 * var foo = element(by.id('foo'));
672 * expect(foo.isSelected()).toBe(false);
673 * foo.click();
674 * expect(foo.isSelected()).toBe(true);
675 *
676 * @returns {!webdriver.promise.Promise.<boolean>} A promise that will be
677 * resolved with whether this element is currently selected.
678 */
679webdriver.WebElement.prototype.isSelected = function() {};
680
681
682/**
683 * Schedules a command to submit the form containing this element (or this
684 * element if it is a FORM element). This command is a no-op if the element is
685 * not contained in a form.
686 *
687 * @view
688 * <form id="login">
689 * <input name="user">
690 * </form>
691 *
692 * @example
693 * var login_form = element(by.id('login'));
694 * login_form.submit();
695 *
696 * @returns {!webdriver.promise.Promise.<void>} A promise that will be resolved
697 * when the form has been submitted.
698 */
699webdriver.WebElement.prototype.submit = function() {};
700
701
702/**
703 * Schedules a command to clear the {@code value} of this element. This command
704 * has no effect if the underlying DOM element is neither a text INPUT element
705 * nor a TEXTAREA element.
706 *
707 * @view
708 * <input id="foo" value="Default Text">
709 *
710 * @example
711 * var foo = element(by.id('foo'));
712 * expect(foo.getAttribute('value')).toEqual('Default Text');
713 * foo.clear();
714 * expect(foo.getAttribute('value')).toEqual('');
715 *
716 * @returns {!webdriver.promise.Promise.<void>} A promise that will be resolved
717 * when the element has been cleared.
718 */
719webdriver.WebElement.prototype.clear = function() {};
720
721
722/**
723 * Schedules a command to test whether this element is currently displayed.
724 *
725 * @view
726 * <div id="foo" style="visibility:hidden">
727 *
728 * @example
729 * var foo = element(by.id('foo'));
730 * expect(foo.isDisplayed()).toBe(false);
731 *
732 * @returns {!webdriver.promise.Promise.<boolean>} A promise that will be
733 * resolved with whether this element is currently visible on the page.
734 */
735webdriver.WebElement.prototype.isDisplayed = function() {};
736
737
738/**
739 * Take a screenshot of the visible region encompassed by this element's
740 * bounding rectangle.
741 *
742 * @view
743 * <div id="foo">Inner Text</div>
744 *
745 * @example
746 * function writeScreenShot(data, filename) {
747 * var stream = fs.createWriteStream(filename);
748 * stream.write(new Buffer(data, 'base64'));
749 * stream.end();
750 * }
751 * var foo = element(by.id('foo'));
752 * foo.takeScreenshot().then((png) => {
753 * writeScreenShot(png, 'foo.png');
754 * });
755 *
756 * Note that this is a new feature in WebDriver and may not be supported by
757 * your browser's driver. It isn't yet supported in Chromedriver as of 2.21.
758 *
759 * @param {boolean=} opt_scroll Optional argument that indicates whether the
760 * element should be scrolled into view before taking a screenshot. Defaults
761 * to false.
762 * @returns {!webdriver.promise.Promise.<string>} A promise that will be
763 * resolved to the screenshot as a base-64 encoded PNG.
764 */
765webdriver.WebElement.prototype.takeScreenshot = function(opt_scroll) {};