How to use webdriver method in pom

Best Python code snippet using pom_python

angular-protractor.d.ts

Source:angular-protractor.d.ts Github

copy

Full Screen

1// Compiled using typings@0.6.102// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/64b25f63f0ec821040a5d3e049a976865062ed9d/angular-protractor/angular-protractor.d.ts3// Type definitions for Angular Protractor 1.5.04// Project: https://github.com/angular/protractor5// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>6// Definitions: https://github.com/borisyankov/DefinitelyTyped7declare module protractor {8 //region Wrapped webdriver Items9 class ActionSequence extends webdriver.ActionSequence {}10 class Builder extends webdriver.Builder {}11 class Capabilities extends webdriver.Capabilities {}12 class Command extends webdriver.Command {}13 class EventEmitter extends webdriver.EventEmitter {}14 class Session extends webdriver.Session {}15 class WebDriver extends webdriver.WebDriver {}16 class WebElement extends webdriver.WebElement {}17 class WebElementPromise extends webdriver.WebElementPromise { }18 var Browser: webdriver.IBrowser;19 var Button: webdriver.IButton;20 var Capability: webdriver.ICapability;21 var CommandName: webdriver.ICommandName;22 var Key: webdriver.IKey;23 module error {24 class Error extends webdriver.error.Error {}25 var ErrorCode: webdriver.error.IErrorCode;26 }27 module logging {28 class Preferences extends webdriver.logging.Preferences { }29 class Entry extends webdriver.logging.Entry { }30 var Type: webdriver.logging.IType;31 var Level: webdriver.logging.ILevelValues;32 function getLevel(nameOrValue: string): webdriver.logging.ILevel;33 function getLevel(nameOrValue: number): webdriver.logging.ILevel;34 }35 module promise {36 class Thenable<T> extends webdriver.promise.Thenable<T> { }37 class Promise<T> extends webdriver.promise.Promise<T> { }38 class Deferred<T> extends webdriver.promise.Deferred<T> { }39 class ControlFlow extends webdriver.promise.ControlFlow { }40 class CancellationError extends webdriver.promise.CancellationError { }41 /**42 * Given an array of promises, will return a promise that will be fulfilled43 * with the fulfillment values of the input array's values. If any of the44 * input array's promises are rejected, the returned promise will be rejected45 * with the same reason.46 *47 * @param {!Array.<(T|!webdriver.promise.Promise.<T>)>} arr An array of48 * promises to wait on.49 * @return {!webdriver.promise.Promise.<!Array.<T>>} A promise that is50 * fulfilled with an array containing the fulfilled values of the51 * input array, or rejected with the same reason as the first52 * rejected value.53 * @template T54 */55 function all(arr: webdriver.promise.Promise<any>[]): webdriver.promise.Promise<any[]>;56 /**57 * Invokes the appropriate callback function as soon as a promised58 * {@code value} is resolved. This function is similar to59 * {@link webdriver.promise.when}, except it does not return a new promise.60 * @param {*} value The value to observe.61 * @param {Function} callback The function to call when the value is62 * resolved successfully.63 * @param {Function=} opt_errback The function to call when the value is64 * rejected.65 */66 function asap(value: any, callback: Function, opt_errback?: Function): void;67 /**68 * @return {!webdriver.promise.ControlFlow} The currently active control flow.69 */70 function controlFlow(): webdriver.promise.ControlFlow;71 /**72 * Creates a new control flow. The provided callback will be invoked as the73 * first task within the new flow, with the flow as its sole argument. Returns74 * a promise that resolves to the callback result.75 * @param {function(!webdriver.promise.ControlFlow)} callback The entry point76 * to the newly created flow.77 * @return {!webdriver.promise.Promise} A promise that resolves to the callback78 * result.79 */80 function createFlow<R>(callback: (flow: webdriver.promise.ControlFlow) => R): webdriver.promise.Promise<R>;81 /**82 * Determines whether a {@code value} should be treated as a promise.83 * Any object whose "then" property is a function will be considered a promise.84 *85 * @param {*} value The value to test.86 * @return {boolean} Whether the value is a promise.87 */88 function isPromise(value: any): boolean;89 /**90 * Tests is a function is a generator.91 * @param {!Function} fn The function to test.92 * @return {boolean} Whether the function is a generator.93 */94 function isGenerator(fn: Function): boolean;95 /**96 * Creates a promise that will be resolved at a set time in the future.97 * @param {number} ms The amount of time, in milliseconds, to wait before98 * resolving the promise.99 * @return {!webdriver.promise.Promise} The promise.100 */101 function delayed(ms: number): webdriver.promise.Promise<void>;102 /**103 * Calls a function for each element in an array, and if the function returns104 * true adds the element to a new array.105 *106 * <p>If the return value of the filter function is a promise, this function107 * will wait for it to be fulfilled before determining whether to insert the108 * element into the new array.109 *110 * <p>If the filter function throws or returns a rejected promise, the promise111 * returned by this function will be rejected with the same reason. Only the112 * first failure will be reported; all subsequent errors will be silently113 * ignored.114 *115 * @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The116 * array to iterator over, or a promise that will resolve to said array.117 * @param {function(this: SELF, TYPE, number, !Array.<TYPE>): (118 * boolean|webdriver.promise.Promise.<boolean>)} fn The function119 * to call for each element in the array.120 * @param {SELF=} opt_self The object to be used as the value of 'this' within121 * {@code fn}.122 * @template TYPE, SELF123 */124 function filter<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise<T[]>;125 function filter<T>(arr: webdriver.promise.Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise<T[]>126 /**127 * Creates a new deferred object.128 * @return {!webdriver.promise.Deferred} The new deferred object.129 */130 function defer<T>(): webdriver.promise.Deferred<T>;131 /**132 * Creates a promise that has been resolved with the given value.133 * @param {*=} opt_value The resolved value.134 * @return {!webdriver.promise.Promise} The resolved promise.135 */136 function fulfilled<T>(opt_value?: T): webdriver.promise.Promise<T>;137 /**138 * Calls a function for each element in an array and inserts the result into a139 * new array, which is used as the fulfillment value of the promise returned140 * by this function.141 *142 * <p>If the return value of the mapping function is a promise, this function143 * will wait for it to be fulfilled before inserting it into the new array.144 *145 * <p>If the mapping function throws or returns a rejected promise, the146 * promise returned by this function will be rejected with the same reason.147 * Only the first failure will be reported; all subsequent errors will be148 * silently ignored.149 *150 * @param {!(Array.<TYPE>|webdriver.promise.Promise.<!Array.<TYPE>>)} arr The151 * array to iterator over, or a promise that will resolve to said array.152 * @param {function(this: SELF, TYPE, number, !Array.<TYPE>): ?} fn The153 * function to call for each element in the array. This function should154 * expect three arguments (the element, the index, and the array itself.155 * @param {SELF=} opt_self The object to be used as the value of 'this' within156 * {@code fn}.157 * @template TYPE, SELF158 */159 function map<T>(arr: T[], fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise<T[]>160 function map<T>(arr: webdriver.promise.Promise<T[]>, fn: (element: T, index: number, array: T[]) => any, opt_self?: any): webdriver.promise.Promise<T[]>161 /**162 * Creates a promise that has been rejected with the given reason.163 * @param {*=} opt_reason The rejection reason; may be any value, but is164 * usually an Error or a string.165 * @return {!webdriver.promise.Promise} The rejected promise.166 */167 function rejected(opt_reason?: any): webdriver.promise.Promise<void>;168 /**169 * Wraps a function that is assumed to be a node-style callback as its final170 * argument. This callback takes two arguments: an error value (which will be171 * null if the call succeeded), and the success value as the second argument.172 * If the call fails, the returned promise will be rejected, otherwise it will173 * be resolved with the result.174 * @param {!Function} fn The function to wrap.175 * @return {!webdriver.promise.Promise} A promise that will be resolved with the176 * result of the provided function's callback.177 */178 function checkedNodeCall<T>(fn: Function, ...var_args: any[]): webdriver.promise.Promise<T>;179 /**180 * Consumes a {@code GeneratorFunction}. Each time the generator yields a181 * promise, this function will wait for it to be fulfilled before feeding the182 * fulfilled value back into {@code next}. Likewise, if a yielded promise is183 * rejected, the rejection error will be passed to {@code throw}.184 *185 * <p>Example 1: the Fibonacci Sequence.186 * <pre><code>187 * webdriver.promise.consume(function* fibonacci() {188 * var n1 = 1, n2 = 1;189 * for (var i = 0; i < 4; ++i) {190 * var tmp = yield n1 + n2;191 * n1 = n2;192 * n2 = tmp;193 * }194 * return n1 + n2;195 * }).then(function(result) {196 * console.log(result); // 13197 * });198 * </code></pre>199 *200 * <p>Example 2: a generator that throws.201 * <pre><code>202 * webdriver.promise.consume(function* () {203 * yield webdriver.promise.delayed(250).then(function() {204 * throw Error('boom');205 * });206 * }).thenCatch(function(e) {207 * console.log(e.toString()); // Error: boom208 * });209 * </code></pre>210 *211 * @param {!Function} generatorFn The generator function to execute.212 * @param {Object=} opt_self The object to use as "this" when invoking the213 * initial generator.214 * @param {...*} var_args Any arguments to pass to the initial generator.215 * @return {!webdriver.promise.Promise.<?>} A promise that will resolve to the216 * generator's final result.217 * @throws {TypeError} If the given function is not a generator.218 */219 function consume<T>(generatorFn: Function, opt_self?: any, ...var_args: any[]): webdriver.promise.Promise<T>;220 /**221 * Registers an observer on a promised {@code value}, returning a new promise222 * that will be resolved when the value is. If {@code value} is not a promise,223 * then the return promise will be immediately resolved.224 * @param {*} value The value to observe.225 * @param {Function=} opt_callback The function to call when the value is226 * resolved successfully.227 * @param {Function=} opt_errback The function to call when the value is228 * rejected.229 * @return {!webdriver.promise.Promise} A new promise.230 */231 function when<T, R>(value: T, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise<R>;232 function when<T, R>(value: webdriver.promise.Promise<T>, opt_callback?: (value: T) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise<R>;233 /**234 * Returns a promise that will be resolved with the input value in a235 * fully-resolved state. If the value is an array, each element will be fully236 * resolved. Likewise, if the value is an object, all keys will be fully237 * resolved. In both cases, all nested arrays and objects will also be238 * fully resolved. All fields are resolved in place; the returned promise will239 * resolve on {@code value} and not a copy.240 *241 * Warning: This function makes no checks against objects that contain242 * cyclical references:243 *244 * var value = {};245 * value['self'] = value;246 * webdriver.promise.fullyResolved(value); // Stack overflow.247 *248 * @param {*} value The value to fully resolve.249 * @return {!webdriver.promise.Promise} A promise for a fully resolved version250 * of the input value.251 */252 function fullyResolved<T>(value: any): webdriver.promise.Promise<T>;253 /**254 * Changes the default flow to use when no others are active.255 * @param {!webdriver.promise.ControlFlow} flow The new default flow.256 * @throws {Error} If the default flow is not currently active.257 */258 function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;259 }260 module stacktrace {261 class Frame extends webdriver.stacktrace.Frame { }262 class Snapshot extends webdriver.stacktrace.Snapshot { }263 /**264 * Formats an error's stack trace.265 * @param {!(Error|goog.testing.JsUnitException)} error The error to format.266 * @return {!(Error|goog.testing.JsUnitException)} The formatted error.267 */268 function format(error: any): any;269 /**270 * Gets the native stack trace if available otherwise follows the call chain.271 * The generated trace will exclude all frames up to and including the call to272 * this function.273 * @return {!Array.<!webdriver.stacktrace.Frame>} The frames of the stack trace.274 */275 function get(): webdriver.stacktrace.Frame[];276 /**277 * Whether the current browser supports stack traces.278 *279 * @type {boolean}280 * @const281 */282 var BROWSER_SUPPORTED: boolean;283 }284 module until {285 class Condition<T> extends webdriver.until.Condition<T> { }286 /**287 * Creates a condition that will wait until the input driver is able to switch288 * to the designated frame. The target frame may be specified as:289 * <ol>290 * <li>A numeric index into {@code window.frames} for the currently selected291 * frame.292 * <li>A {@link webdriver.WebElement}, which must reference a FRAME or IFRAME293 * element on the current page.294 * <li>A locator which may be used to first locate a FRAME or IFRAME on the295 * current page before attempting to switch to it.296 * </ol>297 *298 * <p>Upon successful resolution of this condition, the driver will be left299 * focused on the new frame.300 *301 * @param {!(number|webdriver.WebElement|302 * webdriver.Locator|webdriver.By.Hash|303 * function(!webdriver.WebDriver): !webdriver.WebElement)} frame304 * The frame identifier.305 * @return {!until.Condition.<boolean>} A new condition.306 */307 function ableToSwitchToFrame(frame: number): webdriver.until.Condition<boolean>;308 function ableToSwitchToFrame(frame: webdriver.IWebElement): webdriver.until.Condition<boolean>;309 function ableToSwitchToFrame(frame: webdriver.Locator): webdriver.until.Condition<boolean>;310 function ableToSwitchToFrame(frame: (webdriver: webdriver.WebDriver) => webdriver.IWebElement): webdriver.until.Condition<boolean>;311 function ableToSwitchToFrame(frame: any): webdriver.until.Condition<boolean>;312 /**313 * Creates a condition that waits for an alert to be opened. Upon success, the314 * returned promise will be fulfilled with the handle for the opened alert.315 *316 * @return {!until.Condition.<!webdriver.Alert>} The new condition.317 */318 function alertIsPresent(): webdriver.until.Condition<webdriver.Alert>;319 /**320 * Creates a condition that will wait for the given element to be disabled.321 *322 * @param {!webdriver.WebElement} element The element to test.323 * @return {!until.Condition.<boolean>} The new condition.324 * @see webdriver.WebDriver#isEnabled325 */326 function elementIsDisabled(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;327 /**328 * Creates a condition that will wait for the given element to be enabled.329 *330 * @param {!webdriver.WebElement} element The element to test.331 * @return {!until.Condition.<boolean>} The new condition.332 * @see webdriver.WebDriver#isEnabled333 */334 function elementIsEnabled(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;335 /**336 * Creates a condition that will wait for the given element to be deselected.337 *338 * @param {!webdriver.WebElement} element The element to test.339 * @return {!until.Condition.<boolean>} The new condition.340 * @see webdriver.WebDriver#isSelected341 */342 function elementIsNotSelected(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;343 /**344 * Creates a condition that will wait for the given element to be in the DOM,345 * yet not visible to the user.346 *347 * @param {!webdriver.WebElement} element The element to test.348 * @return {!until.Condition.<boolean>} The new condition.349 * @see webdriver.WebDriver#isDisplayed350 */351 function elementIsNotVisible(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;352 /**353 * Creates a condition that will wait for the given element to be selected.354 * @param {!webdriver.WebElement} element The element to test.355 * @return {!until.Condition.<boolean>} The new condition.356 * @see webdriver.WebDriver#isSelected357 */358 function elementIsSelected(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;359 /**360 * Creates a condition that will wait for the given element to become visible.361 *362 * @param {!webdriver.WebElement} element The element to test.363 * @return {!until.Condition.<boolean>} The new condition.364 * @see webdriver.WebDriver#isDisplayed365 */366 function elementIsVisible(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;367 /**368 * Creates a condition that will loop until an element is369 * {@link webdriver.WebDriver#findElement found} with the given locator.370 *371 * @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The locator372 * to use.373 * @return {!until.Condition.<!webdriver.WebElement>} The new condition.374 */375 function elementLocated(locator: webdriver.Locator): webdriver.until.Condition<webdriver.IWebElement>;376 function elementLocated(locator: any): webdriver.until.Condition<webdriver.IWebElement>;377 /**378 * Creates a condition that will wait for the given element's379 * {@link webdriver.WebDriver#getText visible text} to contain the given380 * substring.381 *382 * @param {!webdriver.WebElement} element The element to test.383 * @param {string} substr The substring to search for.384 * @return {!until.Condition.<boolean>} The new condition.385 * @see webdriver.WebDriver#getText386 */387 function elementTextContains(element: webdriver.IWebElement, substr: string): webdriver.until.Condition<boolean>;388 /**389 * Creates a condition that will wait for the given element's390 * {@link webdriver.WebDriver#getText visible text} to match the given391 * {@code text} exactly.392 *393 * @param {!webdriver.WebElement} element The element to test.394 * @param {string} text The expected text.395 * @return {!until.Condition.<boolean>} The new condition.396 * @see webdriver.WebDriver#getText397 */398 function elementTextIs(element: webdriver.IWebElement, text: string): webdriver.until.Condition<boolean>;399 /**400 * Creates a condition that will wait for the given element's401 * {@link webdriver.WebDriver#getText visible text} to match a regular402 * expression.403 *404 * @param {!webdriver.WebElement} element The element to test.405 * @param {!RegExp} regex The regular expression to test against.406 * @return {!until.Condition.<boolean>} The new condition.407 * @see webdriver.WebDriver#getText408 */409 function elementTextMatches(element: webdriver.IWebElement, regex: RegExp): webdriver.until.Condition<boolean>;410 /**411 * Creates a condition that will loop until at least one element is412 * {@link webdriver.WebDriver#findElement found} with the given locator.413 *414 * @param {!(webdriver.Locator|webdriver.By.Hash|Function)} locator The locator415 * to use.416 * @return {!until.Condition.<!Array.<!webdriver.WebElement>>} The new417 * condition.418 */419 function elementsLocated(locator: webdriver.Locator): webdriver.until.Condition<webdriver.IWebElement[]>;420 function elementsLocated(locator: any): webdriver.until.Condition<webdriver.IWebElement[]>;421 /**422 * Creates a condition that will wait for the given element to become stale. An423 * element is considered stale once it is removed from the DOM, or a new page424 * has loaded.425 *426 * @param {!webdriver.WebElement} element The element that should become stale.427 * @return {!until.Condition.<boolean>} The new condition.428 */429 function stalenessOf(element: webdriver.IWebElement): webdriver.until.Condition<boolean>;430 /**431 * Creates a condition that will wait for the current page's title to contain432 * the given substring.433 *434 * @param {string} substr The substring that should be present in the page435 * title.436 * @return {!until.Condition.<boolean>} The new condition.437 */438 function titleContains(substr: string): webdriver.until.Condition<boolean>;439 /**440 * Creates a condition that will wait for the current page's title to match the441 * given value.442 *443 * @param {string} title The expected page title.444 * @return {!until.Condition.<boolean>} The new condition.445 */446 function titleIs(title: string): webdriver.until.Condition<boolean>;447 /**448 * Creates a condition that will wait for the current page's title to match the449 * given regular expression.450 *451 * @param {!RegExp} regex The regular expression to test against.452 * @return {!until.Condition.<boolean>} The new condition.453 */454 function titleMatches(regex: RegExp): webdriver.until.Condition<boolean>;455 }456 module ExpectedConditions {457 /**458 * Negates the result of a promise.459 *460 * @param {webdriver.until.Condition<boolean>} expectedCondition461 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns the negated value.462 */463 function not<T>(expectedCondition: webdriver.until.Condition<T>): webdriver.until.Condition<T>;464 /**465 * Chain a number of expected conditions using logical_and, short circuiting at the466 * first expected condition that evaluates to false.467 *468 * @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'and' together.469 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which evaluates470 * to the result of the logical and.471 */472 function and<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;473 /**474 * Chain a number of expected conditions using logical_or, short circuiting at the475 * first expected condition that evaluates to true.476 *477 * @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'or' together.478 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which479 * evaluates to the result of the logical or.480 */481 function or<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;482 /**483 * Expect an alert to be present.484 *485 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing486 * whether an alert is present.487 */488 function alertIsPresent<T>(): webdriver.until.Condition<T>;489 /**490 * An Expectation for checking an element is visible and enabled such that you can click it.491 *492 * @param {ElementFinder} element The element to check493 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing494 * whether the element is clickable.495 */496 function elementToBeClickable<T>(element: ElementFinder): webdriver.until.Condition<T>;497 /**498 * An expectation for checking if the given text is present in the element.499 * Returns false if the elementFinder does not find an element.500 *501 * @param {ElementFinder} element The element to check502 * @param {string} text The text to verify against503 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing504 * whether the text is present in the element.505 */506 function textToBePresentInElement<T>(element: ElementFinder, text: string): webdriver.until.Condition<T>;507 /**508 * An expectation for checking if the given text is present in the element’s value.509 * Returns false if the elementFinder does not find an element.510 *511 * @param {ElementFinder} element The element to check512 * @param {string} text The text to verify against513 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing514 * whether the text is present in the element's value.515 */516 function textToBePresentInElementValue<T>(517 element: ElementFinder, text: string518 ): webdriver.until.Condition<T>;519 /**520 * An expectation for checking that the title contains a case-sensitive substring.521 *522 * @param {string} title The fragment of title expected523 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing524 * whether the title contains the string.525 */526 function titleContains<T>(title: string): webdriver.until.Condition<T>;527 /**528 * An expectation for checking the title of a page.529 *530 * @param {string} title The expected title, which must be an exact match.531 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing532 * whether the title equals the string.533 */534 function titleIs<T>(title: string): webdriver.until.Condition<T>;535 /**536 * An expectation for checking that an element is present on the DOM of a page. This does not necessarily537 * mean that the element is visible. This is the opposite of 'stalenessOf'.538 *539 * @param {ElementFinder} elementFinder The element to check540 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise541 * representing whether the element is present.542 */543 function presenceOf<T>(element: ElementFinder): webdriver.until.Condition<T>;544 /**545 * An expectation for checking that an element is not attached to the DOM of a page.546 * This is the opposite of 'presenceOf'.547 *548 * @param {ElementFinder} elementFinder The element to check549 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing550 * whether the element is stale.551 */552 function stalenessOf<T>(element: ElementFinder): webdriver.until.Condition<T>;553 /**554 * An expectation for checking that an element is present on the DOM of a page and visible.555 * Visibility means that the element is not only displayed but also has a height and width that is556 * greater than 0. This is the opposite of 'invisibilityOf'.557 *558 * @param {ElementFinder} elementFinder The element to check559 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing560 * whether the element is visible.561 */562 function visibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;563 /**564 * An expectation for checking that an element is present on the DOM of a page. This does not necessarily565 * mean that the element is visible. This is the opposite of 'stalenessOf'.566 *567 * @param {ElementFinder} elementFinder The element to check568 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing569 * whether the element is invisible.570 */571 function invisibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;572 /**573 * An expectation for checking the selection is selected.574 *575 * @param {ElementFinder} elementFinder The element to check576 * @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing577 * whether the element is selected.578 */579 function elementToBeSelected<T>(element: ElementFinder): webdriver.until.Condition<T>;580 }581 //endregion582 /**583 * Use as: element(locator)584 *585 * The ElementFinder can be treated as a WebElement for most purposes, in586 * particular, you may perform actions (i.e. click, getText) on them as you587 * would a WebElement. ElementFinders extend Promise, and once an action588 * is performed on an ElementFinder, the latest result from the chain can be589 * accessed using then. Unlike a WebElement, an ElementFinder will wait for590 * angular to settle before performing finds or actions.591 *592 * ElementFinder can be used to build a chain of locators that is used to find593 * an element. An ElementFinder does not actually attempt to find the element594 * until an action is called, which means they can be set up in helper files595 * before the page is available.596 *597 * @param {webdriver.Locator} locator An element locator.598 * @return {ElementFinder}599 */600 interface Element {601 (locator: webdriver.Locator): ElementFinder;602 /**603 * ElementArrayFinder is used for operations on an array of elements (as opposed604 * to a single element).605 *606 * @param {webdriver.Locator} locator An element locator.607 * @return {ElementArrayFinder}608 */609 all(locator: webdriver.Locator): ElementArrayFinder;610 }611 interface ElementFinder extends webdriver.IWebElement, webdriver.promise.IThenable<any> {612 /**613 * Calls to element may be chained to find elements within a parent.614 *615 * @alias element(locator).element(locator)616 * @view617 * <div class="parent">618 * <div class="child">619 * Child text620 * <div>{{person.phone}}</div>621 * </div>622 * </div>623 *624 * @example625 * // Chain 2 element calls.626 * var child = element(by.css('.parent')).627 * element(by.css('.child'));628 * expect(child.getText()).toBe('Child text\n555-123-4567');629 *630 * // Chain 3 element calls.631 * var triple = element(by.css('.parent')).632 * element(by.css('.child')).633 * element(by.binding('person.phone'));634 * expect(triple.getText()).toBe('555-123-4567');635 *636 * @param {webdriver.Locator} subLocator637 * @return {ElementFinder}638 */639 element(subLocator: webdriver.Locator): ElementFinder;640 /**641 * Calls to element may be chained to find an array of elements within a parent.642 *643 * @alias element(locator).all(locator)644 * @view645 * <div class="parent">646 * <ul>647 * <li class="one">First</li>648 * <li class="two">Second</li>649 * <li class="three">Third</li>650 * </ul>651 * </div>652 *653 * @example654 * var items = element(by.css('.parent')).all(by.tagName('li'))655 *656 * @param {webdriver.Locator} subLocator657 * @return {ElementArrayFinder}658 */659 all(subLocator: webdriver.Locator): ElementArrayFinder;660 /**661 * Shortcut for querying the document directly with css.662 *663 * @alias $(cssSelector)664 * @view665 * <div class="count">666 * <span class="one">First</span>667 * <span class="two">Second</span>668 * </div>669 *670 * @example671 * var item = $('.count .two');672 * expect(item.getText()).toBe('Second');673 *674 * @param {string} selector A css selector675 * @return {ElementFinder} which identifies the located676 * {@link webdriver.WebElement}677 */678 $(selector: string): ElementFinder;679 /**680 * Shortcut for querying the document directly with css.681 *682 * @alias $$(cssSelector)683 * @view684 * <div class="count">685 * <span class="one">First</span>686 * <span class="two">Second</span>687 * </div>688 *689 * @example690 * // The following protractor expressions are equivalent.691 * var list = element.all(by.css('.count span'));692 * expect(list.count()).toBe(2);693 *694 * list = $$('.count span');695 * expect(list.count()).toBe(2);696 * expect(list.get(0).getText()).toBe('First');697 * expect(list.get(1).getText()).toBe('Second');698 *699 * @param {string} selector a css selector700 * @return {ElementArrayFinder} which identifies the701 * array of the located {@link webdriver.WebElement}s.702 */703 $$(selector: string): ElementArrayFinder;704 /**705 * Determine whether the element is present on the page.706 *707 * @view708 * <span>{{person.name}}</span>709 *710 * @example711 * // Element exists.712 * expect(element(by.binding('person.name')).isPresent()).toBe(true);713 *714 * // Element not present.715 * expect(element(by.binding('notPresent')).isPresent()).toBe(false);716 *717 * @return {ElementFinder} which resolves to whether718 * the element is present on the page.719 */720 isPresent(): webdriver.promise.Promise<boolean>;721 /**722 * Override for WebElement.prototype.isElementPresent so that protractor waits723 * for Angular to settle before making the check.724 *725 * @see ElementFinder.isPresent726 *727 * @param {webdriver.Locator} subLocator Locator for element to look for.728 * @return {ElementFinder} which resolves to whether729 * the element is present on the page.730 */731 isElementPresent(subLocator: webdriver.Locator): webdriver.promise.Promise<boolean>;732 /**733 * @see ElementArrayFinder.prototype.locator734 *735 * @return {webdriver.Locator}736 */737 locator(): webdriver.Locator;738 /**739 * Returns the WebElement represented by this ElementFinder.740 * Throws the WebDriver error if the element doesn't exist.741 *742 * @example743 * The following three expressions are equivalent.744 * element(by.css('.parent')).getWebElement();745 * browser.waitForAngular(); browser.driver.findElement(by.css('.parent'));746 * browser.findElement(by.css('.parent'));747 *748 * @alias element(locator).getWebElement()749 * @return {webdriver.WebElement}750 */751 getWebElement(): webdriver.WebElement;752 /**753 * Evaluates the input as if it were on the scope of the current element.754 * @see ElementArrayFinder.evaluate755 *756 * @param {string} expression757 *758 * @return {ElementFinder} which resolves to the evaluated expression.759 */760 evaluate(expression: string): ElementFinder;761 /**762 * @see ElementArrayFinder.prototype.allowAnimations.763 * @param {string} value764 *765 * @return {ElementFinder} which resolves to whether animation is allowed.766 */767 allowAnimations(value: string): ElementFinder;768 /**769 * Create a shallow copy of ElementFinder.770 *771 * @return {!ElementFinder} A shallow copy of this.772 */773 clone(): ElementFinder;774 }775 interface ElementArrayFinder extends webdriver.promise.IThenable<ElementFinder[]> {776 /**777 * Returns the elements as an array of WebElements.778 */779 getWebElements(): webdriver.WebElement[];780 /**781 * Get an element within the ElementArrayFinder by index. The index starts at 0.782 * Negative indices are wrapped (i.e. -i means ith element from last)783 * This does not actually retrieve the underlying element.784 *785 * @alias element.all(locator).get(index)786 * @view787 * <ul class="items">788 * <li>First</li>789 * <li>Second</li>790 * <li>Third</li>791 * </ul>792 *793 * @example794 * var list = element.all(by.css('.items li'));795 * expect(list.get(0).getText()).toBe('First');796 * expect(list.get(1).getText()).toBe('Second');797 *798 * @param {number} index Element index.799 * @return {ElementFinder} finder representing element at the given index.800 */801 get(index: number): ElementFinder;802 /**803 * Get the first matching element for the ElementArrayFinder. This does not804 * actually retrieve the underlying element.805 *806 * @alias element.all(locator).first()807 * @view808 * <ul class="items">809 * <li>First</li>810 * <li>Second</li>811 * <li>Third</li>812 * </ul>813 *814 * @example815 * var first = element.all(by.css('.items li')).first();816 * expect(first.getText()).toBe('First');817 *818 * @return {ElementFinder} finder representing the first matching element819 */820 first(): ElementFinder;821 /**822 * Get the last matching element for the ElementArrayFinder. This does not823 * actually retrieve the underlying element.824 *825 * @alias element.all(locator).last()826 * @view827 * <ul class="items">828 * <li>First</li>829 * <li>Second</li>830 * <li>Third</li>831 * </ul>832 *833 * @example834 * var last = element.all(by.css('.items li')).last();835 * expect(last.getText()).toBe('Third');836 *837 * @return {ElementFinder} finder representing the last matching element838 */839 last(): ElementFinder;840 /**841 * Count the number of elements represented by the ElementArrayFinder.842 *843 * @alias element.all(locator).count()844 * @view845 * <ul class="items">846 * <li>First</li>847 * <li>Second</li>848 * <li>Third</li>849 * </ul>850 *851 * @example852 * var list = element.all(by.css('.items li'));853 * expect(list.count()).toBe(3);854 *855 * @return {!webdriver.promise.Promise} A promise which resolves to the856 * number of elements matching the locator.857 */858 count(): webdriver.promise.Promise<number>;859 /**860 * Calls the input function on each ElementFinder represented by the ElementArrayFinder.861 *862 * @alias element.all(locator).each(eachFunction)863 * @view864 * <ul class="items">865 * <li>First</li>866 * <li>Second</li>867 * <li>Third</li>868 * </ul>869 *870 * @example871 * element.all(by.css('.items li')).each(function(element) {872 * // Will print First, Second, Third.873 * element.getText().then(console.log);874 * });875 *876 * @param {function(ElementFinder)} fn Input function877 */878 each(fn: (element: ElementFinder, index: number) => void): void;879 /**880 * Apply a map function to each element within the ElementArrayFinder. The881 * callback receives the ElementFinder as the first argument and the index as882 * a second arg.883 *884 * @alias element.all(locator).map(mapFunction)885 * @view886 * <ul class="items">887 * <li class="one">First</li>888 * <li class="two">Second</li>889 * <li class="three">Third</li>890 * </ul>891 *892 * @example893 * var items = element.all(by.css('.items li')).map(function(elm, index) {894 * return {895 * index: index,896 * text: elm.getText(),897 * class: elm.getAttribute('class')898 * };899 * });900 * expect(items).toEqual([901 * {index: 0, text: 'First', class: 'one'},902 * {index: 1, text: 'Second', class: 'two'},903 * {index: 2, text: 'Third', class: 'three'}904 * ]);905 *906 * @param {function(ElementFinder, number)} mapFn Map function that907 * will be applied to each element.908 * @return {!webdriver.promise.Promise} A promise that resolves to an array909 * of values returned by the map function.910 */911 map<T>(mapFn: (element: ElementFinder, index: number) => T): webdriver.promise.Promise<T[]>;912 /**913 * Apply a filter function to each element within the ElementArrayFinder. Returns914 * a new ElementArrayFinder with all elements that pass the filter function. The915 * filter function receives the ElementFinder as the first argument916 * and the index as a second arg.917 * This does not actually retrieve the underlying list of elements, so it can918 * be used in page objects.919 *920 * @alias element.all(locator).filter(filterFn)921 * @view922 * <ul class="items">923 * <li class="one">First</li>924 * <li class="two">Second</li>925 * <li class="three">Third</li>926 * </ul>927 *928 * @example929 * element.all(by.css('.items li')).filter(function(elem, index) {930 * return elem.getText().then(function(text) {931 * return text === 'Third';932 * });933 * }).then(function(filteredElements) {934 * filteredElements[0].click();935 * });936 *937 * @param {function(ElementFinder, number): webdriver.WebElement.Promise} filterFn938 * Filter function that will test if an element should be returned.939 * filterFn can either return a boolean or a promise that resolves to a boolean.940 * @return {!ElementArrayFinder} A ElementArrayFinder that represents an array941 * of element that satisfy the filter function.942 */943 filter(filterFn: (element: ElementFinder, index: number) => any): ElementArrayFinder;944 /**945 * Apply a reduce function against an accumulator and every element found946 * using the locator (from left-to-right). The reduce function has to reduce947 * every element into a single value (the accumulator). Returns promise of948 * the accumulator. The reduce function receives the accumulator, current949 * ElementFinder, the index, and the entire array of ElementFinders,950 * respectively.951 *952 * @alias element.all(locator).reduce(reduceFn)953 * @view954 * <ul class="items">955 * <li class="one">First</li>956 * <li class="two">Second</li>957 * <li class="three">Third</li>958 * </ul>959 *960 * @example961 * var value = element.all(by.css('.items li')).reduce(function(acc, elem) {962 * return elem.getText().then(function(text) {963 * return acc + text + ' ';964 * });965 * });966 *967 * expect(value).toEqual('First Second Third ');968 *969 * @param {function(number, ElementFinder, number, Array.<ElementFinder>)}970 * reduceFn Reduce function that reduces every element into a single value.971 * @param {*} initialValue Initial value of the accumulator.972 * @return {!webdriver.promise.Promise} A promise that resolves to the final973 * value of the accumulator.974 */975 reduce<T>(reduceFn: (acc: T, element: ElementFinder, index: number, arr: ElementFinder[]) => webdriver.promise.Promise<T>, initialValue: T): webdriver.promise.Promise<T>;976 reduce<T>(reduceFn: (acc: T, element: ElementFinder, index: number, arr: ElementFinder[]) => T, initialValue: T): webdriver.promise.Promise<T>;977 /**978 * Represents the ElementArrayFinder as an array of ElementFinders.979 *980 * @return {Array.<ElementFinder>} Return a promise, which resolves to a list981 * of ElementFinders specified by the locator.982 */983 asElementFinders_(): webdriver.promise.Promise<ElementFinder[]>;984 /**985 * Create a shallow copy of ElementArrayFinder.986 *987 * @return {!ElementArrayFinder} A shallow copy of this.988 */989 clone(): ElementArrayFinder;990 /**991 * Calls to ElementArrayFinder may be chained to find an array of elements992 * using the current elements in this ElementArrayFinder as the starting point.993 * This function returns a new ElementArrayFinder which would contain the994 * children elements found (and could also be empty).995 *996 * @alias element.all(locator).all(locator)997 * @view998 * <div id='id1' class="parent">999 * <ul>1000 * <li class="foo">1a</li>1001 * <li class="baz">1b</li>1002 * </ul>1003 * </div>1004 * <div id='id2' class="parent">1005 * <ul>1006 * <li class="foo">2a</li>1007 * <li class="bar">2b</li>1008 * </ul>1009 * </div>1010 *1011 * @example1012 * var foo = element.all(by.css('.parent')).all(by.css('.foo'))1013 * expect(foo.getText()).toEqual(['1a', '2a'])1014 * var baz = element.all(by.css('.parent')).all(by.css('.baz'))1015 * expect(baz.getText()).toEqual(['1b'])1016 * var nonexistent = element.all(by.css('.parent')).all(by.css('.NONEXISTENT'))1017 * expect(nonexistent.getText()).toEqual([''])1018 *1019 * @param {webdriver.Locator} subLocator1020 * @return {ElementArrayFinder}1021 */1022 all(locator: webdriver.Locator): ElementArrayFinder;1023 /**1024 * Shorthand function for finding arrays of elements by css.1025 *1026 * @type {function(string): ElementArrayFinder}1027 */1028 $$(selector: string): ElementArrayFinder;1029 /**1030 * Returns an ElementFinder representation of ElementArrayFinder. It ensures1031 * that the ElementArrayFinder resolves to one and only one underlying element.1032 *1033 * @return {ElementFinder} An ElementFinder representation1034 * @private1035 */1036 toElementFinder_(): ElementFinder;1037 /**1038 * Returns the most relevant locator.1039 *1040 * @example1041 * $('#ID1').locator() // returns by.css('#ID1')1042 * $('#ID1').$('#ID2').locator() // returns by.css('#ID2')1043 * $$('#ID1').filter(filterFn).get(0).click().locator() // returns by.css('#ID1')1044 *1045 * @return {webdriver.Locator}1046 */1047 locator(): webdriver.Locator;1048 /**1049 * Evaluates the input as if it were on the scope of the current underlying1050 * elements.1051 *1052 * @view1053 * <span id="foo">{{variableInScope}}</span>1054 *1055 * @example1056 * var value = element(by.id('foo')).evaluate('variableInScope');1057 *1058 * @param {string} expression1059 *1060 * @return {ElementArrayFinder} which resolves to the1061 * evaluated expression for each underlying element.1062 * The result will be resolved as in1063 * {@link webdriver.WebDriver.executeScript}. In summary - primitives will1064 * be resolved as is, functions will be converted to string, and elements1065 * will be returned as a WebElement.1066 */1067 evaluate(expression: string): ElementArrayFinder;1068 /**1069 * Determine if animation is allowed on the current underlying elements.1070 * @param {string} value1071 *1072 * @example1073 * // Turns off ng-animate animations for all elements in the <body>1074 * element(by.css('body')).allowAnimations(false);1075 *1076 * @return {ElementArrayFinder} which resolves to whether animation is allowed.1077 */1078 allowAnimations(value: boolean): ElementArrayFinder;1079 /**1080 * Schedules a command to click on this element.1081 * @return {!webdriver.promise.Promise} A promise that will be resolved when1082 * the click command has completed.1083 */1084 click(): webdriver.promise.Promise<void>;1085 /**1086 * Schedules a command to type a sequence on the DOM element represented by this1087 * instance.1088 * <p/>1089 * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is1090 * processed in the keysequence, that key state is toggled until one of the1091 * following occurs:1092 * <ul>1093 * <li>The modifier key is encountered again in the sequence. At this point the1094 * state of the key is toggled (along with the appropriate keyup/down events).1095 * </li>1096 * <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When1097 * this key is encountered, all modifier keys current in the down state are1098 * released (with accompanying keyup events). The NULL key can be used to1099 * simulate common keyboard shortcuts:1100 * <code>1101 * element.sendKeys("text was",1102 * webdriver.Key.CONTROL, "a", webdriver.Key.NULL,1103 * "now text is");1104 * // Alternatively:1105 * element.sendKeys("text was",1106 * webdriver.Key.chord(webdriver.Key.CONTROL, "a"),1107 * "now text is");1108 * </code></li>1109 * <li>The end of the keysequence is encountered. When there are no more keys1110 * to type, all depressed modifier keys are released (with accompanying keyup1111 * events).1112 * </li>1113 * </ul>1114 * <strong>Note:</strong> On browsers where native keyboard events are not yet1115 * supported (e.g. Firefox on OS X), key events will be synthesized. Special1116 * punctionation keys will be synthesized according to a standard QWERTY en-us1117 * keyboard layout.1118 *1119 * @param {...string} var_args The sequence of keys to1120 * type. All arguments will be joined into a single sequence (var_args is1121 * permitted for convenience).1122 * @return {!webdriver.promise.Promise} A promise that will be resolved when all1123 * keys have been typed.1124 */1125 sendKeys(...var_args: string[]): webdriver.promise.Promise<void>;1126 /**1127 * Schedules a command to query for the tag/node name of this element.1128 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1129 * element's tag name.1130 */1131 getTagName(): webdriver.promise.Promise<string[]>;1132 /**1133 * Schedules a command to query for the computed style of the element1134 * represented by this instance. If the element inherits the named style from1135 * its parent, the parent will be queried for its value. Where possible, color1136 * values will be converted to their hex representation (e.g. #00ff00 instead of1137 * rgb(0, 255, 0)).1138 * <p/>1139 * <em>Warning:</em> the value returned will be as the browser interprets it, so1140 * it may be tricky to form a proper assertion.1141 *1142 * @param {string} cssStyleProperty The name of the CSS style property to look1143 * up.1144 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1145 * requested CSS value.1146 */1147 getCssValue(cssStyleProperty: string): webdriver.promise.Promise<string[]>;1148 /**1149 * Schedules a command to query for the value of the given attribute of the1150 * element. Will return the current value even if it has been modified after the1151 * page has been loaded. More exactly, this method will return the value of the1152 * given attribute, unless that attribute is not present, in which case the1153 * value of the property with the same name is returned. If neither value is1154 * set, null is returned. The "style" attribute is converted as best can be to a1155 * text representation with a trailing semi-colon. The following are deemed to1156 * be "boolean" attributes and will be returned as thus:1157 *1158 * <p>async, autofocus, autoplay, checked, compact, complete, controls, declare,1159 * defaultchecked, defaultselected, defer, disabled, draggable, ended,1160 * formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,1161 * loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,1162 * paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,1163 * selected, spellcheck, truespeed, willvalidate1164 *1165 * <p>Finally, the following commonly mis-capitalized attribute/property names1166 * are evaluated as expected:1167 * <ul>1168 * <li>"class"1169 * <li>"readonly"1170 * </ul>1171 * @param {string} attributeName The name of the attribute to query.1172 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1173 * attribute's value.1174 */1175 getAttribute(attributeName: string): webdriver.promise.Promise<string[]>;1176 /**1177 * Get the visible (i.e. not hidden by CSS) innerText of this element, including1178 * sub-elements, without any leading or trailing whitespace.1179 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1180 * element's visible text.1181 */1182 getText(): webdriver.promise.Promise<string[]>;1183 /**1184 * Schedules a command to compute the size of this element's bounding box, in1185 * pixels.1186 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1187 * element's size as a {@code {width:number, height:number}} object.1188 */1189 getSize(): webdriver.promise.Promise<webdriver.ISize[]>;1190 /**1191 * Schedules a command to compute the location of this element in page space.1192 * @return {!webdriver.promise.Promise} A promise that will be resolved to the1193 * element's location as a {@code {x:number, y:number}} object.1194 */1195 getLocation(): webdriver.promise.Promise<webdriver.ILocation[]>;1196 /**1197 * Schedules a command to query whether the DOM element represented by this1198 * instance is enabled, as dicted by the {@code disabled} attribute.1199 * @return {!webdriver.promise.Promise} A promise that will be resolved with1200 * whether this element is currently enabled.1201 */1202 isEnabled(): webdriver.promise.Promise<boolean[]>;1203 /**1204 * Schedules a command to query whether this element is selected.1205 * @return {!webdriver.promise.Promise} A promise that will be resolved with1206 * whether this element is currently selected.1207 */1208 isSelected(): webdriver.promise.Promise<boolean[]>;1209 /**1210 * Schedules a command to submit the form containing this element (or this1211 * element if it is a FORM element). This command is a no-op if the element is1212 * not contained in a form.1213 * @return {!webdriver.promise.Promise} A promise that will be resolved when1214 * the form has been submitted.1215 */1216 submit(): webdriver.promise.Promise<void>;1217 /**1218 * Schedules a command to clear the {@code value} of this element. This command1219 * has no effect if the underlying DOM element is neither a text INPUT element1220 * nor a TEXTAREA element.1221 * @return {!webdriver.promise.Promise} A promise that will be resolved when1222 * the element has been cleared.1223 */1224 clear(): webdriver.promise.Promise<void>;1225 /**1226 * Schedules a command to test whether this element is currently displayed.1227 * @return {!webdriver.promise.Promise} A promise that will be resolved with1228 * whether this element is currently visible on the page.1229 */1230 isDisplayed(): webdriver.promise.Promise<boolean[]>;1231 /**1232 * Schedules a command to retrieve the outer HTML of this element.1233 * @return {!webdriver.promise.Promise} A promise that will be resolved with1234 * the element's outer HTML.1235 */1236 getOuterHtml(): webdriver.promise.Promise<string[]>;1237 /**1238 * @return {!webdriver.promise.Promise.<webdriver.WebElement.Id>} A promise1239 * that resolves to this element's JSON representation as defined by the1240 * WebDriver wire protocol.1241 * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol1242 */1243 getId(): webdriver.promise.Promise<webdriver.IWebElementId[]>1244 /**1245 * Schedules a command to retrieve the inner HTML of this element.1246 * @return {!webdriver.promise.Promise} A promise that will be resolved with the1247 * element's inner HTML.1248 */1249 getInnerHtml(): webdriver.promise.Promise<string[]>;1250 }1251 interface LocatorWithColumn extends webdriver.Locator {1252 column(index: number): webdriver.Locator;1253 column(name: string): webdriver.Locator;1254 }1255 interface RepeaterLocator extends LocatorWithColumn {1256 row(index: number): LocatorWithColumn;1257 }1258 interface IProtractorLocatorStrategy {1259 /**1260 * webdriver's By is an enum of locator functions, so we must set it to1261 * a prototype before inheriting from it.1262 */1263 className: typeof webdriver.By.className;1264 css: typeof webdriver.By.css;1265 id: typeof webdriver.By.id;1266 linkText: typeof webdriver.By.linkText;1267 js: typeof webdriver.By.js;1268 name: typeof webdriver.By.name;1269 partialLinkText: typeof webdriver.By.partialLinkText;1270 tagName: typeof webdriver.By.tagName;1271 xpath: typeof webdriver.By.xpath;1272 /**1273 * Add a locator to this instance of ProtractorBy. This locator can then be1274 * used with element(by.locatorName(args)).1275 *1276 * @view1277 * <button ng-click="doAddition()">Go!</button>1278 *1279 * @example1280 * // Add the custom locator.1281 * by.addLocator('buttonTextSimple',1282 * function(buttonText, opt_parentElement, opt_rootSelector) {1283 * // This function will be serialized as a string and will execute in the1284 * // browser. The first argument is the text for the button. The second1285 * // argument is the parent element, if any.1286 * var using = opt_parentElement,1287 * buttons = using.querySelectorAll('button');1288 *1289 * // Return an array of buttons with the text.1290 * return Array.prototype.filter.call(buttons, function(button) {1291 * return button.textContent === buttonText;1292 * });1293 * });1294 *1295 * // Use the custom locator.1296 * element(by.buttonTextSimple('Go!')).click();1297 *1298 * @alias by.addLocator(locatorName, functionOrScript)1299 * @param {string} name The name of the new locator.1300 * @param {Function|string} script A script to be run in the context of1301 * the browser. This script will be passed an array of arguments1302 * that contains any args passed into the locator followed by the1303 * element scoping the search and the css selector for the root angular1304 * element. It should return an array of elements.1305 */1306 addLocator(name: string, script: string): void;1307 addLocator(name: string, script: Function): void;1308 /**1309 * Find an element by binding.1310 *1311 * @view1312 * <span>{{person.name}}</span>1313 * <span ng-bind="person.email"></span>1314 *1315 * @example1316 * var span1 = element(by.binding('person.name'));1317 * expect(span1.getText()).toBe('Foo');1318 *1319 * var span2 = element(by.binding('person.email'));1320 * expect(span2.getText()).toBe('foo@bar.com');1321 *1322 * @param {string} bindingDescriptor1323 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}1324 */1325 binding(bindingDescriptor: string): webdriver.Locator;1326 /**1327 * Find an element by exact binding.1328 *1329 * @view1330 * <span>{{ person.name }}</span>1331 * <span ng-bind="person-email"></span>1332 * <span>{{person_phone|uppercase}}</span>1333 *1334 * @example1335 * expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);1336 * expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);1337 * expect(element(by.exactBinding('person')).isPresent()).toBe(false);1338 * expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);1339 * expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);1340 * expect(element(by.exactBinding('phone')).isPresent()).toBe(false);1341 *1342 * @param {string} bindingDescriptor1343 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}1344 */1345 exactBinding(bindingDescriptor: string): webdriver.Locator;1346 /**1347 * Find an element by ng-model expression.1348 *1349 * @alias by.model(modelName)1350 * @view1351 * <input type="text" ng-model="person.name"/>1352 *1353 * @example1354 * var input = element(by.model('person.name'));1355 * input.sendKeys('123');1356 * expect(input.getAttribute('value')).toBe('Foo123');1357 *1358 * @param {string} model ng-model expression.1359 */1360 model(model: string): webdriver.Locator;1361 /**1362 * Find a button by text.1363 *1364 * @view1365 * <button>Save</button>1366 *1367 * @example1368 * element(by.buttonText('Save'));1369 *1370 * @param {string} searchText1371 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}1372 */1373 buttonText(searchText: string): webdriver.Locator;1374 /**1375 * Find a button by partial text.1376 *1377 * @view1378 * <button>Save my file</button>1379 *1380 * @example1381 * element(by.partialButtonText('Save'));1382 *1383 * @param {string} searchText1384 * @return {{findElementsOverride: findElementsOverride, toString: Function|string}}1385 */1386 partialButtonText(searchText: string): webdriver.Locator;1387 /**1388 * Find elements inside an ng-repeat.1389 *1390 * @view1391 * <div ng-repeat="cat in pets">1392 * <span>{{cat.name}}</span>1393 * <span>{{cat.age}}</span>1394 * </div>1395 *1396 * <div class="book-img" ng-repeat-start="book in library">1397 * <span>{{$index}}</span>1398 * </div>1399 * <div class="book-info" ng-repeat-end>1400 * <h4>{{book.name}}</h4>1401 * <p>{{book.blurb}}</p>1402 * </div>1403 *1404 * @example1405 * // Returns the DIV for the second cat.1406 * var secondCat = element(by.repeater('cat in pets').row(1));1407 *1408 * // Returns the SPAN for the first cat's name.1409 * var firstCatName = element(by.repeater('cat in pets').1410 * row(0).column('{{cat.name}}'));1411 *1412 * // Returns a promise that resolves to an array of WebElements from a column1413 * var ages = element.all(1414 * by.repeater('cat in pets').column('{{cat.age}}'));1415 *1416 * // Returns a promise that resolves to an array of WebElements containing1417 * // all top level elements repeated by the repeater. For 2 pets rows resolves1418 * // to an array of 2 elements.1419 * var rows = element.all(by.repeater('cat in pets'));1420 *1421 * // Returns a promise that resolves to an array of WebElements containing all1422 * // the elements with a binding to the book's name.1423 * var divs = element.all(by.repeater('book in library').column('book.name'));1424 *1425 * // Returns a promise that resolves to an array of WebElements containing1426 * // the DIVs for the second book.1427 * var bookInfo = element.all(by.repeater('book in library').row(1));1428 *1429 * // Returns the H4 for the first book's name.1430 * var firstBookName = element(by.repeater('book in library').1431 * row(0).column('{{book.name}}'));1432 *1433 * // Returns a promise that resolves to an array of WebElements containing1434 * // all top level elements repeated by the repeater. For 2 books divs1435 * // resolves to an array of 4 elements.1436 * var divs = element.all(by.repeater('book in library'));1437 */1438 repeater(repeatDescriptor: string): RepeaterLocator;1439 /**1440 * Find elements by CSS which contain a certain string.1441 *1442 * @view1443 * <ul>1444 * <li class="pet">Dog</li>1445 * <li class="pet">Cat</li>1446 * </ul>1447 *1448 * @example1449 * // Returns the DIV for the dog, but not cat.1450 * var dog = element(by.cssContainingText('.pet', 'Dog'));1451 */1452 cssContainingText(cssSelector: string, searchText: string): webdriver.Locator;1453 /**1454 * Find an element by ng-options expression.1455 *1456 * @alias by.options(optionsDescriptor)1457 * @view1458 * <select ng-model="color" ng-options="c for c in colors">1459 * <option value="0" selected="selected">red</option>1460 * <option value="1">green</option>1461 * </select>1462 *1463 * @example1464 * var allOptions = element.all(by.options('c for c in colors'));1465 * expect(allOptions.count()).toEqual(2);1466 * var firstOption = allOptions.first();1467 * expect(firstOption.getText()).toEqual('red');1468 *1469 * @param {string} optionsDescriptor ng-options expression.1470 */1471 options(optionsDescriptor: string): webdriver.Locator;1472 }1473 var By: IProtractorLocatorStrategy;1474 interface Protractor extends webdriver.WebDriver {1475 /**1476 * The wrapped webdriver instance. Use this to interact with pages that do1477 * not contain Angular (such as a log-in screen).1478 *1479 * @type {webdriver.WebDriver}1480 */1481 driver: webdriver.WebDriver;1482 /**1483 * Helper function for finding elements.1484 *1485 * @type {function(webdriver.Locator): ElementFinder}1486 */1487 element(locator: webdriver.Locator): ElementFinder;1488 /**1489 * Shorthand function for finding elements by css.1490 *1491 * @type {function(string): ElementFinder}1492 */1493 $(selector: string): ElementFinder;1494 /**1495 * Shorthand function for finding arrays of elements by css.1496 *1497 * @type {function(string): ElementArrayFinder}1498 */1499 $$(selector: string): ElementArrayFinder;1500 /**1501 * All get methods will be resolved against this base URL. Relative URLs are =1502 * resolved the way anchor tags resolve.1503 *1504 * @type {string}1505 */1506 baseUrl: string;1507 /**1508 * The css selector for an element on which to find Angular. This is usually1509 * 'body' but if your ng-app is on a subsection of the page it may be1510 * a subelement.1511 *1512 * @type {string}1513 */1514 rootEl: string;1515 /**1516 * If true, Protractor will not attempt to synchronize with the page before1517 * performing actions. This can be harmful because Protractor will not wait1518 * until $timeouts and $http calls have been processed, which can cause1519 * tests to become flaky. This should be used only when necessary, such as1520 * when a page continuously polls an API using $timeout.1521 *1522 * @type {boolean}1523 */1524 ignoreSynchronization: boolean;1525 /**1526 * Timeout in milliseconds to wait for pages to load when calling `get`.1527 *1528 * @type {number}1529 */1530 getPageTimeout: number;1531 /**1532 * An object that holds custom test parameters.1533 *1534 * @type {Object}1535 */1536 params: any;1537 /**1538 * The reset URL to use between page loads.1539 *1540 * @type {string}1541 */1542 resetUrl: string;1543 /**1544 * Instruct webdriver to wait until Angular has finished rendering and has1545 * no outstanding $http calls before continuing.1546 *1547 * @return {!webdriver.promise.Promise} A promise that will resolve to the1548 * scripts return value.1549 */1550 waitForAngular(): webdriver.promise.Promise<void>;1551 /**1552 * Add a module to load before Angular whenever Protractor.get is called.1553 * Modules will be registered after existing modules already on the page,1554 * so any module registered here will override preexisting modules with the same1555 * name.1556 *1557 * @example1558 * browser.addMockModule('modName', function() {1559 * angular.module('modName', []).value('foo', 'bar');1560 * });1561 *1562 * @param {!string} name The name of the module to load or override.1563 * @param {!string|Function} script The JavaScript to load the module.1564 * @param {...*} varArgs Any additional arguments will be provided to1565 * the script and may be referenced using the `arguments` object.1566 */1567 addMockModule(name: string, script: string, ...varArgs: any[]): void;1568 addMockModule(name: string, script: Function, ...varArgs: any[]): void;1569 /**1570 * Clear the list of registered mock modules.1571 */1572 clearMockModules(): void;1573 /**1574 * Remove a registered mock module.1575 *1576 * @example1577 * browser.removeMockModule('modName');1578 *1579 * @param {!string} name The name of the module to remove.1580 */1581 removeMockModule(name: string): void;1582 /**1583 * @see webdriver.WebDriver.get1584 *1585 * Navigate to the given destination and loads mock modules before1586 * Angular. Assumes that the page being loaded uses Angular.1587 * If you need to access a page which does not have Angular on load, use1588 * the wrapped webdriver directly.1589 *1590 * @param {string} destination Destination URL.1591 * @param {number=} opt_timeout Number of milliseconds to wait for Angular to1592 * start.1593 */1594 get(destination: string, opt_timeout?: number): webdriver.promise.Promise<void>;1595 /**1596 * See webdriver.WebDriver.refresh1597 *1598 * Makes a full reload of the current page and loads mock modules before1599 * Angular. Assumes that the page being loaded uses Angular.1600 * If you need to access a page which does not have Angular on load, use1601 * the wrapped webdriver directly.1602 *1603 * @param {number=} opt_timeout Number of seconds to wait for Angular to start.1604 */1605 refresh(opt_timeout?: number): webdriver.promise.Promise<void>;1606 /**1607 * Browse to another page using in-page navigation.1608 *1609 * @param {string} url In page URL using the same syntax as $location.url()1610 * @returns {!webdriver.promise.Promise} A promise that will resolve once1611 * page has been changed.1612 */1613 setLocation(url: string): webdriver.promise.Promise<void>;1614 /**1615 * Returns the current absolute url from AngularJS.1616 */1617 getLocationAbsUrl(): webdriver.promise.Promise<string>;1618 /**1619 * Pauses the test and injects some helper functions into the browser, so that1620 * debugging may be done in the browser console.1621 *1622 * This should be used under node in debug mode, i.e. with1623 * protractor debug <configuration.js>1624 *1625 * @example1626 * While in the debugger, commands can be scheduled through webdriver by1627 * entering the repl:1628 * debug> repl1629 * Press Ctrl + C to leave rdebug repl1630 * > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));1631 * > ptor.debugger();1632 * debug> c1633 *1634 * This will run the sendKeys command as the next task, then re-enter the1635 * debugger.1636 */1637 debugger(): void;1638 /**1639 * Beta (unstable) pause function for debugging webdriver tests. Use1640 * browser.pause() in your test to enter the protractor debugger from that1641 * point in the control flow.1642 * Does not require changes to the command line (no need to add 'debug').1643 *1644 * @example1645 * element(by.id('foo')).click();1646 * browser.pause();1647 * // Execution will stop before the next click action.1648 * element(by.id('bar')).click();1649 *1650 * @param {number=} opt_debugPort Optional port to use for the debugging process1651 */1652 pause(opt_debugPort?: number): void;1653 }1654 // Interface for the global browser object.1655 interface IBrowser extends Protractor {1656 /**1657 * Fork another instance of protractor for use in interactive tests.1658 *1659 * @param {boolean} opt_useSameUrl Whether to navigate to current url on creation1660 * @param {boolean} opt_copyMockModules Whether to apply same mock modules on creation1661 * @return {Protractor} a protractor instance.1662 */1663 forkNewDriverInstance(opt_useSameUrl?: boolean, opt_copyMockModules?: boolean): Protractor;1664 /**1665 * Get the processed configuration object that is currently being run. This will contain1666 * the specs and capabilities properties of the current runner instance.1667 *1668 * Set by the runner.1669 *1670 * @return {webdriver.promise.Promise<any>} A promise which resolves to the capabilities object.1671 */1672 getProcessedConfig(): webdriver.promise.Promise<any>;1673 }1674 /**1675 * Create a new instance of Protractor by wrapping a webdriver instance.1676 *1677 * @param {webdriver.WebDriver} webdriver The configured webdriver instance.1678 * @param {string=} opt_baseUrl A URL to prepend to relative gets.1679 * @return {Protractor}1680 */1681 function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;1682}1683interface cssSelectorHelper {1684 (cssLocator: string): protractor.ElementFinder;1685}1686interface cssArraySelectorHelper {1687 (cssLocator: string): protractor.ElementArrayFinder;1688}1689declare var browser: protractor.IBrowser;1690declare var by: protractor.IProtractorLocatorStrategy;1691declare var By: protractor.IProtractorLocatorStrategy;1692declare var element: protractor.Element;1693declare var $: cssSelectorHelper;1694declare var $$: cssArraySelectorHelper;1695declare module 'protractor' {1696 export = protractor;...

