API

Waiters

Condition

A Condition represents a predicate which can be used to wait for an ElementHandle. They are generally created by using Until's helper methods.

Until

Until contains a wealth of useful Conditions.

Conditions 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.

Methods

Until.ableToSwitchToFrame(frame)

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.

Example:

step('Switch frame', async browser => {
  await browser.wait(Until.ableToSwitchToFrame('frame1'))
  ...
})

Parameters

Until.alertIsPresent()

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.

Example:

step('Handle alert', async browser => {
  let dialog = await browser.wait(Until.alertIsPresent())
  await dialog.accept()
})

Parameters

Until.elementIsDisabled(selectorOrLocator)

Creates a condition that will wait for the given element to be disabled

Example:

step('Element state', async browser => {
  let btnLocator = By.css('button.submit')
  await browser.wait(Until.elementIsDisabled(btnLocator))
  let element = await browser.findElement(btnLocator)
  // element disabled attribute should be true
})

Parameters

Until.elementIsEnabled(selectorOrLocator)

Creates a condition that will wait for the given element to be enabled

Parameters

Until.elementIsNotSelected(selectorOrLocator)

Creates a condition that will wait for the given element to be in the DOM, yet not visible to the user

Parameters

Until.elementIsNotVisible(selectorOrLocator)

Creates a condition that will wait for the given element to become visible.

Example:

step("Step 1", async browser => {
     await browser.click(By.css('.hide-panel'))
  await browser.wait(Until.elementIsNotVisible(By.id("btn")))
})

Parameters

Until.elementIsSelected(selectorOrLocator)

Creates a condition that will wait for the given element to be deselected.

Parameters

Until.elementIsVisible(selectorOrLocator)

Creates a condition that will wait for the given element to be selected.

Example:

step("Step 1", async browser => {
  await browser.wait(Until.elementIsVisible(By.partialLinkText("Start")))
})

Parameters

Until.elementLocated(selectorOrLocator)

Creates a condition which will wait until the element is located on the page.

Parameters

Until.elementTextContains(selectorOrLocator, text)

Creates a condition which will wait until the element's text content contains the target text.

Parameters

Until.elementTextIs(selectorOrLocator, text)

Creates a condition which will wait until the element's text exactly matches the target text, excluding leading and trailing whitespace.

Parameters

Until.elementTextMatches(selectorOrLocator, regex)

Creates a condition which will wait until the element's text matches the target Regular Expression.

Parameters

Until.elementsLocated(selectorOrLocator, desiredCount)

Creates a condition that will wait until at least the desired number of elements are found.

Parameters

Until.titleContains(title)

Creates a condition which waits until the page title contains the expected text.

Parameters

Until.titleIs(title)

Creates a condition which waits until the page title exactly matches the expected text.

Parameters

Until.titleMatches(title)

Creates a condition which waits until the page title matches the title RegExp.

Parameters

Until.urlContains(url)

Creates a condition which waits until the page URL contains the expected path.

Parameters

Until.urlIs(url)

Creates a condition which waits until the page URL exactly matches the expected URL.

Parameters

Until.urlMatches(url)

Creates a condition which waits until the page URL matches the supplied RegExp.

Parameters