<commit_before># selsa

> Selenium, Saucelabs, Webdriver and lots of despair

[![Build Status](https://travis-ci.org/gr2m/selsa.svg?branch=master)](https://travis-ci.org/gr2m/selsa)
[![Dependency Status](https://david-dm.org/gr2m/selsa.svg)](https://david-dm.org/gr2m/selsa)
[![devDependency Status](https://david-dm.org/gr2m/selsa/dev-status.svg)](https://david-dm.org/gr2m/selsa#info=devDependencies)

`selsa` lets you run tests agains a local selenium or against Sauce Labs both locally or during your CI.

The objective of `selsa` is to do as little as possible. It provides
extensive debug logs and expose its underlying modules

- [selenium-standalone](https://www.npmjs.com/package/selenium-standalone),
- [sauce-connect-launcher](https://www.npmjs.com/package/sauce-connect-launcher)
- [selenium-sauce](https://www.npmjs.com/package/selenium-sauce)
- [webdriverio](https://www.npmjs.com/package/webdriverio)

Many projects aim for the best possible developer experience by hiding as much
of the underlying complexity as possible, and by combining it with test runners
and dev servers. But not `selsa`. It puts debug-ability first.

## Install

```
npm install --save selsa
```

## Usage

This example uses [tap](http://www.node-tap.org/), but `selsa` can be used
with any test framework

```js
const selsa = require('selsa')
const test = require('tap').test

const selsaOptions = {
  client: 'saucelabs:chrome'
}

test('Landing page', (t) => {
  selsa(selsaOptions, (error, api) => {
    api.browser
      .url('http://localhost:8000')
  })
    return this.client
      .url('/')
      .getTitle()
        .then((title) => {
          t.equals(title, 'My demo page')
          t.end()
        }))
  })
})
```

### Testing on Travis

`selsa` plays nicely with [Travis](http://travis-ci.org/). If
you want to test using selenium, make sure to only test in Firefox as it's the
only supported browser, and add the following lines:

```
before_install:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
```

You can also install a more recent firefox version. I recommend v48, as 49 and
later only works with the latest gecko driver and I couldn’t get it to work
myself yet

```
addons:
  firefox: "48.0"
```

I would also recommend to cache the saucelabs binaries for faster build

```
cache:
  directories:
  - node_modules/selenium-standalone/.selenium
```

Set `SAUCELABS_USERNAME` & `SAUCELABS_ACCESS_KEY` as env variables, and test
as many different browser configurations using the `env.matrix` setting, e.g.

```
env:
  matrix:
  - CLIENT=selenium:firefox
  - CLIENT=saucelabs:chrome
  - CLIENT="saucelabs:internet explorer:10:Windows 8"
  - CLIENT="saucelabs:iphone:8.4:OS X 10.11"
```

## Options

```js
selsa(selsaOptions, (error, api) => {})
```

`selsa` can be configured by passing `selsaOptions` as shown above or by using
ENV variables, listed below the option name.

<table>
  <thead>
    <tr>
      <th>Setting (ENV)</th>
      <th>Default / Example</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <strong>client</strong><br>
        (<code>CLIENT</code>)<br><br>

        (saucelabs|selenium):browserName:browserVerion:platform,
        e.g. 'saucelabs:internet explorer:10:win10'
      </td>
      <td><code>'selenium:chrome'</code></td>
    </tr>
    <tr>
      <td>
        <strong>timeout</strong><br>
        (<code>TIMEOUT</code>)<br><br>

        <a href="http://webdriver.io/api/protocol/timeouts.html">webdriver timouts</a>
      </td>
      <td><code>180000</code></td>
    </tr>
    <tr>
      <td>
        <strong>selenium.hub</strong><br>
        (<code>SELENIUM_HUB</code>)<br><br>

        Url to selenium hub
      </td>
      <td><code>'http://localhost:4444/wd/hub/status'</code></td>
    </tr>
    <tr>
      <td>
        <strong>saucelabs.connect.username</strong><br>
        (<code>SAUCELABS_USERNAME</code>)<br><br>

        Saucelabs username for authentication
      </td>
      <td>e.g. <code>'pat'</code></td>
    </tr>
    <tr>
      <td>
        <strong>saucelabs.connect.accessKey</strong><br>
        (<code>SAUCELABS_ACCESS_KEY</code>)<br><br>

        Saucelabs access key for authentication
      </td>
      <td>e.g. <code>'abcd5678-1234-1234-1234-abcd5678abcd'</code></td>
    </tr><commit_msg>docs(README): CLIENT_TIMEOUT and SELENIUM_VERSION configs<commit_after># selsa

> Selenium, Saucelabs, Webdriver and lots of despair

[![Build Status](https://travis-ci.org/gr2m/selsa.svg?branch=master)](https://travis-ci.org/gr2m/selsa)
[![Dependency Status](https://david-dm.org/gr2m/selsa.svg)](https://david-dm.org/gr2m/selsa)
[![devDependency Status](https://david-dm.org/gr2m/selsa/dev-status.svg)](https://david-dm.org/gr2m/selsa#info=devDependencies)

`selsa` lets you run tests agains a local selenium or against Sauce Labs both locally or during your CI.

The objective of `selsa` is to do as little as possible. It provides
extensive debug logs and expose its underlying modules

- [selenium-standalone](https://www.npmjs.com/package/selenium-standalone),
- [sauce-connect-launcher](https://www.npmjs.com/package/sauce-connect-launcher)
- [selenium-sauce](https://www.npmjs.com/package/selenium-sauce)
- [webdriverio](https://www.npmjs.com/package/webdriverio)

Many projects aim for the best possible developer experience by hiding as much
of the underlying complexity as possible, and by combining it with test runners
and dev servers. But not `selsa`. It puts debug-ability first.

## Install

```
npm install --save selsa
```

## Usage

This example uses [tap](http://www.node-tap.org/), but `selsa` can be used
with any test framework

```js
const selsa = require('selsa')
const test = require('tap').test

const selsaOptions = {
  client: 'saucelabs:chrome'
}

test('Landing page', (t) => {
  selsa(selsaOptions, (error, api) => {
    api.browser
      .url('http://localhost:8000')
  })
    return this.client
      .url('/')
      .getTitle()
        .then((title) => {
          t.equals(title, 'My demo page')
          t.end()
        }))
  })
})
```

### Testing on Travis

`selsa` plays nicely with [Travis](http://travis-ci.org/). If
you want to test using selenium, make sure to only test in Firefox as it's the
only supported browser, and add the following lines:

```
before_install:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
```

You can also install a more recent firefox version. I recommend v48, as 49 and
later only works with the latest gecko driver and I couldn’t get it to work
myself yet

```
addons:
  firefox: "48.0"
```

I would also recommend to cache the saucelabs binaries for faster build

```
cache:
  directories:
  - node_modules/selenium-standalone/.selenium
```

Set `SAUCELABS_USERNAME` & `SAUCELABS_ACCESS_KEY` as env variables, and test
as many different browser configurations using the `env.matrix` setting, e.g.

```
env:
  matrix:
  - CLIENT=selenium:firefox
  - CLIENT=saucelabs:chrome
  - CLIENT="saucelabs:internet explorer:10:Windows 8"
  - CLIENT="saucelabs:iphone:8.4:OS X 10.11"
```

## Options

```js
selsa(selsaOptions, (error, api) => {})
```

`selsa` can be configured by passing `selsaOptions` as shown above or by using
ENV variables, listed below the option name.

<table>
  <thead>
    <tr>
      <th>Setting (ENV)</th>
      <th>Default / Example</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <strong>client</strong><br>
        (<code>CLIENT</code>)<br><br>

        (saucelabs|selenium):browserName:browserVerion:platform,
        e.g. 'saucelabs:internet explorer:10:win10'
      </td>
      <td><code>'selenium:chrome'</code></td>
    </tr>
    <tr>
      <td>
        <strong>timeout</strong><br>
        (<code>CLIENT_TIMEOUT</code>)<br><br>

        <a href="http://webdriver.io/api/protocol/timeouts.html">webdriver timouts</a>
      </td>
      <td><code>180000</code></td>
    </tr>
    <tr>
      <td>
        <strong>selenium.hub</strong><br>
        (<code>SELENIUM_HUB</code>)<br><br>

        Url to selenium hub
      </td>
      <td><code>'http://localhost:4444/wd/hub/status'</code></td>
    </tr>
    <tr>
      <td>
        <strong>selenium.standalone.version</strong><br>
        (<code>SELENIUM_VERSION</code>)<br><br>

        Selenium version to install
      </td>
      <td>see <a href="https://github.com/vvo/selenium-standalone/blob/master/lib/default-config.js">selenium-standalone defaults</a></td>
    </tr>
    <tr>
      <td>
        <strong>saucelabs.connect.username</strong><br>
        (<code>SAUCELABS_USERNAME</code>)<br><br>

        Saucelabs username for authentication
      </td>
      <td>e.g. <code>'pat'</code></td>
    </tr>
    <tr>
      <td>
        <strong>saucelabs.connect.accessKey</strong><br>
        (<code>SAUCELABS_ACCESS_KEY</code>)<br><br>

        Saucelabs access key for authentication
      </td>
      <td>e.g. <code>'abcd5678-1234-1234-1234-abcd5678abcd'</code></td>
    </tr>
{'fraction_non_alphanumeric': 0.15751736500112032, 'fraction_numerical': 0.014116065426842931, 'mean_word_length': 3.2651696129956997, 'pattern_counts': {'":': 0, '<': 192, '<?xml version=': 0, '>': 202, 'https://': 21, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2575218', 'n_tokens_mistral': 3374, 'n_tokens_neox': 3159, 'n_words': 723}