This cookbook installs and configures Selenium and WebDriver components (http://www.seleniumhq.org/).
This cookbook comes with the following Resource/Providers:
- selenium_hub - Installs and configures selenium-grid hubs.
- selenium_node - Installs and configures selenium-grid nodes with support for ChromeDriver, FirefoxDriver, HtmlUnitDriver, and InternetExplorerDriver.
- selenium_phantomjs - Installs and configures PhantomJS as a selenium-grid node or as a standalone server via GhostDriver.
- Add support for Appium
- Chef 11.14 or higher (
sensitiveresource introduced)
- CentOS, RedHat
- Mac OS X
- Ubuntu
- Windows
These cookbooks are referenced with suggests, so be sure to depend on cookbooks that apply:
- windows
- nssm - Required for Windows services only (e.g. Hub, PhantomJS, and HtmlUnit running in background)
See selenium_test cookbook for working cross platform examples. Note that provided examples in this cookbook have passwords unencrypted for simplicity.
Installs and configures selenium-grid hubs.
- Java must be installed outside of this cookbook.
selenium_hub 'selenium_hub' do
action :install
endThis 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. Defaults tonull.port- Port. Defaults to4444.
Installs and configures selenium-grid nodes with support for ChromeDriver, FirefoxDriver, HtmlUnitDriver, and InternetExplorerDriver.
- 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, x11vnc, etc...) and must be installed and configured outside this cookbook.
- Mac OS X/Windows nodes (with the exception of HtmlUnitDriver) 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.
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: 'htmlunit',
maxInstances: 1,
platform: 'ANY',
seleniumProtocol: 'WebDriver'
},
{
browserName: 'internet explorer',
maxInstances: 1,
seleniumProtocol: 'WebDriver'
}
]
action :install
endThis is a partial list of attributes available. See node resource for the complete listing of attributes.
name- Name attribute. The name of the service or Windows foreground startup script.host- Hostname. Defaults tonull.port- Port. Defaults to5555.hubHost- Selenium-grid hub hostname. Defaults toip.hubPort- Selenium-grid hub port. Defaults to4444.capabilities- The following drivers are supported and installed based on capabilities:- ChromeDriver -
Installed if capabilities contains browser name
chrome - FirefoxDriver - Pre-installed with Selenium server
- HtmlUnitDriver - Pre-installed with Selenium server
- InternetExplorerDriver - 32-bit or 64-bit
installed if capabilities contains browser name
internet explorer
- ChromeDriver -
Installed if capabilities contains browser name
- Mac OS X/Windows only - Set both username and password to run as a GUI service or leave nil to run service in
background:
username- Defaults tonil.password- Defaults tonil. 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. Defaults tonil.
Installs and configures PhantomJS as a selenium-grid node or as a standalone server via GhostDriver (Mac OS X is not supported).
- PhantomJS must be installed outside of this cookbook.
- Windows nodes have the option to run as a GUI service and that requires a username and password to automatically
login.
Note that Windows password is stored unencrypted under windows registry
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.
selenium_phantomjs 'selenium_phantomjs' do
action :install
endselenium_phantomjs 'selenium_phantomjs_nogrid' do
webdriverSeleniumGridHub false
action :install
endThis is a partial list of attributes available. See phantomjs resource for the complete listing of attributes.
name- Name attribute. The name of the service or Windows foreground startup script.webdriver- Webdriver ip:port. Defaults to#{node['ipaddress']}:8910.webdriverSeleniumGridHub- Webdriver selenium-grid hub url. Set tofalseto install PhantomJS as a standalone service. Defaults tohttp://#{node['ipaddress']}:4444.- Windows only - Set both username and password to run as a GUI service or leave nil to run service in background:
username- Defaults tonil.password- Defaults tonil. Note that Windows password is stored unencrypted under windows registryHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon.domain- Optional. Defaults tonil.
The 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)
- install_selenium_phantomjs(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.