Reputation: 14283
I'm trying to lunch some selenium tests on an android device. All the connection seams to work, as on the device i can see chrome opening and then the url change to data;
but after the url changes, everything stops saying
[launcher] Error: TypeError: Cannot read property 'Q' of undefined at module.exports (C:\src\angular-test\node_modules\wd-bridge\lib\wd-bridge.js:6:13)
I think it is related to wdBridge, as if i check wd-bridge,js, Q looks like this:
var Q = wd.Q;
I have no idea why its not working.
My protractor config file is the following:
"use strict";
exports.config = {
specs: ['e2e/*.js'],
framework: 'jasmine',
capabilities: {
'appium-version': '',
'platformName': 'Android',
'platformVersion': '6.0',
'deviceName': 'Android Device',
'autoWebView': true,
'app': "C:/src/angular-test/platforms/android/build/outputs/apk/android-debug.apk",
'udid': '',
'fullReset': true,
'browserName': 'chrome'
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {
}
},
onPrepare: function () {
var DisplayProcessor = require('../node_modules/jasmine-spec-reporter/src/display-processor');
var SpecReporter = require('jasmine-spec-reporter');
function TimeProcessor(options) {
}
function getTime() {
var now = new Date();
return now.getHours() + ':' +
now.getMinutes() + ':' +
now.getSeconds()
}
TimeProcessor.prototype = new DisplayProcessor();
TimeProcessor.prototype.displaySuite = function (suite, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displaySuccessfulSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displayFailedSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displayPendingSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
// add jasmine spec reporter
var reporter = new SpecReporter({
customProcessors: [TimeProcessor]
});
jasmine.getEnv().addReporter(reporter);
var wd = require('wd'),
wdBridge = require('wd-bridge')(wd);
wdBridge.initFromProtractor(exports.config);
},
//seleniumAddress: 'http://localhost:4723/wd/hub' //For mobile devices
seleniumAddress: 'http://localhost:4444/wd/hub' //For desktop
};
Any help, as always, is really appreciated. Thanks
Upvotes: 4
Views: 1279
Reputation: 14283
I managed to solve this myself. Here's what i did:
Starting from the code above, as mentioned, Q was undefined.
This was because var Q = wd.Q
that can be found inside wd-bridge.js file inside the node module folder is inside a function that needs 2 parameters.
I changed my protractor.config.js file like this:
"use strict";
var wd = require('wd');
var protractor = require ('protractor');
var wdBridge = require('wd-bridge')(protractor,wd);
exports.config = {
specs: ['e2e/*.js'],
framework: 'jasmine',
capabilities: {
'appium-version': '',
'platformName': 'Android',
'platformVersion': '6.0',
'deviceName': 'Android Device',
'autoWebView': true,
'app': "C:/src/angular-test/platforms/android/build/outputs/apk/android-debug.apk",
'udid': '',
'fullReset': true,
'browserName': 'chrome'
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {
}
},
onPrepare: function () {
var DisplayProcessor = require('../node_modules/jasmine-spec-reporter/src/display-processor');
var SpecReporter = require('jasmine-spec-reporter');
function TimeProcessor(options) {
}
function getTime() {
var now = new Date();
return now.getHours() + ':' +
now.getMinutes() + ':' +
now.getSeconds()
}
TimeProcessor.prototype = new DisplayProcessor();
TimeProcessor.prototype.displaySuite = function (suite, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displaySuccessfulSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displayFailedSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
TimeProcessor.prototype.displayPendingSpec = function (spec, log) {
return getTime() + ' - ' + log;
};
// add jasmine spec reporter
var reporter = new SpecReporter({
customProcessors: [TimeProcessor]
});
jasmine.getEnv().addReporter(reporter);
wdBridge.initFromProtractor(exports.config);
},
//seleniumAddress: 'http://localhost:4723/wd/hub' //For mobile devices
seleniumAddress: 'http://localhost:4444/wd/hub' //For desktop
};
it is now working perfectly.
Note: If you have wd
, wdBridge
or protractor
modules not found, you need to install them NOT GLOBALLY (for example, npm install wd
instead of npm install -g wd
)
Hope this can help you out.
Upvotes: 5