Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 量角器测试失败,因为模型值为空_Angularjs_Selenium_Selenium Webdriver_Integration Testing_Protractor - Fatal编程技术网

Angularjs 量角器测试失败,因为模型值为空

Angularjs 量角器测试失败,因为模型值为空,angularjs,selenium,selenium-webdriver,integration-testing,protractor,Angularjs,Selenium,Selenium Webdriver,Integration Testing,Protractor,我有一个样本,我正试图测试使用量角器 下面是我的测试 describe("Fiddle homepage", function() { beforeEach(function() { browser.get('http://fiddle.jshell.net/yfUQ8/9/show'); browser.rootEl = 'div'; }); describe("binding", function() { var i

我有一个样本,我正试图测试使用量角器

下面是我的测试

describe("Fiddle homepage", function() {


    beforeEach(function() {
        browser.get('http://fiddle.jshell.net/yfUQ8/9/show');
        browser.rootEl = 'div';
    });
    describe("binding", function() {
        var inputByModel;
        beforeEach(function() {
            inputByModel = element(by.model('model.yourName'));
        })
        // Fail
        it("should have value Julie1", function() {
            inputByModel.sendKeys('Julie1');
            // browser.waitForAngular();
            expect(inputByModel.getText()).to.eventually.equal('Julie1');

        });
        // Fail
        it("should have value Julie2", function() {
            inputByModel.sendKeys('Julie2');

            var greeting = element(by.model('model.yourName'));
            expect(greeting.getText()).to.eventually.equal('Julie2');
        });
        // Pass
        it("should have value Julie3", function() {
            inputByModel.sendKeys('Julie3');
            var byBinding = element(by.binding('model.yourName'));
            expect(byBinding.getText()).to.eventually.equal('Julie');
        });
        // Fail
        it("should get value by id and should pass the test", function() {
            inputByModel.sendKeys('Julie4');

            var byID = element(by.id('myinput'));
            expect(byID.getText()).to.eventually.equal('Julie4');
        })
    });
});

我用的是摩卡咖啡,Chaias答应会帮我做测试。有人能解释我的前两个测试失败的原因吗?

要获取输入元素的文本,必须使用:

getAttribute('value')
而不是

getText()

量角器常见问题解答中记录了这一点:

Hmm确实有效!想知道为什么它是FAQ的一部分而在示例中没有提到,或者至少我找不到。无论如何谢谢你!