当我开始我的测试时,浏览器打开并显示一个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
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我的配置文件是
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,我的测试文件是
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“
发布于 2015-10-30 12:09:53
您没有很好地处理项目中的异步代码。header.getText()返回一个promise,您需要在断言文本之前解析该promise。你可以这样做:
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();
});
});
});https://stackoverflow.com/questions/33428438
复制相似问题