在远程Selenium服务器上通过Jenkins运行量角器测试未找到任何规格

时间:2016-10-11 22:01:32

标签: selenium jenkins protractor

我可以在我的远程selenium服务器上本地运行测试,它们运行得很好。

当我在Jenkins的同一个远程selenium服务器上的Jenkins盒子上运行它时,我找到了No Specs,在我的selenium服务器的输出中,我看到以下内容:

21:33:41.256 INFO - Executing: [execute async script: try { return (function (attempts, ng12Hybrid, asyncCallback) {
  var callback = function(args) {
    setTimeout(function() {
      asyncCallback(args);
    }, 0);
  };
  var check = function(n) {
    try {
      if (!ng12Hybrid && window.getAllAngularTestabilities) {
        callback({ver: 2});
      } else if (window.angular && window.angular.resumeBootstrap) {
        callback({ver: 1});
      } else if (n < 1) {
        if (window.angular) {
          callback({message: 'angular never provided resumeBootstrap'});
        } else {
          callback({message: 'retries looking for angular exceeded'});
        }
      } else {
        window.setTimeout(function() {check(n - 1);}, 1000);
      }
    } catch (e) {
      callback({message: e});
    }
  };
  check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10, false]])
21:33:41.273 INFO - Done: [execute async script: try { return (function (attempts, ng12Hybrid, asyncCallback) {
  var callback = function(args) {
    setTimeout(function() {
      asyncCallback(args);
    }, 0);
  };
  var check = function(n) {
    try {
      if (!ng12Hybrid && window.getAllAngularTestabilities) {
        callback({ver: 2});
      } else if (window.angular && window.angular.resumeBootstrap) {
        callback({ver: 1});
      } else if (n < 1) {
        if (window.angular) {
          callback({message: 'angular never provided resumeBootstrap'});
        } else {
          callback({message: 'retries looking for angular exceeded'});
        }
      } else {
        window.setTimeout(function() {check(n - 1);}, 1000);
      }
    } catch (e) {
      callback({message: e});
    }
  };
  check(attempts);
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10, false]]
21:33:41.288 INFO - Executing: [execute script: return (function (trackOutstandingTimeouts) {
  var ngMod = angular.module('protractorBaseModule_', []).config([
    '$compileProvider',
    function($compileProvider) {
      if ($compileProvider.debugInfoEnabled) {
        $compileProvider.debugInfoEnabled(true);
      }
    }
  ]);
  if (trackOutstandingTimeouts) {
    ngMod.config([
      '$provide',
      function ($provide) {
        $provide.decorator('$timeout', [
          '$delegate',
          function ($delegate) {
            var $timeout = $delegate;

            var taskId = 0;

            if (!window['NG_PENDING_TIMEOUTS']) {
              window['NG_PENDING_TIMEOUTS'] = {};
            }

            var extendedTimeout= function() {
              var args = Array.prototype.slice.call(arguments);
              if (typeof(args[0]) !== 'function') {
                return $timeout.apply(null, args);
              }

              taskId++;
              var fn = args[0];
              window['NG_PENDING_TIMEOUTS'][taskId] =
                  fn.toString();
              var wrappedFn = (function(taskId_) {
                return function() {
                  delete window['NG_PENDING_TIMEOUTS'][taskId_];
                  return fn.apply(null, arguments);
                };
              })(taskId);
              args[0] = wrappedFn;

              var promise = $timeout.apply(null, args);
              promise.ptorTaskId_ = taskId;
              return promise;
            };

            extendedTimeout.cancel = function() {
              var taskId_ = arguments[0] && arguments[0].ptorTaskId_;
              if (taskId_) {
                delete window['NG_PENDING_TIMEOUTS'][taskId_];
              }
              return $timeout.cancel.apply($timeout, arguments);
            };

            return extendedTimeout;
          }
        ]);
      }
    ]);
  }
}).apply(null, arguments);, [true]])
21:33:41.312 INFO - Done: [execute script: return (function (trackOutstandingTimeouts) {
  var ngMod = angular.module('protractorBaseModule_', []).config([
    '$compileProvider',
    function($compileProvider) {
      if ($compileProvider.debugInfoEnabled) {
        $compileProvider.debugInfoEnabled(true);
      }
    }
  ]);
  if (trackOutstandingTimeouts) {
    ngMod.config([
      '$provide',
      function ($provide) {
        $provide.decorator('$timeout', [
          '$delegate',
          function ($delegate) {
            var $timeout = $delegate;

            var taskId = 0;

            if (!window['NG_PENDING_TIMEOUTS']) {
              window['NG_PENDING_TIMEOUTS'] = {};
            }

            var extendedTimeout= function() {
              var args = Array.prototype.slice.call(arguments);
              if (typeof(args[0]) !== 'function') {
                return $timeout.apply(null, args);
              }

              taskId++;
              var fn = args[0];
              window['NG_PENDING_TIMEOUTS'][taskId] =
                  fn.toString();
              var wrappedFn = (function(taskId_) {
                return function() {
                  delete window['NG_PENDING_TIMEOUTS'][taskId_];
                  return fn.apply(null, arguments);
                };
              })(taskId);
              args[0] = wrappedFn;

              var promise = $timeout.apply(null, args);
              promise.ptorTaskId_ = taskId;
              return promise;
            };

            extendedTimeout.cancel = function() {
              var taskId_ = arguments[0] && arguments[0].ptorTaskId_;
              if (taskId_) {
                delete window['NG_PENDING_TIMEOUTS'][taskId_];
              }
              return $timeout.cancel.apply($timeout, arguments);
            };

            return extendedTimeout;
          }
        ]);
      }
    ]);
  }
}).apply(null, arguments);, [true]]

就像我说的,这些在本地运行得很好,所以我不确定我的Jenkins机器是怎么回事。

这是我的量角器配置文件:

// Configuration constants
var downloadsFolder = 'test/downloads/',
    today = ("0" + (new Date()).getDate()).slice(-2),
    month = ("0" + ((new Date()).getMonth() + 1)).slice(-2),
    baseUrl = 'BASE URL GOES HERE';

// Test report setup w/ screenshot
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
  dest: 'test/report',
  filename: 'e2e-report.html'
});

