Skip to content
Parashuram N edited this page Mar 7, 2014 · 15 revisions

Setup

Browser-perf requires selenium to launch the browsers and collect metrics. The following options can be used to setting up selenium

Selenium Setup

Local Installation

  1. Ensure that you have Java installed.
  2. Download Selenium Server (formerly the Selenium RC Server)
  3. Download the latest WebDriver for Chrome from here for your operating system.
  4. Start the selenium server locally using java -jar selenium-server-standalone-2.40.0.jar -Dwebdriver.chrome.driver=chromedriver.exe. Don't forget to correct the filename of the jar and Chrome driver file
  5. Wait till you see the logs that say Selenium has started.
  6. Browser-perf can now be run
  • Using the command line browser-perf http://url.com --selenium=localhost:4444 --verbose
  • Or using the Node API, setting the selenium key in the options variable to http://localhost:4444/wd/hub

Saucelabs or Browserstack

  1. Saucelabs and Browserstack provides hosted selenium. You would just need to connect to their servers. Note that if the site under test is not accessible over the internet, the tunnel module may need to be used.
  2. Set the selenium option for the command line or your node module to ondemand.saucelabs.com or hub.browserstack.com.
  3. Set the username and accesskey parameters to the corresponding user name and access key. This tool will automatically take care of adding the credentials either to the capabilities in case of browserstack or to the selenium url in case of saucelabs.

View the Node Module API page for details on how to set the options.

Testing Cordova Applications for Android 4.4

  1. Pre-req: Android tools and your Cordova Android application.
  2. Ensure that you have your Cordova application installed on the emulator or the device
  3. Ensure that the adb server is started using adb start-server.
  4. Ensure that your target emulator or device is connected using adb devices
  5. Download the latest WebDriver for Chrome from here for your operating system.
  6. Start the Chrome driver. It usually starts on 9515.
  7. Set the selenium option for the the node module to http://localhost:9515/. If you specified a --url-base when starting the Chrome driver, ensure that it is included in the selenium tab. Here is a sample of how to use it in your node program.

Here is how the code would look like.

var browserPerf = require('../../');

browserPerf(undefined, function(err, res) {
	if (err) {
		console.log(err);
	} else {
		console.log(res);
	}
}, {
	selenium: 'http://localhost:9515', //chrome driver port
	browsers: [{
		browserName: 'android',
		chromeOptions: {
			androidActivity: 'io.cordova.hellocordova.HelloCordova', // name of your activity
			androidPackage: 'io.cordova.hellocordova' // name of the package
		},
		loggingPrefs: {
			performance: 'ALL'
		}
	}]
});

Clone this wiki locally