Full Screen

Full Screen

ptor.d.ts

Source:ptor.d.ts Github

copy

Full Screen

1import * as webdriver from 'selenium-webdriver';2import * as chrome from 'selenium-webdriver/chrome';3import * as firefox from 'selenium-webdriver/firefox';4import * as http from 'selenium-webdriver/http';5import * as remote from 'selenium-webdriver/remote';6import { ElementHelper, ProtractorBrowser } from './browser';7import { ElementArrayFinder, ElementFinder } from './element';8import { ProtractorExpectedConditions } from './expectedConditions';9import { ProtractorBy } from './locators';10export declare class Ptor {11 browser: ProtractorBrowser;12 $: (search: string) => ElementFinder;13 $$: (search: string) => ElementArrayFinder;14 element: ElementHelper;15 By: ProtractorBy;16 by: ProtractorBy;17 wrapDriver: (webdriver: webdriver.WebDriver, baseUrl?: string, rootElement?: string, untrackOutstandingTimeouts?: boolean) => ProtractorBrowser;18 ExpectedConditions: ProtractorExpectedConditions;19 ProtractorBrowser: any;20 ElementFinder: any;21 ElementArrayFinder: any;22 ProtractorBy: any;23 ProtractorExpectedConditions: any;24 ActionSequence: typeof webdriver.ActionSequence;25 Browser: webdriver.IBrowser;26 Builder: typeof webdriver.Builder;27 Button: webdriver.IButton;28 Capabilities: typeof webdriver.Capabilities;29 Capability: webdriver.ICapability;30 EventEmitter: typeof webdriver.EventEmitter;31 FileDetector: typeof webdriver.FileDetector;32 Key: webdriver.IKey;33 Session: typeof webdriver.Session;34 WebDriver: typeof webdriver.WebDriver;35 WebElement: typeof webdriver.WebElement;36 WebElementPromise: typeof webdriver.WebElementPromise;37 error: typeof webdriver.error;38 logging: typeof webdriver.logging;39 promise: typeof webdriver.promise;40 until: typeof webdriver.until;41 Command: any;42 CommandName: any;43 utils: {44 firefox: typeof firefox;45 http: typeof http;46 remote: typeof remote;47 chrome: typeof chrome;48 };49}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful