Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjirou/selenium-webdriver-util
A loosely coupled utilities for selenium-webdriver
https://github.com/kjirou/selenium-webdriver-util
Last synced: 14 days ago
JSON representation
A loosely coupled utilities for selenium-webdriver
- Host: GitHub
- URL: https://github.com/kjirou/selenium-webdriver-util
- Owner: kjirou
- License: mit
- Created: 2015-08-11T11:08:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T07:11:02.000Z (over 3 years ago)
- Last Synced: 2024-12-07T12:04:50.051Z (22 days ago)
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# selenium-webdriver-util
[![npm version](https://badge.fury.io/js/selenium-webdriver-util.svg)](http://badge.fury.io/js/selenium-webdriver-util)
[![Circle CI](https://circleci.com/gh/kjirou/selenium-webdriver-util.svg?style=svg)](https://circleci.com/gh/kjirou/selenium-webdriver-util)A loosely coupled utilities for [selenium-webdriver](https://code.google.com/p/selenium/wiki/WebDriverJs)
## Installation
```
npm install --save-dev selenium-webdriver-util
```## Overview
This module is utilities for selenium-webdriver.
It has the following static functions.
- `waitForElements`
- Wait to find expected elements
- `waitForElement`
- Wait to find a expected element
- `filterElementsByHtml`
- Filter elements by keyword or RegExp matcher
- `selectOption`
- Select a option tag from a select tag
- `breakpoint`
- To stop running tests until receive a key from the terminalPlease refer function's comment too!
## Examples
`waitForElements`:
```
var webdriver = require('selenium-webdriver');
var webdriverUtil = require('selenium-webdriver-util');driver
.get('http://foobarbaz.qux/')
.then(function() {
return webdriverUtil.waitForElements(driver, webdriver.By.css('ul li'), { min: 2 });
})
.then(function(elements) {
// Run here after finding 2 or more 'ul li' elements
})
;
````filterElementsByHtml`:
```
var webdriver = require('selenium-webdriver');
var webdriverUtil = require('selenium-webdriver-util');driver
.get('http://foobarbaz.qux/')
.then(function() {
//
//
- Apple
- Grape
- Orange
//
//
//
//
//
return driver.findElements(webdriver.By.css('ul li'));
})
.then(function(elements) {
return webdriverUtil.filterElementsByHtml(elements, 'ra');
})
.then(function(elements) {
// Find "Grape" and "Orange" elements
})
;
```
`selectOption`:
```
var webdriver = require('selenium-webdriver');
var webdriverUtil = require('selenium-webdriver-util');
driver
.get('http://foobarbaz.qux/')
.then(function() {
//
//
// Apple
// Grape
// Orange
//
//
return driver.findElement(webdriver.By.css('select'));
})
.then(function(element) {
return webdriverUtil.selectOption(element, 'Grape');
})
.then(function(element) {
// Select a "Grape" option, and it returns the selected option element
})
;
```