# selenium-smart-wait

> Conditions for common usage of selenium-webdriver

Latest version **0.0.7** (published 2017-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install selenium-smart-wait
pnpm add selenium-smart-wait
yarn add selenium-smart-wait
bun add selenium-smart-wait
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2017-03-17 |
| First published | 2017-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Gildas Garcia |
| Maintainers | djhi |

## Links

- npm: https://www.npmjs.com/package/selenium-smart-wait
- Repository: https://github.com/marmelab/selenium-smart-wait
- Homepage: https://github.com/marmelab/selenium-smart-wait#readme
- Issues: https://github.com/marmelab/selenium-smart-wait/issues
- npm.io page: https://npm.io/package/selenium-smart-wait

## Recent versions

- 0.0.7 (latest) — 2017-03-17
- 0.0.6 — 2017-03-17
- 0.0.5 — 2017-03-15
- 0.0.4 — 2017-03-15
- 0.0.3 — 2017-02-24
- 0.0.2 — 2017-02-24
- 0.0.1 — 2017-02-24

## README

# selenium-smart-wait

[![Build Status](https://travis-ci.org/marmelab/selenium-smart-wait.svg?branch=master)](https://travis-ci.org/marmelab/selenium-smart-wait)

Conditions for common usage of [selenium-webdriver](http://seleniumhq.github.io/selenium/docs/api/javascript/index.html),
built to avoid random test failures on CI.

## Installation

Install with:

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

or

```sh
yarn add --dev selenium-smart-wait
```

## Usage

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

```js
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](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebElement.html)
, a `locator` such as `By.css('.my_css_class')` (see selenium webdriver documentation on [WebDriver](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html),
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](http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/until.html)
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:

```js
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`.

---
_Source: https://npm.io/package/selenium-smart-wait · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
