Protractor is agnostic to how you set up your browser - it wraps WebDriverJS, so all browser setup for WebDriverJS applies. This doc serves as a collection for information surrounding how to set up browsers.
In your Protractor configuration file, all browser set up is done within the capabilities
JSON object. This is passed directly to the WebDriver Builder.
See the DesiredCapabilities Docs for full information on which properties are available.
Simply set a different browser name in the capabilites object
capabilities: {
'browserName': 'firefox'
}
You may need to install a separate binary to run another browser, such as IE or Android.
Chrome options are nested in the chromeOptions
object. A full list of options is at the chromedriver site. For example, to show an FPS counter in the upper right, your configuration would look like this:
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['show-fps-counter=true']
}
},
In order to test locally with PhantomJS, you'll need to either have it installed globally, or relative to your project. For global install see the PhantomJS download page. For relative install run: npm install --save-dev phantomjs
.
Add phantomjs to the driver capabilities, and include a path to the binary if using local installation:
capabilities: {
'browserName': 'phantomjs',
// should be able to omit this property if phantomjs installed globally
'phantomjs.binary.path':'./node_modules/phantomjs/bin/phantomjs'
}
If you are not using the Protractor runner (for example, you're using Mocha) and you are setting up webdriver yourself, you will need to create a capabilities object and pass it in to the webdriver builder. The webdriver.Capabilities
namespace offers some preset options. See the webdriver capabilities source.
driver = new webdriver.Builder().
usingServer('http://localhost:4444/wd/hub').
withCapabilities(webdriver.Capabilities.phantomjs()).
build();