我正在尝试在Android设备上吃一些selenium测试。 所有的连接接缝都能正常工作,就像在设备上我可以看到镀铬开口然后将网址更改为数据;
但在网址更改后,一切都停止了
[launcher]错误:TypeError:无法读取module.exports中未定义的属性'Q'(C:\ src \ angular-test \ node_modules \ wd-bridge \ lib \ wd-bridge.js:6:13)
我认为这与wdBridge有关,好像我检查了wd-bridge,js,Q看起来像这样:
var Q = wd.Q;
我不知道为什么它不起作用。
我的量角器配置文件如下:
"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
};
任何帮助,一如既往,真的很感激。 感谢
答案 0 :(得分:4)
我自己设法解决了这个问题。 这就是我的所作所为:
从上面的代码开始,如上所述,Q未定义。
这是因为可以在节点模块文件夹内的wd-bridge.js文件中找到的var Q = wd.Q
位于需要2个参数的函数内。
我改变了我的protractor.config.js文件:
"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
};
它现在正在完美运作。
注意:如果找不到wd
,wdBridge
或protractor
个模块,则需要全部安装它们(例如,npm install wd
而不是npm install -g wd
$before = "2016-01-19 06:22:00";
$after = (new DateTime($before))->format('Y-m-d\TH:i:s.s\Z');
echo "Before: $before\n";
echo "After: $after";
)强>
希望这可以帮助你。