mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Added definitions for protractor.ExpectedConditions
Added definitions and tests for ExpectedConditions documented at https://angular.github.io/protractor/#/api?view=ExpectedConditions.
This commit is contained in:
@@ -196,6 +196,27 @@ function TestWebDriverUntilModule() {
|
||||
conditionWebElements = protractor.until.elementsLocated(by.className('class'));
|
||||
}
|
||||
|
||||
function TestWebDriverExpectedConditionsModule() {
|
||||
var conditionB: protractor.until.Condition<boolean>;
|
||||
var el: protractor.ElementFinder = element(by.id('id'));
|
||||
|
||||
conditionB = protractor.ExpectedConditions.alertIsPresent();
|
||||
conditionB = protractor.ExpectedConditions.elementToBeClickable(el);
|
||||
conditionB = protractor.ExpectedConditions.textToBePresentInElement(el, 'text');
|
||||
conditionB = protractor.ExpectedConditions.textToBePresentInElementValue(el, 'text');
|
||||
conditionB = protractor.ExpectedConditions.titleContains('text');
|
||||
conditionB = protractor.ExpectedConditions.titleIs('text');
|
||||
conditionB = protractor.ExpectedConditions.presenceOf(el);
|
||||
conditionB = protractor.ExpectedConditions.stalenessOf(el);
|
||||
conditionB = protractor.ExpectedConditions.visibilityOf(el);
|
||||
conditionB = protractor.ExpectedConditions.invisibilityOf(el);
|
||||
conditionB = protractor.ExpectedConditions.elementToBeSelected(el);
|
||||
|
||||
conditionB = protractor.ExpectedConditions.not(protractor.ExpectedConditions.alertIsPresent());
|
||||
conditionB = protractor.ExpectedConditions.and(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el));
|
||||
conditionB = protractor.ExpectedConditions.or(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el));
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
var ptor: protractor.Protractor;
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
|
||||
+139
@@ -501,6 +501,145 @@ declare module protractor {
|
||||
function titleMatches(regex: RegExp): webdriver.until.Condition<boolean>;
|
||||
}
|
||||
|
||||
module ExpectedConditions {
|
||||
/**
|
||||
* Negates the result of a promise.
|
||||
*
|
||||
* @param {webdriver.until.Condition<boolean>} expectedCondition
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns the negated value.
|
||||
*/
|
||||
function not<T>(expectedCondition: webdriver.until.Condition<T>): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* Chain a number of expected conditions using logical_and, short circuiting at the
|
||||
* first expected condition that evaluates to false.
|
||||
*
|
||||
* @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'and' together.
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which evaluates
|
||||
* to the result of the logical and.
|
||||
*/
|
||||
function and<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* Chain a number of expected conditions using logical_or, short circuiting at the
|
||||
* first expected condition that evaluates to true.
|
||||
*
|
||||
* @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'or' together.
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which
|
||||
* evaluates to the result of the logical or.
|
||||
*/
|
||||
function or<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* Expect an alert to be present.
|
||||
*
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether an alert is present.
|
||||
*/
|
||||
function alertIsPresent<T>(): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An Expectation for checking an element is visible and enabled such that you can click it.
|
||||
*
|
||||
* @param {ElementFinder} element The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the element is clickable.
|
||||
*/
|
||||
function elementToBeClickable<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking if the given text is present in the element.
|
||||
* Returns false if the elementFinder does not find an element.
|
||||
*
|
||||
* @param {ElementFinder} element The element to check
|
||||
* @param {string} text The text to verify against
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the text is present in the element.
|
||||
*/
|
||||
function textToBePresentInElement<T>(element: ElementFinder, text: string): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking if the given text is present in the element’s value.
|
||||
* Returns false if the elementFinder does not find an element.
|
||||
*
|
||||
* @param {ElementFinder} element The element to check
|
||||
* @param {string} text The text to verify against
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the text is present in the element's value.
|
||||
*/
|
||||
function textToBePresentInElementValue<T>(
|
||||
element: ElementFinder, text: string
|
||||
): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking that the title contains a case-sensitive substring.
|
||||
*
|
||||
* @param {string} title The fragment of title expected
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the title contains the string.
|
||||
*/
|
||||
function titleContains<T>(title: string): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking the title of a page.
|
||||
*
|
||||
* @param {string} title The expected title, which must be an exact match.
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the title equals the string.
|
||||
*/
|
||||
function titleIs<T>(title: string): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking that an element is present on the DOM of a page. This does not necessarily
|
||||
* mean that the element is visible. This is the opposite of 'stalenessOf'.
|
||||
*
|
||||
* @param {ElementFinder} elementFinder The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise
|
||||
* representing whether the element is present.
|
||||
*/
|
||||
function presenceOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking that an element is not attached to the DOM of a page.
|
||||
* This is the opposite of 'presenceOf'.
|
||||
*
|
||||
* @param {ElementFinder} elementFinder The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the element is stale.
|
||||
*/
|
||||
function stalenessOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking that an element is present on the DOM of a page and visible.
|
||||
* Visibility means that the element is not only displayed but also has a height and width that is
|
||||
* greater than 0. This is the opposite of 'invisibilityOf'.
|
||||
*
|
||||
* @param {ElementFinder} elementFinder The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the element is visible.
|
||||
*/
|
||||
function visibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking that an element is present on the DOM of a page. This does not necessarily
|
||||
* mean that the element is visible. This is the opposite of 'stalenessOf'.
|
||||
*
|
||||
* @param {ElementFinder} elementFinder The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the element is invisible.
|
||||
*/
|
||||
function invisibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
|
||||
/**
|
||||
* An expectation for checking the selection is selected.
|
||||
*
|
||||
* @param {ElementFinder} elementFinder The element to check
|
||||
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
|
||||
* whether the element is selected.
|
||||
*/
|
||||
function elementToBeSelected<T>(element: ElementFinder): webdriver.until.Condition<T>;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user