量角器适用于localhost,但在CircleCi中失败

时间:2017-07-17 08:00:35

标签: protractor circleci

我对如何在circleCi中使用量角器有一个小问题。这个代码在我的localhost中工作正常,如果我在firefox中运行它。还有一个很小的猜测(不是100%肯定)但是当我使用返回promice如getCurrentUrl的方法时,circleCi上的chrome也会失败。这是我收到的错误:

circleCi error message

我的配置是:

  • 节点版本:6.9.1
  • 量角器版本:5.1
  • Angular Version:4
  • 浏览器:chrome
  • 操作系统和版本ubuntu 16.4

**我的测试赌博**

import { browser, Config, element, by } from 'protractor';
import { assert } from 'chai';
describe('simple test', function() {

    beforeEach(function() {
        browser.ignoreSynchronization = true;
    });

    it('should login', function() {
        browser.get('http://localhost:8080/#/signin');
        const email = element(by.name('email'));
        const password = element(by.name('password'));
        const button = element(by.css('[type="submit"]'));
        email.sendKeys('qa-test@domain.fr');
        password.sendKeys('12345678');
        button.click();
        browser.sleep(1500);
        const logout = element(by.className('ll-navbar-icon fa fa-power-off'));
        expect(browser.getCurrentUrl()).toMatch('/dashboard');
        browser.isElementPresent(logout);
    });
});

我的量角器配置文件:

import { environment } from './environment';
import { browser, Config } from 'protractor';
import { SpecReporter } from 'jasmine-spec-reporter';

export let config: Config = {
  directConnect: true,
  allScriptsTimeout: 11000,
  seleniumAddress: 'http://localhost:4444/wd/hub',
  baseUrl: environment.baseUrl,
  capabilities: environment.capabilities,
  framework: environment.framework,
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },

  specs: [
    '../../build/app.spec.js'
  ],
  // This utility function helps prepare our scripts with required actions like browser maximize
  onPrepare: () => {
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    browser.driver.manage().window().maximize();
  }
};

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,测试在本地运行没有问题,但是当在circleci中运行时它失败了。

我能够通过在测试中增加茉莉花DEFAULT_TIMEOUT_INTERVAL来修复它:

beforeEach(function() { jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999; });

还要确保使用circleci提供的“通过SSH调试”功能。调试你的设置非常方便。

相关问题