Protractor 如何使用量角器转换页面对象中的下线

Protractor 如何使用量角器转换页面对象中的下线,protractor,Protractor,要转换到下面的行吗 rows.element(by.xpath(".//*[@ng-model='strategy.COMMENT']")).clear() 进入页面对象类似 rows.dataCatcherPage.strategyAUMValue.clear() 但是我得到了错误 “失败:无法读取未定义的属性'strategyAUMValue'” 这是页面对象 strategyAUMValue: { get: function () { return elemen

要转换到下面的行吗

rows.element(by.xpath(".//*[@ng-model='strategy.COMMENT']")).clear()
进入页面对象类似

rows.dataCatcherPage.strategyAUMValue.clear()
但是我得到了错误

“失败:无法读取未定义的属性'strategyAUMValue'”

这是页面对象

strategyAUMValue: {
    get: function () {
        return element(by.xpath(".//*[@ng-model='strategy.AUM_VALUE']"));
    }
},
这个怎么样:

页面

规格

这允许页面元素是私有的(分离框架层),但允许您完全访问测试将要执行的所有操作。您可以通过将任何其他元素添加到elements部分,然后添加到该元素测试所需的任何this.clear/getText/isDisplayed类型函数来扩展它

一些可扩展性:

module.exports = new function () {
    var elements : {
        strategyAUMValue : element(by.xpath(".//*[@ng-model='strategy.AUM_VALUE']")),
        // Get an element where multiple exist
        coolElement : $$('[name="coolElement"]')
    };

    this.clear = {
        strategyAUMValue : elements.strategyAUMValue.clear()
    };

    this.getText = {
        strategyAUMValue : elements.strategyAUMValue.getText(),
        coolElement : elements.coolElement.getText()
    };
};


其中有一个中继器..我正在迭代每一行。。。这是上面创建的页面对象…但我希望每行都有页面对象,而不是单独的。。。。。
var dataCacherPage = require('./dataCacher.page.js');

describe('Data cacher', function(){
    it('can clear the strategy aum value', function(){
        dataCacherPage.clear.strategyAUMValue();
        expect(dataCacherPage.clear.strategyAUMValue()).toEqual('', 'Strategy AUM Value should have been an empty string');
    });
});
module.exports = new function () {
    var elements : {
        strategyAUMValue : element(by.xpath(".//*[@ng-model='strategy.AUM_VALUE']")),
        // Get an element where multiple exist
        coolElement : $$('[name="coolElement"]')
    };

    this.clear = {
        strategyAUMValue : elements.strategyAUMValue.clear()
    };

    this.getText = {
        strategyAUMValue : elements.strategyAUMValue.getText(),
        coolElement : elements.coolElement.getText()
    };
};
var dataCacherPage = require('./dataCacher.page.js');

describe('Data cacher', function(){
    it('can hit multiple elements', function(){
        // Just add an index on coolElement to get whichever you want
        expect(dataCacherPage.clear.coolElement(2)).toEqual('This is the third cool element on the page', 'Should have gotten the text from the third cool element');
    });
});