3

Я пытаюсь обедать некоторые тесты селена на устройстве Android. Все соединительные швы для работы, так как на устройстве я могу видеть открытие хрома, а затем изменение url на данные;транспортир и appium - невозможно прочитать свойство undefined

, но после того, как изменения 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-мост, 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 
}; 

Любая помощь, как всегда, очень ценится. Thanks

ответ

4

Мне удалось решить это самостоятельно. Вот что я сделал:

Начиная с кода выше, как уже упоминалось, Q не был определен. Это связано с тем, что var Q = wd.Q, который находится внутри файла wd-bridge.js внутри папки узла узла, находится внутри функции, которая требует 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)

Надеется, что это может помочь вам.

Смежные вопросы