0.0.7 • Published 8 years ago

selenium-smart-wait v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

selenium-smart-wait

Build Status

Conditions for common usage of selenium-webdriver, built to avoid random test failures on CI.

Installation

Install with:

npm install --save-dev selenium-smart-wait

or

yarn add --dev selenium-smart-wait

Usage

Simply import the exported conditions and pass them to driver.wait:

import { elementValueIs } from 'selenium-smart-wait';

const TIMEOUT = 5000;

// ... mocha, jasmine, whatever ...
await driver.wait(elementValueIs('.my-input', 'expected value'), TIMEOUT);

All conditions expect either an existing WebElement , a locator such as By.css('.my_css_class') (see selenium webdriver documentation on WebDriver, especially the findElement and findElements methods) or a string. If a string is given, it will be considered as a css selector.

API

  • elementsCountIs: wait until the specified count of elements is found.
  • elementValueIs: wait until the element has the specified value. You should only pass input elements to this condition.
  • elementIsClicked: wait until the element has been successfully clicked.
  • elementHasBeenSentKeys: wait until the element has successfully been sent keys clicked.

Some conditions from selenium-webdriver have also been added but you can now pass them a locator too (please refer to the selenium webdriver documentation for details about them).

Important: You must pass a timeout number as the last argument when calling these conditions:

  • elementIsDisabled
  • elementIsEnabled
  • elementIsNotSelected
  • elementIsNotVisible
  • elementIsSelected
  • elementIsVisible
  • elementTextContains
  • elementTextIs
  • elementTextMatches
  • stalenessOf

Use them like this:

import { stalenessOf } from 'selenium-smart-wait';

const TIMEOUT = 5000;

// ... mocha, jasmine, whatever ...
await driver.wait(stalenessOf('.my-input', TIMEOUT));

Contributing

Coverage data is available in ./coverage after executing make test.

An HTML report is generated in ./coverage/lcov-report/index.html.

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago