首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >selenium standalone终止,出现未知错误

selenium standalone终止,出现未知错误
EN

Stack Overflow用户
提问于 2015-10-30 12:00:49
回答 1查看 130关注 0票数 0

当我开始我的测试时,浏览器打开并显示一个ip,几秒后,ip被更改为“data”;在终端中,测试被循环并发送err ms

empresss-Mac-mini:myApp admin$ protractor test/e2e.js在http://localhost:4444/wd/hub启动器上使用selenium服务器运行1个WebDriver实例启动Jasmine规范超时。重置WebDriver控制流。F

代码语言:javascript
复制
Failures:
1) header Module should check title text
  Message:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Stack:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Message:
    Failed: header is not defined
  Stack:
    ReferenceError: header is not defined
        at Object.<anonymous> (/Users/admin/myApp/www/head.spec.js:8:13)
    From: Task: Run it("should check title text") in control flow
    From asynchronous test: 
    Error
        at Suite.<anonymous> (/Users/admin/myApp/www/head.spec.js:7:4)
        at Object.<anonymous> (/Users/admin/myApp/www/head.spec.js:1:63)

1 spec, 1 failure
Finished in 30.019 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1

我的配置文件是

代码语言:javascript
复制
exports.config = {
  framework: 'jasmine2',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['../www/head.spec.js'],
  multiCapabilities: [
  {
    browserName: 'chrome'
  }],
  onPrepare: function(){
        browser.driver.get('http://192.168.1.2:8100');
    }
}

我把它命名为e2e.js,我的测试文件是

代码语言:javascript
复制
describe('header Module', function(){

   beforeEach(function() {
        var header = element(by.css('title'));
    });

   it('should check title text',function(){
        expect(header.getText()).toContain('Ionic Blank Starter');    
    });
});

我下载了一个空白ionic应用程序,我想测试标题包含元素"Ionic blank Starter“

EN

回答 1

Stack Overflow用户

发布于 2015-10-30 12:09:53

您没有很好地处理项目中的异步代码。header.getText()返回一个promise,您需要在断言文本之前解析该promise。你可以这样做:

代码语言:javascript
复制
describe('header Module', function(){
it('should check title text',function(callback){
    var header = element(by.css('.title'));
    header.getText()
       .then(function (text) {
           expect(text).toContain('Ionic Blank Starter');
           callback();
       }); 
});
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33428438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档