2017-07-17 99 views
0

我有一个关于如何在circleCi中使用量角器的小问题。此代码在我的本地主机中正常工作,并且如果我在Firefox中运行它。也有一个小猜测(不是100%肯定),但是当我使用getCurrentUrl等返回承诺的方法时,circleCi上的chrome也失败。这是在出现故障i接收:量角器在localhost上工作,但在CircleCi中失败

circleCi error message

我的配置是:

  • 节点版本:6.9.1
  • 量角器版本:5.1
  • 角版本:4
  • 浏览器:chrome
  • Operating Syste m和版本的Ubuntu 16.4

**我的测试samble **

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('[email protected]'); 
     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(); 
    } 
}; 

回答

0

我也有类似的问题,测试,但没有任何当地出现问题,但在circleci跑步时失败。

我能够在我的测试增加了茉莉DEFAULT_TIMEOUT_INTERVAL解决它:

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

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

相关问题