// Protractor config
exports.config = {
    suites: {
        explore: '.protractor/src/app/exploration/tests/exploration.scenario.js',
        login: '.protractor/src/auth-app/login/tests/login.scenario.js',
        stories: '.protractor/src/app/story/tests/story.scenario.js',
        cohorts: '.protractor/src/app/cohort/tests/cohort.scenario.js',
        visualize: '.protractor/src/app/visualize/tests/visualize.scenario.js'
    },
    baseUrl: 'BASE URL GOES HERE',
    directConnect: false,
    // Override default 11s timeout for long requests such as visualize's "Recommended Visualizations"
    // See https://github.com/angular/protractor/blob/master/docs/timeouts.md
    allScriptsTimeout: 25 * 1000,
    jasmineNodeOpts: {
        defaultTimeoutInterval: 90 * 1000
    },
    multiCapabilities: [
        {
            browserName: 'chrome',
            seleniumAddress: "http://SELENIUM SERVER URL HERE:4444/wd/hub",
            platform: 'ANY',
            version: 'ANY',
            chromeOptions: {
                args: ['--no-sandbox', '--test-type=browser', '--lang=en', '--start-maximized'],
                prefs: {
                    download: {
                        prompt_for_download: false,
                        directory_upgrade: true,
                        default_directory: 'test/downloads'
                    },
                },
            }
            // shardTestFiles: true,
            // maxInstances: 2
        }
    ],
    onPrepare: function() {
        // Set browser window size
        browser.driver.manage().window().maximize();

        //Setup screenshots
        jasmine.getEnv().addReporter(reporter);
        browser.get('BASE URL GOES HERE');
    },
    // Setup the report before any tests start
    beforeLaunch: function() {
        return new Promise(function(resolve){
            reporter.beforeLaunch(resolve);
        });
    },
    // Close the report after all tests finish
    afterLaunch: function(exitCode) {
        return new Promise(function(resolve){
            reporter.afterLaunch(resolve.bind(this, exitCode));
        });
    },
    params: {
        baseUrl: baseUrl,
        downloadsFolder: 'test/downloads',
        cohort: {
            listView: baseUrl + 'cohorts',
            newView: baseUrl + 'cohorts/new'
        },
        story: {
            listView: baseUrl + 'stories',
            newView: baseUrl + 'story/new',
            displayView: baseUrl + 'story'
        },
        visualize: {
            listView: baseUrl + 'visualize',
            newView: baseUrl + 'visualize/new'
        },
        explore: {
            listView: baseUrl + 'explorations',
            newView: baseUrl + 'explorations/new',
            excelFilename: downloadsFolder + `DataExport_2016-${month}-${today}.xlsx`,
            csvFilename: downloadsFolder + `DataExport_2016-${month}-${today}.csv`,
            maxDownloadTime: 10 * 1000
        }
    }
};

1 个答案:

答案 0 :(得分:0)

这归结为权限问题。一旦我将我的jenkins用户添加到sudo,我就可以在项目上执行make命令,该命令构建了所有必需的文件,并且还将我的打字稿测试转换为Javascript并允许它们运行。