-
Notifications
You must be signed in to change notification settings - Fork 60
Node Module API
When using it as a node module do a require(browser-perf) after installing it using npm install --save browser-perf.
var browserPref = require('browser-perf');
browserPerf('http://url-to-test.com', function(err, res){/*callback*/}, options);The callback function is invoked after the URL is tested on all the browsers. The callback is passed two arguments - error and results. They are both arrays, with one entry per browser that the URL was tested on. More details about the options object below.
The options object is a set of key value pairs as follows
No default value
A configuration file can be used to specify all the option. This is a JSON file with all the keys and values as described in this section. Any values specified directly in the object overrides the value in the configuration file. The path of this file is relative to the current working directory.
Default: http://localhost:4444/wd/hub
The address where the selenium server is running. See setting up selenium on information on how to get started with selenium. This can be an object like described here or a URL string. Some examples of the possible values for this key are
-
http://localhost:4444/wd/hubfor a local installation of selenium -
http://localhost:9515/to directly connect to a chrome driver running locally -
ondemand.saucelabs.com,ondemand.saucelabs.com/wd/huborhttp://ondemand.saucelabs.comto connect to selenium running on Saucelabs -
{ hostname: '127.0.0.1',port: 4444, user: 'username', pwd: 'password'}to connect to selenium that is password protected locally
Default:
undefinedfor both username and accesskey Services like Saucelabs or Browserstack also require a username or an access key to start the testing. These can be specified using theusernameandaccesskeykeys in the options object. They are automatically added to the URL in case of Saucelabs, or to the browser capabilities object in case of Browserstack. Note that the username and access key can also be specified in the Selenium URL.
Default:
{browserName: 'chrome',version: 32}This can either be a string separated by commas, an array of strings, or an array of objects with the desired capabilities. Some examples are
chrome, firefox['chrome', 'firefox'][{browserName: 'chrome', version: 32, chromeOptions: {args: ['--start-maximized'], loggingPrefs:{performance: 'ALL'}}}]
Note: When using any metric that relies on collecting information from Chrome's about:tracing, you should specify the platform (Windows, LINUX or OS X). This platform determines where the tracing output will be saved
_Note: When using the android browser, the browserName should be android. Chrome should be installed on the emulator or the device and com.chromeOptions.androidPackage is automatically set to com.android.chrome
Note: _When testing Cordova apps, set the androidActivity and androidPackage in the chrome options.
An example is
[{
browserName: 'android',
chromeOptions: {
androidActivity: 'io.cordova.hellocordova.HelloCordova', // name of your activity
androidPackage: 'io.cordova.hellocordova' // name of the package
}
}]The preScript key
An example options object may look like the following