# selenium-runner

> Run a [{url+JSTest}, ..] combo in selenium grid, in parallel, in multiple browsers

Latest version **0.2.0** (published 2013-02-06) · MIT license · 0 weekly downloads

## Install

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

## 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.2.0 |
| Published | 2013-02-06 |
| First published | 2013-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Vincent Voyer |
| Maintainers | vvo |
| Keywords | selenium, runner, parallel, wd |

## Links

- npm: https://www.npmjs.com/package/selenium-runner
- Repository: git@github.com:vvo/selenium-runner
- npm.io page: https://npm.io/package/selenium-runner

## Dependencies (3)

- [wd](https://npm.io/package/wd.md) 0.0.x
- [async](https://npm.io/package/async.md) 0.1.x
- [selenium-grid-status](https://npm.io/package/selenium-grid-status.md) 0.0.x

## 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

- 0.2.0 (latest) — 2013-02-06
- 0.1.0 — 2013-02-05

## README

selenium-runner
===============

Run a [{url+JSTest}, ..] combo in selenium grid, in parallel, in multiple browsers.

Basically, this module will launch a set of tests, in the browsers you want.
A test is defined by a URL to visit and a JavaScript callback to execute when the page
is ready.

```bash
npm install
node example
```

## Writing tests

We want to check the `<title>` of http://www.google.com in multiple browsers.
We will run the same test on http://www.yahoo.com and it will fail because the title
is different.

### Test file

Write your test file, it's a callback that will get a ready [browser object](https://github.com/admc/wd/).

check-title.js
```js
module.exports = function checkTitle(browser, cb) {
  browser.title(function(err, title) {
    if (err !== null) cb(err);

    if (title === 'Google') {
      cb(null);
    } else {
      cb(new Error('UH OH Title is not ok! Are you on google.com?'));
    }
  });
}
```
### Some configuration

* remoteCfg: Where is the [selenium grid](http://code.google.com/p/selenium/wiki/Grid2), you can
also use [saucelabs](https://saucelabs.com/)
* browsers: On which browsers to launch every test
* concurrency: How many tests a browser can launch in parallel

config.json
```json
{
  "remoteCfg": {
    "host": "127.0.0.1",
    "port": 4444
  },
  "browsers": [{
    "browserName": "internet explorer",
    "version": "9"
  }, {
    "browserName": "chrome",
    "version": "latest"
  }],
  "concurrency": 2
}
```

### Run them all!

launcher.js
```js
var seleniumRunner = require('selenium-runner');

// tests to run
var tests = [{
  url: 'http://www.google.com',
  exec: require('./check-title.js')
}, {
  url: 'http://www.yahoo.com',
  exec: require('./check-title.js')
}];

var config = require('./config.json');

// launch tests
seleniumRunner(config, tests, testCallback, endCallback);

// For each browser, you get the result of calling your test (check-title) here
// You always get the context: {url: 'http://', browser: {browserName: '', version: }}
function testCallback(err, context) {
  console.log('A test finished', arguments);
}

// Called when all tests have finished/or an error popped while connecting to the grid
// It will not get called when an error is emitted from a test
function endCallback(err) {
  console.log('All tests ended', arguments);
}
```

### Results

```bash
-> % node example
You should get 4 test callbacks and one end callback
A test finished { '0': null,
  '1':
   { url: 'http://www.google.com',
     browser: { browserName: 'internet explorer', version: '9' } } }
A test finished { '0': null,
  '1':
   { url: 'http://www.google.com',
     browser: { browserName: 'chrome', version: 'latest' } } }
A test finished { '0': [Error: UH OH Title is not ok! Are you on google.com?],
  '1':
   { url: 'http://www.yahoo.com',
     browser: { browserName: 'chrome', version: 'latest' } } }
A test finished { '0': [Error: UH OH Title is not ok! Are you on google.com?],
  '1':
   { url: 'http://www.yahoo.com',
     browser: { browserName: 'internet explorer', version: '9' } } }
All tests ended { '0': null }
```

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