导航到localhost:8000 on travis进行量角器e2e测试时出现错误的网关错误

时间:2015-04-08 17:18:40

标签: protractor travis-ci saucelabs

我正在尝试为我的网络应用程序设置Travis的持续集成。我想进行单元测试&使用酱实验室在不同的浏览器中进行端到端测试。我最近几天已经倾倒了文档,并且仍然坚持让e2e和单元测试在travis服务器上执行(顺序,不是并行)。

.travis.yml

addons:
  sauce_connect: true

branches:
  only:
  - master
  - passing_test_branch

sudo: required

services:
- redis-server

language: node_js
node_js:
- 0.10.36

before_install:
- export PIP_USE_MIRRORS=true

install:
- npm install
- sudo -H pip install -r requirements.txt
- bower install

script:
- grunt karma:sauceTravis
- grunt protractor:sauceLabs
- coverage run --source='.' manage.py test

after_success:
- grunt coveralls:run
- coveralls --merge=coverage/lcov/coveralls.json

量角器-sauce.conf.js

// conf.js

exports.config = {

  // seleniumAddress: 'http://localhost:4443/wd/hub',

  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,

  multiCapabilities: [
      {
        'name': 'Protractor Tests - Travis',
        'browserName': 'firefox',
        'version': '35',
        'platform': 'Windows 7',
        'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
        'build': process.env.TRAVIS_BUILD_NUMBER,
      }, 
      {
        'name': 'Protractor Tests - Travis',
        'browserName': 'chrome',
        'version': '41',
        'platform': 'Windows 7',
        'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
        'build': process.env.TRAVIS_BUILD_NUMBER,
      }, 
      {
        'name': 'Protractor Tests - Travis',
        'browserName': 'internet explorer',
        'version': '11',
        'platform': 'Windows 7',
        'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
        'build': process.env.TRAVIS_BUILD_NUMBER,
      },
      {
        'name': 'Protractor Tests - Travis',
        'browserName': 'internet explorer',
        'version': '10',
        'platform': 'Windows 7',
        'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
        'build': process.env.TRAVIS_BUILD_NUMBER,
      },
      {
        'name': 'Protractor Tests - Travis',
        'browserName': 'chrome',
        'version': '40',
        'platform': 'Windows 7',
        'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
        'build': process.env.TRAVIS_BUILD_NUMBER,
      }, 
  ],

  baseUrl: 'http://localhost:8000/',

  framework: 'jasmine',

  specs: ['./test/e2e/*.js'],

  jasmineNodeOpts: {

    showColors: true,

  },

  params: {

    TEST_PASS: process.env.TEST_PASS,

  }
};

gruntfile.js

module.exports = function(grunt) {

    var customLaunchers = {
        sl_chrome: {
            base: 'SauceLabs',
            browserName: 'chrome',
            platform: 'Windows 7',
        },
        sl_firefox: {
            base: 'SauceLabs',
            browserName: 'firefox',
            platform: 'Windows 7',
        },
        sl_ios_safari: {
            base: 'SauceLabs',
            browserName: 'safari',
            platform: 'OS X 10.9',
        },
        sl_ie_11: {
            base: 'SauceLabs',
            browserName: 'internet explorer',
            platform: 'Windows 7',
        }
    };

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        karma: {
            options: {
                configFile: 'karma.conf.js',
            },
            unit: {

            },
            test: {

                singleRun: true,
                browsers: ['PhantomJS'],

            },

            sauceLocal: {

                sauceLabs: {

                    testName: 'Karma Tests - LOCAL',
                    startConnect: true

                },

                customLaunchers: customLaunchers,
                browsers: Object.keys(customLaunchers),
                reporters: ['progress','coverage','saucelabs'],

                singleRun: true,
                recordScreenshots: false,
                autoWatch: false,

                browserNoActivityTimeout: 150000,

            },

            sauceTravis: {

                coverageReporter: {
                    dir: 'coverage',
                    reporters: [
                        { type: 'lcovonly', subdir: 'lcov' },
                    ]
                },

                sauceLabs: {
                    testName: 'Karma Tests - TRAVIS',

                    startConnect: false,
                    tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
                    build: 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' ; BUILD ID #' + process.env.TRAVIS_BUILD_ID,
                },

                customLaunchers: customLaunchers,
                browsers: Object.keys(customLaunchers),
                reporters: ['progress','coverage','saucelabs'],

                singleRun: true,
                recordScreenshots: false,
                autoWatch: false,

                browserNoActivityTimeout: 150000,
                keepAlive: false
            },

            lcov: {

                singleRun: true,

                browsers: ['PhantomJS'],

                coverageReporter: {
                    dir: 'coverage',
                    reporters: [
                        { type: 'lcovonly', subdir: 'lcov' },
                    ]
                },

            },
        },

        protractor: {
            options: {

                keepAlive: false,
                singleRun: true, 

            },
            test: {   // Grunt requires at least one target to run so you can simply put 'all: {}' here too.

                configFile: "protractor.conf.js", // Default config file

            },

            sauceLabs: {

                configFile: "protractor-sauce.conf.js",

            },
        },

        coveralls: {
            options: {

                coverageDir: 'coverage/lcov',
                dryRun: true,

            },
            run: {

            }
        }
    });

    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-karma-coveralls');
    grunt.loadNpmTasks('grunt-protractor-runner');
    grunt.registerTask('default', ['karma:unit']);
    grunt.registerTask('e2e', ['protractor:test']);
    grunt.registerTask('fullTest', ['karma:sauceTravis', 'protractor:sauceLabs']);
    grunt.registerTask('karmaSauce', ['karma:sauceLocal']);

};

