Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sacoo7/selenium-js-extensions
Selenium safe JS bindings for executing user actions.
https://github.com/sacoo7/selenium-js-extensions
Last synced: about 1 month ago
JSON representation
Selenium safe JS bindings for executing user actions.
- Host: GitHub
- URL: https://github.com/sacoo7/selenium-js-extensions
- Owner: sacOO7
- License: mit
- Created: 2020-07-18T14:01:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T11:53:36.000Z (almost 2 years ago)
- Last Synced: 2024-10-02T00:39:00.377Z (about 1 month ago)
- Language: TypeScript
- Size: 1.73 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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 Promise2. 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
- **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).