import { TitleCondition } from './conditions/TitleCondition' ; import { TitleNotMatchCondition } from './conditions/TitleNotMatchCondition' ; import { ElementVisibilityCondition , ElementLocatedCondition , ElementsLocatedCondition , } from './conditions/ElementVisibilityCondition' ; import { ElementStateCondition } from './conditions/ElementStateCondition' ; import { ElementSelectedCondition } from './conditions/ElementSelectedCondition' ; import { ElementTextNotMatchCondition } from './conditions/ElementTextNotMatchCondition' ; import { ElementTextCondition } from './conditions/ElementTextCondition' ; import { URLCondition } from './conditions/URLCondition' ; import { DialogCondition } from './conditions/DialogCondition' ; import { FrameCondition } from './conditions/FrameCondition' ; import { Condition } from './Condition' ; import { NullableLocatable , Locatable } from '../runtime/Locatable' ; import { URLNotMatchCondition } from './conditions/URLNotMatchCondition' ; /**
 * Until contains a wealth of useful <Condition>s.
 *
 * <[Condition]>s represent predicates used to wait for something to become true.
 *
 * These predicates include waiting for elements to become active, visible, invisible or disabled on the page.
 *
 * You typically use these to control the flow of you test.
 *
 */ export class Until { /**
     * Creates a condition that will wait until the input driver is able to switch to the designated frame.
     *
     * The target frame may be specified as:
     * - string name of the frame to wait for matching the frame's `name` or `id` attribute.
     * - (Coming soon) numeric index into window.frames for the currently selected frame.
     * - (Coming soon) locator which may be used to first locate a FRAME or IFRAME on the current page before attempting to switch to it.
     *
     * Upon successful resolution of this condition, the driver will be left focused on the new frame.
     */ static ableToSwitchToFrame ( frame ) { return new FrameCondition ( 'ableToSwitchToFrame' , frame ) ; } /**
     * Creates a condition that waits for an alert to be opened. Upon success,
     * the returned promise will be fulfilled with the handle for the opened alert.
     */ static alertIsPresent ( ) { return new DialogCondition ( 'alertIsPresent' ) ; } param selectorOrLocator static elementIsDisabled ( selectorOrLocator ) { return new ElementStateCondition ( 'elementIsDisabled' , selectorOrLocator , true ) ; } param selectorOrLocator static elementIsEnabled ( selectorOrLocator ) { return new ElementStateCondition ( 'elementIsEnabled' , selectorOrLocator , false ) ; } param selectorOrLocator static elementIsSelected ( selectorOrLocator ) { return new ElementSelectedCondition ( 'elementIsSelected' , selectorOrLocator , true ) ; } param selectorOrLocator static elementIsNotSelected ( selectorOrLocator ) { return new ElementSelectedCondition ( 'elementIsNotSelected' , selectorOrLocator , false ) ; } param selectorOrLocator static elementIsVisible ( selectorOrLocator ) { return new ElementVisibilityCondition ( 'elementIsVisible' , selectorOrLocator , true , false ) ; } param selectorOrLocator static elementIsNotVisible ( selectorOrLocator ) { return new ElementVisibilityCondition ( 'elementIsNotVisible' , selectorOrLocator , false , true ) ; } /**
     * Creates a condition which will wait until the element is located on the page.
     */ static elementLocated ( selectorOrLocator ) { return new ElementLocatedCondition ( 'elementLocated' , selectorOrLocator , true ) ; } /**
     * Creates a condition which will wait until the element's text exactly matches the target text, excluding leading and trailing whitespace.
     */ static elementTextIs ( selectorOrLocator , text ) { return new ElementTextCondition ( 'elementTextIs' , selectorOrLocator , text , false ) ; } /**
     * Creates a condition which will wait until the element's text not matches the target text, excluding leading and trailing whitespace.
     */ static elementTextIsNot ( selectorOrLocator , text ) { return new ElementTextNotMatchCondition ( 'elementTextIsNot' , selectorOrLocator , text ) ; } /**
     * Creates a condition which will wait until the element's text content contains the target text.
     */ static elementTextContains ( selectorOrLocator , text ) { return new ElementTextCondition ( 'elementTextContains' , selectorOrLocator , text , true ) ; } /**
     * Creates a condition which will wait until the element's text content does not contain the target text.
     */ static elementTextDoesNotContain ( selectorOrLocator , text ) { return new ElementTextNotMatchCondition ( 'elementTextDoesNotContain' , selectorOrLocator , text , true ) ; } /**
     * Creates a condition which will wait until the element's text matches the target Regular Expression.
     */ static elementTextMatches ( selectorOrLocator , regex ) { return new ElementTextCondition ( 'elementTextMatches' , selectorOrLocator , regex . toString ( ) ) ; } /**
     * Creates a condition which will wait until the element's text does not match the target Regular Expression.
     */ static elementTextDoesNotMatch ( selectorOrLocator , regex ) { return new ElementTextNotMatchCondition ( 'elementTextDoesNotMatch' , selectorOrLocator , regex . toString ( ) ) ; } /**
     * Creates a condition that will wait until at least the desired number of elements are found.
     */ static elementsLocated ( selectorOrLocator , desiredCount = 1 ) { return new ElementsLocatedCondition ( 'elementsLocated' , selectorOrLocator , desiredCount ) ; } /**
     * Creates a condition that will wait for the given element to become stale.
     * An element is considered stale once it is removed from the DOM, or a new page has loaded.
     */ /**
     * Creates a condition which waits until the page title contains the expected text.
     */ static titleContains ( title ) { return new TitleCondition ( 'titleContains' , title , true ) ; } /**
     * Creates a condition which waits until the page title does not contain the expected text.
     */ static titleDoesNotContain ( title ) { return new TitleNotMatchCondition ( 'titleDoesNotContain' , title , true ) ; } /**
     * Creates a condition which waits until the page title exactly matches the expected text.
     */ static titleIs ( title ) { return new TitleCondition ( 'titleIs' , title , false ) ; } /**
     * Creates a condition which waits until the page title does not match the expected text.
     */ static titleIsNot ( title ) { return new TitleNotMatchCondition ( 'titleIsNot' , title , false ) ; } /**
     * Creates a condition which waits until the page title matches the title `RegExp`.
     */ static titleMatches ( title ) { return new TitleCondition ( 'titleMatches' , `${ title }` , false ) ; } /**
     * Creates a condition which waits until the page title doesn not match the title `RegExp`.
     */ static titleDoesNotMatch ( title ) { return new TitleNotMatchCondition ( 'titleDoesNotMatch' , `${ title }` , false ) ; } /**
     * Creates a condition which waits until the page URL contains the expected path.
     */ static urlContains ( url ) { return new URLCondition ( 'urlContains' , url , true ) ; } /**
     * Creates a condition which waits until the page URL does not contain the expected path.
     */ static urlDoesNotContain ( url ) { return new URLNotMatchCondition ( 'urlDoesNotContain' , url , true ) ; } /**
     * Creates a condition which waits until the page URL exactly matches the expected URL.
     */ static urlIs ( url ) { return new URLCondition ( 'urlIs' , url , false ) ; } /**
     * Creates a condition which waits until the page URL does not match the expected URL.
     */ static urlIsNot ( url ) { return new URLNotMatchCondition ( 'urlIsNot' , url , false ) ; } /**
     * Creates a condition which waits until the page URL matches the supplied `RegExp`.
     */ static urlMatches ( url ) { return new URLCondition ( 'urlMatches' , url . toString ( ) , true ) ; } /**
     * Creates a condition which waits until the page URL does not match the supplied `RegExp`.
     */ static urlDoesNotMatch ( url ) { return new URLNotMatchCondition ( 'urlDoesNotMatch' , url . toString ( ) , false ) ; } }