<commit_before># Selenium Cookbook

[![Cookbook Version](http://img.shields.io/cookbook/v/selenium.svg?style=flat-square)][supermarket]
[![Build Status](http://img.shields.io/travis/dhoer/chef-selenium.svg?style=flat-square)][travis]
[![GitHub Issues](http://img.shields.io/github/issues/dhoer/chef-selenium.svg?style=flat-square)][github]

[supermarket]: https://supermarket.chef.io/cookbooks/selenium
[travis]: https://travis-ci.org/dhoer/chef-selenium
[github]: https://github.com/dhoer/chef-selenium

This cookbook installs and configures Selenium and WebDriver components (http://www.seleniumhq.org/).

This cookbook comes with the following Resource/Providers:

- **[selenium_hub](https://github.com/dhoer/chef-selenium#selenium_hub)** - Installs and configures selenium-grid hubs.
- **[selenium_node](https://github.com/dhoer/chef-selenium#selenium_node)** - Installs and configures selenium-grid nodes
with support for [ChromeDriver](http://chromedriver.storage.googleapis.com/index.html),
[InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver), and
[FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver).
- **[selenium_phantomjs](https://github.com/dhoer/chef-selenium#selenium_phantomjs)** - Installs and configures
[PhantomJS](http://phantomjs.org/) as a selenium-grid node or as a standalone server via
[GhostDriver](https://github.com/detro/ghostdriver).

#### Roadmap

Add support for the following (any volunteers?):

- [HtmlUnit](https://code.google.com/p/selenium/wiki/HtmlUnitDriver)
- Mac OS X platform and [SafariDriver](https://code.google.com/p/selenium/wiki/SafariDriver)
- [Appium](http://appium.io)

## Requirements

Chef 11 or greater

### Platforms

- CentOS, RedHat
- Ubuntu
- Windows

### Cookbooks

These cookbooks are referenced with suggests, so be sure to depend on cookbooks that apply:

- windows
- nssm - Windows hubs only

## Usage

See [selenium_test](https://github.com/dhoer/chef-selenium/tree/master/test/fixtures/cookbooks/selenium_test)
cookbook for working cross platform examples. Note that the provided examples in this cookbook have passwords
unencrypted for simplicity.

## selenium_hub

Installs and configures selenium-grid hubs.

#### Requirements

- Java must be installed outside of this cookbook.

### Example

##### Install selenium-grid hub

```ruby
selenium_hub 'selenium_hub' do
  action :install
end
```

#### Attributes

See [hub](https://github.com/dhoer/chef-selenium/blob/master/resources/hub.rb) resource for a complete list
of attributes. See [default](https://github.com/dhoer/chef-selenium/blob/master/attributes/default.rb) attributes
for global cookbook settings.

- `name` - Name attribute. The name of the service.
- `host` - Hostname. Defaults to `null` if nil.
- `port` - Port.  Defaults to `4444` if nil.
- `jvm_args` - Jvm arguments (e.g., -Xmx256M). Defaults to `nil`.

## selenium_node

Installs and configures selenium-grid nodes with support for
[ChromeDriver](http://chromedriver.storage.googleapis.com/index.html),
[InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver), and
[FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver).

#### Requirements

- Java must be installed outside of this cookbook.
- Browsers (e.g., chrome, firefox, etc...) must be installed outside of this cookbook.
- Linux nodes without a physical monitor require a headless display
(e.g., [xvfb](https://supermarket.chef.io/cookbooks/xvfb), [x11vnc](https://supermarket.chef.io/cookbooks/x11vnc),
etc...) and must be installed and configured outside this cookbook.
- Windows nodes require an account (e.g., username/password/domain) for auto-logon. Note that the password is
stored unencrypted under windows registry: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`.

### Example

##### Install selenium-grid node with Chrome, Firefox and Internet Explorer capability

```ruby
selenium_node 'selenium_node' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  capabilities [
    {
      browserName: 'chrome',
      maxInstances: 5,
      seleniumProtocol: 'WebDriver'
    },
    {
      browserName: 'firefox',
      maxInstances: 5,
      seleniumProtocol: 'WebDriver'
    },
    {
      browserName: 'internet explorer',
      maxInstances: 1,
      seleniumProtocol: 'WebDriver'
    }
  ]
  action :install
end
```

#### Attributes

See [node](https://github.com/dhoer/chef-selenium/blob/master/resources/node.rb) resource for a complete list
of attributes. See [default](https://github.com/dhoer/chef-selenium/blob/master/attributes/default.rb) attributes
for global cookbook settings.

- `name` - Name attribute. The name of the service or auto-logon script (Windows nodes only).
- `host` - Hostname. Defaults to null if nil.
- `port` - Port.  Defaults to 4444 if nil.
- `hubHost` - Selenium-grid hub hostname. Defaults to `ip` if nil.
- `hubPort` - Selenium-grid hub port. Defaults to `4444`.
- `jvm_args` - Jvm arguments (e.g., -Xmx256M). Defaults to `nil`.
- `capabilities` - The following drivers are supported and installed based on
[capabilities](https://code.google.com/p/selenium/wiki/DesiredCapabilities):
    - [ChromeDriver](http://chromedriver.storage.googleapis.com/index.html) -
Installed if capabilities contains browser name `chrome`
    - [InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver) -
32-bit or 64-bit installed if capabilities contains browser name `internet explorer`
    - [FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver) - Pre-installed with Selenium server
- `username` - Windows account username. Required for Windows only.
- `password` - Windows account password. Required for Windows only.
- `domain` - Windows account domain. Optional.  Defaults to `nil`.

## selenium_phantomjs

Installs and configures [PhantomJS](http://phantomjs.org/) as a selenium-grid node or as a standalone server via
[GhostDriver](https://github.com/detro/ghostdriver).

#### Requirements

- [PhantomJS](http://phantomjs.org/) must be installed outside of this cookbook.

#### Examples

##### Install PhantomJS as a selenium-grid node

```ruby
selenium_phantomjs 'selenium_phantomjs' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  action :install
end
```

##### Install PhantomJS as a standalone server by setting webdriverSeleniumGridHub to false

```ruby
selenium_phantomjs 'selenium_phantomjs_nogrid' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  webdriverSeleniumGridHub false<commit_msg>Add windows info to phantomjs requirements<commit_after># Selenium Cookbook

[![Cookbook Version](http://img.shields.io/cookbook/v/selenium.svg?style=flat-square)][supermarket]
[![Build Status](http://img.shields.io/travis/dhoer/chef-selenium.svg?style=flat-square)][travis]
[![GitHub Issues](http://img.shields.io/github/issues/dhoer/chef-selenium.svg?style=flat-square)][github]

[supermarket]: https://supermarket.chef.io/cookbooks/selenium
[travis]: https://travis-ci.org/dhoer/chef-selenium
[github]: https://github.com/dhoer/chef-selenium

This cookbook installs and configures Selenium and WebDriver components (http://www.seleniumhq.org/).

This cookbook comes with the following Resource/Providers:

- **[selenium_hub](https://github.com/dhoer/chef-selenium#selenium_hub)** - Installs and configures selenium-grid hubs.
- **[selenium_node](https://github.com/dhoer/chef-selenium#selenium_node)** - Installs and configures selenium-grid nodes
with support for [ChromeDriver](http://chromedriver.storage.googleapis.com/index.html),
[InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver), and
[FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver).
- **[selenium_phantomjs](https://github.com/dhoer/chef-selenium#selenium_phantomjs)** - Installs and configures
[PhantomJS](http://phantomjs.org/) as a selenium-grid node or as a standalone server via
[GhostDriver](https://github.com/detro/ghostdriver).

#### Roadmap

Add support for the following (any volunteers?):

- [HtmlUnit](https://code.google.com/p/selenium/wiki/HtmlUnitDriver)
- Mac OS X platform and [SafariDriver](https://code.google.com/p/selenium/wiki/SafariDriver)
- [Appium](http://appium.io)

## Requirements

Chef 11 or greater

### Platforms

- CentOS, RedHat
- Ubuntu
- Windows

### Cookbooks

These cookbooks are referenced with suggests, so be sure to depend on cookbooks that apply:

- windows
- nssm - Windows hubs only

## Usage

See [selenium_test](https://github.com/dhoer/chef-selenium/tree/master/test/fixtures/cookbooks/selenium_test)
cookbook for working cross platform examples. Note that the provided examples in this cookbook have passwords
unencrypted for simplicity.

## selenium_hub

Installs and configures selenium-grid hubs.

#### Requirements

- Java must be installed outside of this cookbook.

### Example

##### Install selenium-grid hub

```ruby
selenium_hub 'selenium_hub' do
  action :install
end
```

#### Attributes

See [hub](https://github.com/dhoer/chef-selenium/blob/master/resources/hub.rb) resource for a complete list
of attributes. See [default](https://github.com/dhoer/chef-selenium/blob/master/attributes/default.rb) attributes
for global cookbook settings.

- `name` - Name attribute. The name of the service.
- `host` - Hostname. Defaults to `null` if nil.
- `port` - Port.  Defaults to `4444` if nil.
- `jvm_args` - Jvm arguments (e.g., -Xmx256M). Defaults to `nil`.

## selenium_node

Installs and configures selenium-grid nodes with support for
[ChromeDriver](http://chromedriver.storage.googleapis.com/index.html),
[InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver), and
[FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver).

#### Requirements

- Java must be installed outside of this cookbook.
- Browsers (e.g., chrome, firefox, etc...) must be installed outside of this cookbook.
- Linux nodes without a physical monitor require a headless display
(e.g., [xvfb](https://supermarket.chef.io/cookbooks/xvfb), [x11vnc](https://supermarket.chef.io/cookbooks/x11vnc),
etc...) and must be installed and configured outside this cookbook.
- Windows nodes require an account (e.g., username/password/domain) for auto-logon. Note that the password is
stored unencrypted under windows registry: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`.

### Example

##### Install selenium-grid node with Chrome, Firefox and Internet Explorer capability

```ruby
selenium_node 'selenium_node' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  capabilities [
    {
      browserName: 'chrome',
      maxInstances: 5,
      seleniumProtocol: 'WebDriver'
    },
    {
      browserName: 'firefox',
      maxInstances: 5,
      seleniumProtocol: 'WebDriver'
    },
    {
      browserName: 'internet explorer',
      maxInstances: 1,
      seleniumProtocol: 'WebDriver'
    }
  ]
  action :install
end
```

#### Attributes

See [node](https://github.com/dhoer/chef-selenium/blob/master/resources/node.rb) resource for a complete list
of attributes. See [default](https://github.com/dhoer/chef-selenium/blob/master/attributes/default.rb) attributes
for global cookbook settings.

- `name` - Name attribute. The name of the service or auto-logon script (Windows nodes only).
- `host` - Hostname. Defaults to null if nil.
- `port` - Port.  Defaults to 4444 if nil.
- `hubHost` - Selenium-grid hub hostname. Defaults to `ip` if nil.
- `hubPort` - Selenium-grid hub port. Defaults to `4444`.
- `jvm_args` - Jvm arguments (e.g., -Xmx256M). Defaults to `nil`.
- `capabilities` - The following drivers are supported and installed based on
[capabilities](https://code.google.com/p/selenium/wiki/DesiredCapabilities):
    - [ChromeDriver](http://chromedriver.storage.googleapis.com/index.html) -
Installed if capabilities contains browser name `chrome`
    - [InternetExplorerDriver](https://code.google.com/p/selenium/wiki/InternetExplorerDriver) -
32-bit or 64-bit installed if capabilities contains browser name `internet explorer`
    - [FirefoxDriver](https://code.google.com/p/selenium/wiki/FirefoxDriver) - Pre-installed with Selenium server
- `username` - Windows account username. Required for Windows only.
- `password` - Windows account password. Required for Windows only.
- `domain` - Windows account domain. Optional.  Defaults to `nil`.

## selenium_phantomjs

Installs and configures [PhantomJS](http://phantomjs.org/) as a selenium-grid node or as a standalone server via
[GhostDriver](https://github.com/detro/ghostdriver).

#### Requirements

- [PhantomJS](http://phantomjs.org/) must be installed outside of this cookbook.
- Windows nodes require an account (e.g., username/password/domain) for auto-logon. Note that the password is
stored unencrypted under windows registry: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`.

#### Examples

##### Install PhantomJS as a selenium-grid node

```ruby
selenium_phantomjs 'selenium_phantomjs' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  action :install
end
```

##### Install PhantomJS as a standalone server by setting webdriverSeleniumGridHub to false

```ruby
selenium_phantomjs 'selenium_phantomjs_nogrid' do
  username 'Administrator' if platform?('windows')
  password 'password' if platform?('windows')
  webdriverSeleniumGridHub false
{'fraction_non_alphanumeric': 0.12962421406638397, 'fraction_numerical': 0.00453282643661354, 'mean_word_length': 4.678289746782897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 48, 'lorem ipsum': 0, 'www.': 2, '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': '2511549', 'n_tokens_mistral': 4555, 'n_tokens_neox': 4212, 'n_words': 1093}