<commit_before>Webdriver/selenium 2.0 javascript bindings for nodejs [![Build Status](https://travis-ci.org/christian-bromann/webdriverjs.png)](https://travis-ci.org/christian-bromann/webdriverjs) [![Selenium Test Status](https://saucelabs.com/buildstatus/webdriverjs)](https://saucelabs.com/u/webdriverjs) [![Dependency Status](https://gemnasium.com/christian-bromann/webdriverjs.png)](https://gemnasium.com/christian-bromann/webdriverjs)
=====================================================

This library is a webdriver module for nodejs. It makes it possible to write
super easy selenium tests in your favorite BDD or TDD test framework. Even
Cucumber tests are supported. Take a look into the [example](https://github.com/camme/webdriverjs/tree/master/examples)
directory for test samples.

## How to install it

Either download it from github or use npm:
    
```shell
npm install webdriverjs
```

To run tests on your local machine, you have to download a selenium standalone
server which executes the selenium commands. You find the latest version
[here](https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.35.0.jar).
It is also possible to run the tests in the could (e.g. on BrowserStack, Sauce Labs or TestingBot). For more informations, see below.

## Example of webdriverjs

Run selenium server first:  

```shell
java -jar path/to/your/selenium-server-standalone-2.35.0.jar
```

Webdriverjs has just a few methods. Most of the methods you will use regurarly
are the methods available from the client. To begin using Webdriverjs you just
need to create a client.

**example using [Mocha](http://visionmedia.github.com/mocha/) and [Chai](http://chaijs.com/)**

```js
var webdriverjs = require('webdriverjs'),
    client = {};

describe('my webdriverjs tests', function(){
    this.timeout(99999999);
    before(function(){
            client = webdriverjs.remote(options);
            client.init();
    });

    it('Github test',function(done) {
        client
            .url('https://github.com/')
            .getElementSize('.header-logo-wordmark', function(err, result) {
                expect(err).to.be.null;
                assert.strictEqual(result.height , 30);
                assert.strictEqual(result.width, 94);
            })
            .getTitle(function(err, title) {
                expect(err).to.be.null;
                assert.strictEqual(title,'GitHub · Build software better, together.');
            })
            .getElementCssProperty('class name','subheading', 'color', function(err, result){
                expect(err).to.be.null;
                assert.strictEqual(result, 'rgba(136, 136, 136, 1)');
            })
            .call(done);
    });

    after(function(done) {
        client.end(done);
    });
});
```

See more examples with other libraries in the [example directory](https://github.com/Camme/webdriverjs/tree/master/examples).

## Options

### desiredCapabilities
Type: `Object`<br>

**Example:**

```js
browserName: 'chrome',  // options: firefox, chrome, opera, safari
version: '27.0',         // browser version
platform: 'XP',          // OS platform
tags: ['tag1','tag2'],   // specify some tags (e.g. if you use Sauce Labs)
name: 'my test'          // set name for test (e.g. if you use Sauce Labs)
```

### logLevel
Type: `String`<br>
Default: *verbose*<br>
Options: *verbose* | *silent* | *command* | *data* | *result*

### singleton
Create client as singleton instance for use in different files<br>
Type: `Boolean`<br>
Default: *true*

## [Sauce Labs](https://saucelabs.com/) support
To run your tests via Sauce Labs, add the following attributes to your option
object. If you are using Webdriverjs in a public repository, never publish your
Sauce Labs key! Export these informations as enviroment variables.

```js
host: 'ondemand.saucelabs.com', // Sauce Labs remote host
user: '<username>',             // your username
key:  '<access-key>',           // your access key
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.saucelabs.example.js)!

## [BrowserStack](http://www.browserstack.com/) support
You can also run your tests with BrowserStack on a remote machine.

```js
host: 'hub.browserstack.com', // Browserstack remote host
user: '<username>',           // your username
key:  '<access-key>',         // your access key
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.browserstack.example.js)!

## [TestingBot](https://testingbot.com/) support
You can also run your tests with BrowserStack on a remote machine.

```js
host: 'hub.testingbot.com', // TestingBot remote host
user: '<client_key>',       // your client key
key:  '<client_secret>',    // your client secret
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.testingbot.example.js)!

## webdriverjs.endAll
If you wish to end all sessions, you can call the endAll method:

    require("webdriverjs").endAll(callback);
    
Where callback is an optional parameter. This method can be used if you run
lots of tests, and you want to make sure that all sessions on your selenium
server are closed when you are done. Usually its enough to close each client
with its end() method, but if you, for some reason, want to make sure that
no sessions are open, use endAll(). (note: this method is also available
from the client returned from .remote() as well, but its the same as
webdriverjs.endAll())

## webdriverjs.sessions
To get a list of all open sessions, you can call:

    require("webdriverjs").sessions(callback);<commit_msg>added twitter logos of remote services in readme file<commit_after>Webdriver/selenium 2.0 javascript bindings for nodejs [![Build Status](https://travis-ci.org/christian-bromann/webdriverjs.png)](https://travis-ci.org/christian-bromann/webdriverjs) [![Selenium Test Status](https://saucelabs.com/buildstatus/webdriverjs)](https://saucelabs.com/u/webdriverjs) [![Dependency Status](https://gemnasium.com/christian-bromann/webdriverjs.png)](https://gemnasium.com/christian-bromann/webdriverjs)
=====================================================

This library is a webdriver module for nodejs. It makes it possible to write
super easy selenium tests in your favorite BDD or TDD test framework. Even
Cucumber tests are supported. Take a look into the [example](https://github.com/camme/webdriverjs/tree/master/examples)
directory for test samples.

## How to install it

Either download it from github or use npm:
    
```shell
npm install webdriverjs
```

To run tests on your local machine, you have to download a selenium standalone
server which executes the selenium commands. You find the latest version
[here](https://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.35.0.jar).
It is also possible to run the tests in the could (e.g. on BrowserStack, Sauce Labs or TestingBot). For more informations, see below.

## Example of webdriverjs

Run selenium server first:  

```shell
java -jar path/to/your/selenium-server-standalone-2.35.0.jar
```

Webdriverjs has just a few methods. Most of the methods you will use regurarly
are the methods available from the client. To begin using Webdriverjs you just
need to create a client.

**example using [Mocha](http://visionmedia.github.com/mocha/) and [Chai](http://chaijs.com/)**

```js
var webdriverjs = require('webdriverjs'),
    client = {};

describe('my webdriverjs tests', function(){
    this.timeout(99999999);
    before(function(){
            client = webdriverjs.remote(options);
            client.init();
    });

    it('Github test',function(done) {
        client
            .url('https://github.com/')
            .getElementSize('.header-logo-wordmark', function(err, result) {
                expect(err).to.be.null;
                assert.strictEqual(result.height , 30);
                assert.strictEqual(result.width, 94);
            })
            .getTitle(function(err, title) {
                expect(err).to.be.null;
                assert.strictEqual(title,'GitHub · Build software better, together.');
            })
            .getElementCssProperty('class name','subheading', 'color', function(err, result){
                expect(err).to.be.null;
                assert.strictEqual(result, 'rgba(136, 136, 136, 1)');
            })
            .call(done);
    });

    after(function(done) {
        client.end(done);
    });
});
```

See more examples with other libraries in the [example directory](https://github.com/Camme/webdriverjs/tree/master/examples).

## Options

### desiredCapabilities
Type: `Object`<br>

**Example:**

```js
browserName: 'chrome',  // options: firefox, chrome, opera, safari
version: '27.0',         // browser version
platform: 'XP',          // OS platform
tags: ['tag1','tag2'],   // specify some tags (e.g. if you use Sauce Labs)
name: 'my test'          // set name for test (e.g. if you use Sauce Labs)
```

### logLevel
Type: `String`<br>
Default: *verbose*<br>
Options: *verbose* | *silent* | *command* | *data* | *result*

### singleton
Create client as singleton instance for use in different files<br>
Type: `Boolean`<br>
Default: *true*

## <img src="http://a0.twimg.com/profile_images/794342508/Logo_Square.png" width="48" /> [Sauce Labs](https://saucelabs.com/) support
To run your tests via Sauce Labs, add the following attributes to your option
object. If you are using Webdriverjs in a public repository, never publish your
Sauce Labs key! Export these informations as enviroment variables.

```js
host: 'ondemand.saucelabs.com', // Sauce Labs remote host
user: '<username>',             // your username
key:  '<access-key>',           // your access key
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.saucelabs.example.js)!

## <img src="http://a0.twimg.com/profile_images/1440403042/logo-separate-big_normal.png" width="48" /> [BrowserStack](http://www.browserstack.com/) support
You can also run your tests with BrowserStack on a remote machine.

```js
host: 'hub.browserstack.com', // Browserstack remote host
user: '<username>',           // your username
key:  '<access-key>',         // your access key
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.browserstack.example.js)!

## <img src="https://si0.twimg.com/profile_images/1647337797/testingbot1_bigger.png" width="48" /> [TestingBot](https://testingbot.com/) support
You can also run your tests with TestingBot on a remote machine.

```js
host: 'hub.testingbot.com', // TestingBot remote host
user: '<client_key>',       // your client key
key:  '<client_secret>',    // your client secret
port: 80
```

Find a test example [here](https://github.com/camme/webdriverjs/blob/master/examples/webdriverjs.testingbot.example.js)!

## webdriverjs.endAll
If you wish to end all sessions, you can call the endAll method:

    require("webdriverjs").endAll(callback);
    
Where callback is an optional parameter. This method can be used if you run
lots of tests, and you want to make sure that all sessions on your selenium
server are closed when you are done. Usually its enough to close each client
with its end() method, but if you, for some reason, want to make sure that
no sessions are open, use endAll(). (note: this method is also available
from the client returned from .remote() as well, but its the same as
webdriverjs.endAll())

## webdriverjs.sessions
To get a list of all open sessions, you can call:

    require("webdriverjs").sessions(callback);
{'fraction_non_alphanumeric': 0.13572649572649573, 'fraction_numerical': 0.010683760683760684, 'mean_word_length': 3.5922291993720563, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 31, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4680494', 'n_tokens_mistral': 3638, 'n_tokens_neox': 3399, 'n_words': 1104}