I came across concept of Page Objects, and used it in writing tests in Protractor, but I am facing an issue. The old code was as follows.
var productList = element.all(by.repeater('product in contractsCtrl.contracts'));
productList.get(0).element(by.model('qty')).sendKeys(20);
I organized the code in a class, like
var Product = {
productList : element.all(by.repeater('product in contractsCtrl.contracts')),
qtyElem : element(by.model('qty')),
setProduct : function (pos) {
this.productElem = this.productList.get(pos);
}
}
Now to implement the scenario (as in code snippet 1) with Page Objects, I modified code as,
var Product = require('product.js');
Product.setProduct(0);
I am stuck here on how to access the qtyElem
within productElem
.