你可以在我的travis.yml中看到我正在使用sauce_connect插件,它在构建我的travis服务器时启动一个酱连接实例。我的脚本涉及启动grunt任务" karma:sauceLabs",它通过酱油连接隧道执行正常(我可以看到酱汁中的结果),但是当我尝试在travis上运行量角器e2e测试时,我得到以下错误,当我检查sauceLabs时,我得到了一个" badgateway"我尝试连接到localhost:8000时出错。

The command "grunt karma:sauceTravis" exited with 0.
40.64s$ grunt protractor:sauceLabs
Running "protractor:sauceLabs" (protractor) task
[launcher] Running 5 instances of WebDriver
FFFFFFF
------------------------------------
[chrome 40 Windows 7 #5] PID: 4694
[chrome 40 Windows 7 #5] Specs: /home/travis/build//cv/test/e2e/login.spec.js
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5] Using SauceLabs selenium server at http://ondemand.saucelabs.com:80/wd/hub
[chrome 40 Windows 7 #5] FF
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5] Failures:
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5]   1) Login should not allow for login with an invalid username and password
[chrome 40 Windows 7 #5]    Message:
[chrome 40 Windows 7 #5]      NoSuchElementError: no such element
[chrome 40 Windows 7 #5]   (Session info: chrome=40.0.2214.93)
[chrome 40 Windows 7 #5]   (Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86_64)
[chrome 40 Windows 7 #5]    Stacktrace:
[chrome 40 Windows 7 #5]      NoSuchElementError: no such element
[chrome 40 Windows 7 #5]   (Session info: chrome=40.0.2214.93)
[chrome 40 Windows 7 #5]   (Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86_64)
[chrome 40 Windows 7 #5]     at Array.forEach (native)
[chrome 40 Windows 7 #5] From: Task: WebElement.sendKeys()
[chrome 40 Windows 7 #5]     at [object Object].<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:12:51)
[chrome 40 Windows 7 #5] From: Task: Asynchronous test function: it()
[chrome 40 Windows 7 #5] Error
[chrome 40 Windows 7 #5]     at [object Object].<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:8:5)
[chrome 40 Windows 7 #5]     at Object.<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:2:1)
[chrome 40 Windows 7 #5]     at require (module.js:380:17)
[chrome 40 Windows 7 #5]     at Function.promise (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:650:9)
[chrome 40 Windows 7 #5]     at _fulfilled (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:797:54)
[chrome 40 Windows 7 #5]     at self.promiseDispatch.done (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:826:30)
[chrome 40 Windows 7 #5]     at Promise.promise.promiseDispatch (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:759:13)
[chrome 40 Windows 7 #5]     at /home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:525:49
[chrome 40 Windows 7 #5]     at flush (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:108:17)
[chrome 40 Windows 7 #5]     at process._tickCallback (node.js:442:13)
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5]   2) Login should allow for login with a valid username and password
[chrome 40 Windows 7 #5]    Message:
[chrome 40 Windows 7 #5]      NoSuchElementError: no such element
[chrome 40 Windows 7 #5]   (Session info: chrome=40.0.2214.93)
[chrome 40 Windows 7 #5]   (Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86_64)
[chrome 40 Windows 7 #5]    Stacktrace:
[chrome 40 Windows 7 #5]      NoSuchElementError: no such element
[chrome 40 Windows 7 #5]   (Session info: chrome=40.0.2214.93)
[chrome 40 Windows 7 #5]   (Driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=Windows NT 6.1 SP1 x86_64)
[chrome 40 Windows 7 #5]     at Array.forEach (native)
[chrome 40 Windows 7 #5] From: Task: WebElement.sendKeys()
[chrome 40 Windows 7 #5]     at [object Object].<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:23:51)
[chrome 40 Windows 7 #5] From: Task: Asynchronous test function: it()
[chrome 40 Windows 7 #5] Error
[chrome 40 Windows 7 #5]     at [object Object].<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:19:5)
[chrome 40 Windows 7 #5]     at Object.<anonymous> (/home/travis/build//cv/test/e2e/login.spec.js:2:1)
[chrome 40 Windows 7 #5]     at require (module.js:380:17)
[chrome 40 Windows 7 #5]     at Function.promise (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:650:9)
[chrome 40 Windows 7 #5]     at _fulfilled (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:797:54)
[chrome 40 Windows 7 #5]     at self.promiseDispatch.done (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:826:30)
[chrome 40 Windows 7 #5]     at Promise.promise.promiseDispatch (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:759:13)
[chrome 40 Windows 7 #5]     at /home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:525:49
[chrome 40 Windows 7 #5]     at flush (/home/travis/build//cv/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/q/q.js:108:17)
[chrome 40 Windows 7 #5]     at process._tickCallback (node.js:442:13)
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5] Finished in 22.342 seconds
[chrome 40 Windows 7 #5] 2 tests, 2 assertions, 2 failures
[chrome 40 Windows 7 #5] 
[chrome 40 Windows 7 #5] SauceLabs results available at http://saucelabs.com/jobs/a94dc37936734d188eb2e60abf3f8d65

所以我想我的问题是酱汁隧道是适当打开的,我可以看到我的浏览器正在达到sauceLabs,但当我尝试导航到localhost:8000在saucelabs时,我得到一个&#34;坏网关&#34 ;错误而不是我的网站。有关我在配置中可以做什么的建议,以摆脱错误的网关错误

由于

0 个答案:

没有答案