# selenium-extensions

> Selenium JS bindings for executing stable user actions.

Latest version **1.0.0** (published 2020-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install selenium-extensions
pnpm add selenium-extensions
yarn add selenium-extensions
bun add selenium-extensions
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-07-20 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 26.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | sachin shinde |
| Maintainers | sachin76 |
| Keywords | selenium, browser-automation, e2e-testing, extensions |

## Links

- npm: https://www.npmjs.com/package/selenium-extensions
- Repository: https://github.com/sacOO7/selenium-js-extensions
- Homepage: https://github.com/sacOO7/selenium-js-extensions#readme
- Issues: https://github.com/sacOO7/selenium-js-extensions/issues
- npm.io page: https://npm.io/package/selenium-extensions

## Dependencies (2)

- [selenium-webdriver](https://npm.io/package/selenium-webdriver.md) ^4.0.0-alpha.7
- [@types/selenium-webdriver](https://npm.io/package/@types/selenium-webdriver.md) ^4.0.9

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-07-20

## README

# Selenium-js-extensions
- Contains JS bindings to mitigate flaky tests behaviour.
- Explicit waits, timeouts and native js code to ensure stable user interactions.

## Installation

- Using NPM
```shell script 
  npm install selenium-extensions --save  
```

- Using yarn
```shell script
  yarn add selenium-extensions --save
```

## Usage
- Import library, start using extensions as a part of original selenium implementation. 

```javascript
  import 'selenium-extensions';
```

or ES5

```javascript
   require('selenium-extensions');
```

-  Update **types** section in **tsconfig.json**

```editorconfig
  "compilerOptions": {
        "types": ["selenium-extensions"]
    }
```
- Once imported, following methods can be used on native selenium **WebDriver** and **WebElement** classes.

1. WebDriver -  
- **findElementSafe(locator, timeout)** - Locate element from the dom, passing selenium locator object, returns WebElementPromise 
- **findElementsSafe(locator, timeout)** - Locate elements from the dom, passing selenium locator object, returns Promise<WebElements[]>

2. WebElement - 
- **findElementSafe(locator, timeout)** - Locate element inside container element, passing selenium locator object, returns WebElementPromise
- **findElementsSafe(locator, timeout)** - Locate elements inside container element, passing selenium locator object, returns Promise<WebElements[]>
- **clickSafe(timeout)** - Clicks on the element on the DOM (Waits until it's visible and displayed on the DOM) 
- **clickForced(timeout)** - Force Clicks on the visible element (Doesn't matter if element is behind other element)
- **getTextSafe(timeout)** - Gets text from the visible input (Waits until it's visible and displayed on the DOM)
- **sendKeysSafe(args)** - Type text into input element
- **sendKeysForced(args)** - Type text into input using Javascript

## Notes
* Default timeout is 20000 ms.
* Methods with a timeout, waits for the element to be available on the DOM.
* Methods with action (click event or sending data) and timeout, waits for the element to be available and visible on the DOM.
* Methods with **force** postfix should be preferred, only if **safe** counterparts are flaky. (force executes inline JS code inside DOM to manipulate behaviour).

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