gpt4 book ai didi

angularjs - Protractor 和 appium - 无法读取未定义的属性

转载 作者:行者123 更新时间:2023-12-03 06:50:47 24 4
gpt4 key购买 nike

我正在尝试在 Android 设备上进行一些 Selenium 测试。所有连接接缝均正常工作,因为在设备上我可以看到 chrome 打开,然后 url 更改为数据;

但网址更改后,一切都停止了

[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)

我认为它与wdBridge有关,好像我检查wd-bridge,js,Q看起来像这样:

var Q = wd.Q;

我不知道为什么它不起作用。

我的 Protractor 配置文件如下:

"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
};

一如既往,我们非常感谢任何帮助。谢谢

最佳答案

我自己设法解决了这个问题。这就是我所做的:

从上面的代码开始,如上所述,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
};

现在工作正常。

注意:如果未找到 wdwdBridgeprotractor 模块,则无需全局安装它们(对于例如,npm install wd 而不是 npm install -g wd)

希望这可以帮到你。

关于angularjs - Protractor 和 appium - 无法读取未定义的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34964445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com