Skip to content

Commit

Permalink
add enablePerformanceLogging cap for chrome/android hybrid, so we can…
Browse files Browse the repository at this point in the history
… get performance logs
  • Loading branch information
jlipps committed Mar 7, 2014
1 parent 9ba883f commit 80ebe34
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
3 changes: 2 additions & 1 deletion docs/caps.md
Expand Up @@ -22,6 +22,7 @@ Appium server capabilities
|`device-ready-timeout`| Timeout in seconds while waiting for device to become ready|`5`|
|`compressXml`| [setCompressedLayoutHeirarchy(true)](http://developer.android.com/tools/help/uiautomator/UiDevice.html#setCompressedLayoutHeirarchy%28boolean%29)| `true`|
|`androidCoverage`| Fully qualified instrumentation class. Passed to -w in adb shell am instrument -e coverage true -w | `com.my.Pkg/com.my.Pkg.instrumentation.MyInstrumentation`|
|`enablePerformanceLogging`| (Chrome and webview only) Enable Chromedriver's performance logging (default `false`)| `true`, `false`|

--

Expand All @@ -42,4 +43,4 @@ Appium server capabilities
|`safariAllowPopups`| (Sim-only) Allow javascript to open new windows in Safari. Default keeps current sim setting|`true` or `false`|
|`safariIgnoreFraudWarning`| (Sim-only) Prevent Safari from showing a fraudulent website warning. Default keeps current sim setting.|`true` or `false`|
|`safariOpenLinksInBackground`| (Sim-only) Whether Safari should allow links to open in new windows. Default keeps current sim setting.|`true` or `false`|
|`keepKeyChains`| (Sim-only) Whether to keep keychains (Library/Keychains) when appium session is started/finished|`true` or `false`|
|`keepKeyChains`| (Sim-only) Whether to keep keychains (Library/Keychains) when appium session is started/finished|`true` or `false`|
7 changes: 6 additions & 1 deletion lib/devices/android/android-hybrid.js
Expand Up @@ -28,7 +28,12 @@ androidHybrid.startChromedriverProxy = function (cb) {
if (this.chromedriver !== null) {
return cb(new Error("We already have a chromedriver instance running"));
}
this.chromedriver = new Chromedriver(this.args.chromeDriverPort,
var chromeArgs = {
port: this.args.chromeDriverPort
, deviceId: this.adb.curDeviceId
, enablePerformanceLogging: this.args.enablePerformanceLogging
};
this.chromedriver = new Chromedriver(chromeArgs,
this.onChromedriverExit.bind(this));
this.proxyHost = this.chromedriver.proxyHost;
this.proxyPort = this.chromedriver.proxyPort;
Expand Down
9 changes: 7 additions & 2 deletions lib/devices/android/chrome.js
Expand Up @@ -58,8 +58,13 @@ ChromeAndroid.prototype.start = function (cb, onDie) {
};

ChromeAndroid.prototype.prepareChromedriver = function (cb) {
this.chromedriver = new Chromedriver(this.args.proxyPort,
this.adb.curDeviceId, this.onChromedriverExit.bind(this));
var chromeArgs = {
port: this.args.proxyPort
, deviceId: this.adb.curDeviceId
, enablePerformanceLogging: this.args.enablePerformanceLogging
};
this.chromedriver = new Chromedriver(chromeArgs,
this.onChromedriverExit.bind(this));
this.proxyTo = this.chromedriver.proxyTo.bind(this.chromedriver);
this.proxyHost = this.chromedriver.proxyHost;
this.proxyPort = this.chromedriver.proxyPort;
Expand Down
10 changes: 7 additions & 3 deletions lib/devices/android/chromedriver.js
Expand Up @@ -12,10 +12,11 @@ var proxyTo = require('../common.js').proxyTo
, path = require('path')
, fs = require('fs');

var Chromedriver = function (port, deviceId, onDie) {
var Chromedriver = function (args, onDie) {
this.proxyHost = '127.0.0.1';
this.proxyPort = port || 9515;
this.deviceId = deviceId;
this.proxyPort = args.port || 9515;
this.deviceId = args.deviceId;
this.enablePerformanceLogging = args.enablePerformanceLogging;
this.proc = null;
this.onChromedriverStart = null;
this.onDie = onDie;
Expand Down Expand Up @@ -120,6 +121,9 @@ Chromedriver.prototype.onClose = function (code, signal) {
Chromedriver.prototype.createSession = function (caps, cb) {
logger.info("Creating Chrome session");
caps.chromeOptions.androidDeviceSerial = this.deviceId;
if (this.enablePerformanceLogging) {
caps.loggingPrefs = {performance: 'ALL'};
}
var data = {
sessionId: null,
desiredCapabilities: caps
Expand Down
17 changes: 14 additions & 3 deletions test/functional/common/webview-base.js
Expand Up @@ -22,9 +22,10 @@ module.exports = function (app) {

var setup = function (context) {
return setupBase(context, {
nonSyntheticWebClick: true,
app: app,
safariIgnoreFraudWarning: true
nonSyntheticWebClick: true
, app: app
, safariIgnoreFraudWarning: true
, enablePerformanceLogging: true
});
};

Expand Down Expand Up @@ -283,6 +284,16 @@ module.exports = function (app) {
.should.eventually.contain("Google")
.nodeify(done);
});
it('should be able to get performance logs', function (done) {
if (!isChrome) return _skip(
"Performance logs aren't available except in Chrome", done);
driver
.logTypes()
.should.eventually.include('performance')
.log('performance').then(function (logs) {
logs.length.should.be.above(0);
}).nodeify(done);
});
});

describe('implicit wait', function () {
Expand Down

0 comments on commit 80ebe34

Please sign in to comment.