webdriver.js 28 KB

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