This cookbook installs and configures Selenium (http://www.seleniumhq.org/).
This cookbook comes with the following recipes:
- default - Downloads and installs Selenium Standalone jar.
- hub - Installs and configures a Selenium Hub as a service.
- node - Installs and configures a Selenium Node as service on Linux and a GUI service on Mac OS X and Windows.
Resources selenium_hub and selenium_node are also available.
See selenium_grid cookbook that wraps selenium, browsers, drivers, and screenresolution cookbooks into one comprehensive cookbook.
- Java (not installed by this cookbook)
- Chef 11.16+
- CentOS, RedHat
- Mac OS X
- Ubuntu
- Windows
- windows
- nssm - Required by Windows services only (e.g. Hub and HtmlUnit running in background)
- macosx_autologin - Required by Mac OS X GUI services
Downloads and installs Selenium Standalone jar.
node['selenium']['url']- The download URL of Selenium Standalone jar.node['selenium']['windows']['home']- Home directory. Default#{ENV['SYSTEMDRIVE']}/selenium.node['selenium']['windows']['java']- Path to Java executable. Default#{ENV['SYSTEMDRIVE']}\\java\\bin\\java.exe.node['selenium']['unix']['home']- Home directory. Default/opt/selenium.node['selenium']['unix']['java']- Path to Java executable. Default/usr/bin/java.
Installs and configures a Selenium Hub as a service.
node['selenium']['hub']['servicename']- The name of the service. Defaultselenium_hub.node['selenium']['hub']['host']- Defaultnull.node['selenium']['hub']['port']- Default4444.node['selenium']['hub']['jvm_args']- Defaultnil.node['selenium']['hub']['newSessionWaitTimeout']- Default-1.node['selenium']['hub']['servlets']- Default[].node['selenium']['hub']['prioritizer']- Defaultnull.node['selenium']['hub']['capabilityMatcher']- Defaultorg.openqa.grid.internal.utils.DefaultCapabilityMatcher.node['selenium']['hub']['throwOnCapabilityNotPresent']- Defaulttrue.node['selenium']['hub']['nodePolling']- Default5000.node['selenium']['hub']['cleanUpCycle']- Default5000.node['selenium']['hub']['timeout']- Default30_000.node['selenium']['hub']['browserTimeout']- Default0.node['selenium']['hub']['maxSession']- Default5.node['selenium']['hub']['jettyMaxThreads']- Default-1.
Installs and configures a Selenium Node as service on Linux and a GUI service on Mac OS X and Windows.
- Firefox browser must be installed outside of this cookbook.
- Linux nodes without a physical monitor require a headless display (e.g., xvfb, x11vnc, etc...) and must be installed and configured outside this cookbook.
- Mac OS X/Windows nodes must run as a GUI service and that requires a username
and password for automatic login. Note that Windows password is stored unencrypted under windows registry
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogonand Mac OS X password is stored encrypted under/etc/kcpasswordbut it can be easily decrypted.
node['selenium']['node']['servicename']- The name of the service. Defaultselenium_node.node['selenium']['node']['host']- Defaultip.node['selenium']['node']['port']- Default5555.node['selenium']['node']['jvm_args']- Defaultnil.node['selenium']['node']['proxy']- Defaultorg.openqa.grid.selenium.proxy.DefaultRemoteProxy.node['selenium']['node']['maxSession']- Default5.node['selenium']['node']['register']- Defaulttrue.node['selenium']['node']['registerCycle']- Default5000.node['selenium']['node']['hubPort']- Selenium-grid hub hostname. Default4444.node['selenium']['node']['hubHost']- Selenium-grid hub port. Defaultip.node['selenium']['node']['capabilities']- Based on capabilities. Default[].node['selenium']['node']['additional_args']- Default[].node['selenium']['node']['display']- Default:0.- Mac OS X/Windows only - Set both username and password to run as a GUI service:
username- Defaultnil.password- Defaultnil. Note that Windows password is stored unencrypted under windows registryHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogonand Mac OS X password is stored encrypted under/etc/kcpasswordbut it can be easily decrypted.domain- Optional for Windows only. Defaultnil.
node.override['selenium']['node']['username'] = 'vagrant' if platform?('windows', 'mac_os_x')
node.override['selenium']['node']['password'] = 'vagrant' if platform?('windows', 'mac_os_x')
node.override['selenium']['node']['capabilities'] = [
{
browserName: 'firefox',
maxInstances: 5,
seleniumProtocol: 'WebDriver'
},
{
browserName: 'htmlunit',
maxInstances: 1,
platform: 'ANY',
seleniumProtocol: 'WebDriver'
}
]
include_recipe 'selenium::node'Installs and configures a Selenium Hub as a service.
This is a partial list of attributes available. See hub resource for the complete listing of attributes.
name- Name attribute. The name of the service.host- Hostname. Defaultnull.port- Port. Default4444.
Installs and configures a Selenium Node as a service.
This is a partial list of attributes available. See node resource for the complete listing of attributes.
name- Name attribute. The name of the service.host- Hostname. Defaultnull.port- Port. Default5555.hubHost- Selenium-grid hub hostname. Defaultip.hubPort- Selenium-grid hub port. Default4444.capabilities- Based on capabilities. Default[].- Mac OS X/Windows only - Set both username and password to run as a GUI service:
username- Defaultnil.password- Defaultnil. Note that Windows password is stored unencrypted under windows registryHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogonand Mac OS X password is stored encrypted under/etc/kcpasswordbut it can be easily decrypted.domain- Optional for Windows only. Defaultnil.
selenium_node 'selenium_node' do
username 'vagrant' if platform?('windows', 'mac_os_x')
password 'vagrant' if platform?('windows', 'mac_os_x')
capabilities [
{
browserName: 'firefox',
maxInstances: 5,
seleniumProtocol: 'WebDriver'
},
{
browserName: 'htmlunit',
maxInstances: 1,
platform: 'ANY',
seleniumProtocol: 'WebDriver'
}
]
action :install
endThe Selenium cookbook includes custom ChefSpec matchers you can use to test your own cookbooks.
Example Matcher Usage
expect(chef_run).to install_selenium_hub('resource_name').with(
port: '4444'
)Selenium Cookbook Matchers
- install_selenium_hub(resource_name)
- install_selenium_node(resource_name)
- Ask specific questions on Stack Overflow.
- Report bugs and discuss potential features in Github issues.
Please refer to CONTRIBUTING.
MIT - see the accompanying LICENSE file for details.