简体   繁体   English

量角器指向Sauce Labs Selenium服务器

[英]Protractor pointing to Sauce Labs Selenium Server

I'm trying to integrate Protractor with Sauce Labs from Travis. 我正在尝试将量角器与Travis的Sauce Labs集成。 I can get the sauce_connect server running correctly but am unable to get Travis to point to that particular remote server. 我可以使sauce_connect服务器正确运行,但是无法使Travis指向该特定的远程服务器。

Travis will get to the point where it initiates sauce_connect but when I run "protractor:analytics" it doesn't point to the correct server and fails. Travis会到达启动sauce_connect的地步,但是当我运行“ protractor:analytics”时,它并没有指向正确的服务器,并且失败了。

Travis.yml: Travis.yml:

language: python
python:
- 3.2_with_system_site_packages
branches:
  only:
  - develop
before_install:
- sudo apt-get update -qq
- sudo apt-get install python-numpy
install:
- cd lib && python setup.py install
- cd .. && pip install -r requirements/travis_requirements.txt
- npm install
script:
- grunt karma:single
- grunt protractor:analytics
env:
  global:
  - secure: <string>
  - secure: <string>
sauce_connect: true

Gruntfile: Gruntfile:

protractor: {
  options: {
    configFile: './webapp/static/test/e2e/protractor.conf.js',
    keepAlive: true
  },
  singlerun: {},
  analytics: {
    options: {
      //debug : true,
      args:{
        specs: ['./webapp/static/test/e2e/analytics_spec.js']
      }
    }
  },
},

Protractor Conf: 量角器Conf:

exports.config = {
  chromeOnly: false,
  seleniumArgs: [],

  // If sauceUser and sauceKey are specified, seleniumServerJar will be ignored.
  // The tests will be run remotely using SauceLabs.
  sauceUser: process.env.SAUCE_USER,
  sauceKey: process.env.SAUCE_KEY,

  baseUrl: 'http://localhost:8000',
  specs: [
    './*_spec.js',
  ],

  // Patterns to exclude.
  exclude: [],

  multiCapabilities: [],

  // ----- More information for your tests ----
  //
  // A base URL for your application under test. Calls to protractor.get()
  // with relative paths will be prepended with this.
  baseUrl: process.env.SN_BASE_URL,

  // Selector for the element housing the angular app - this defaults to
  // body, but is necessary if ng-app is on a descendant of <body>
  rootElement: 'body',

  // A callback function called once protractor is ready and available, and
  // before the specs are executed
  // You can specify a file containing code to run by setting onPrepare to
  // the filename string.
  onPrepare: function() {
    // At this point, global 'protractor' object will be set up, and jasmine
    // will be available. For example, you can add a Jasmine reporter with:
    //     jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
    //         'outputdir/', true, true));
  },

  // The params object will be passed directly to the protractor instance,
  // and can be accessed from your test. It is an arbitrary object and can
  // contain anything you may need in your test.
  // This can be changed via the command line as:
  //   --params.login.user 'Joe'
  params: {
    login: {
      user: process.env.SN_TEST_USERNAME,
      password: process.env.SN_TEST_PASSWORD
    }
  },
  framework: 'jasmine',

  // ----- Options to be passed to minijasminenode -----
  //
  // See the full list at https://github.com/juliemr/minijasminenode
  jasmineNodeOpts: {
    // onComplete will be called just before the driver quits.
    onComplete: null,
    // If true, display spec names.
    isVerbose: false,
    // If true, print colors to the terminal.
    showColors: true,
    // If true, include stack traces in failures.
    includeStackTrace: true,
    // Default time to wait in ms before a test fails.
    defaultTimeoutInterval: 30000
  },

  onCleanUp: function() {}
};

If I did understand well : Sauce connect tool is not used by protractor/selenium when running a test suite. 如果我确实理解得很好:在运行测试套件时,量角器/硒不使用酱连接工具。

Well I had this problem, travis requires sauce credentials and protractor requires those credentials and a tunnel id : 好吧,我遇到了这个问题,特拉维斯需要调味酱凭证,量角器需要这些凭证和通道ID

.travis.yml: .travis.yml:

addons:
  sauce_connect:
    username: xxx
    access_key: xxx

protractor.conf.js: protractor.conf.js:

exports.config = {
  ...
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  capabilities: {
    ...
    'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM