如何让我的量角器测试通过?

时间:2016-03-25 05:25:13

标签: angularjs protractor

我为我的角度应用程序创建了一个简单的量角器测试。当我单击一个按钮时,输入值被设置:

 $scope.fillForm=function(){
        console.log('fillform');
        $scope.myText='hoera';
    };

e2e测试期望输入填充'hoera':

describe('fill in form e2e test', function () {
    it('should test  form', function () {
        browser.get('http://localhost:63342/protractor_new/index.html');
        element(by.buttonText('go')).click().then(function () {
            var el = element(by.model('myText')).getText();
            expect(el).toEqual('hoera');
        });
    });
});

当我使用'量角器conf'进行测试时,我得到:

Expected '' to equal 'hoera'.

我希望有类似的东西:预期'hoera'等于'hoera'?如何让它通过可能在角度设置值之前有一个延迟?以下是代码的链接:https://github.com/dimitri-a/protractor_new

1 个答案:

答案 0 :(得分:1)

你很亲密。您的getclick应添加到controlFlow,因此点击时无需then。但是你的then需要getText。这应该有用......

describe('fill in form e2e test', function () {
    it('should test  form', function () {
        browser.get('http://localhost:63342/protractor_new/index.html');
        element(by.buttonText('go')).click();
        element(by.model('myText')).getText().then(function(el) {
            expect(el).toEqual('hoera');
        });
    });
});