I'm using Jasmine in my end-2-end tests written with protractor. I'm trying to create page object abstraction to be used as base class for other page objects defined in my solution.
As my application is classic form based solution, so I can gather common behaviors for edit pages into base class. To be more closer to M** pattern - I want to connect my abstract view with concrete model.
So my base page object view looks like:
export class EditPageBase<T> {
constructor(T model) {
this.model = model;
}
fillForm() {
...
}
checkForm() {
...
}
}
where T - class model related to this view.
This approach allow me use model structure and map directly to my view. So any property defined in model has correspondent representation in my view.
So I can use next syntax to map my model to view:
for(let prop in this.model) {
let ctrl = this.getControl(prop);
ctrl.sendKeys(this.model[prop]);
}
So is not important how complex my form is - I need only define my model correct.
The problem I experiencing with checking data of the form as protractor returns promises when requesting page data:
for(let prop in this.model) {
let ctrl = this.getControl(prop);
expect(ctrl.getAttribute('value')).toEqual(this.model[prop] || '');
}
This code time to time throws:
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
I has idea why this happens - because my loop can ends earlier that promise will resolve. I don't know how to deal with this situation. I don't want to create promises chain or other Promise.all wrappers as Jasmine works good with promises so want to leave code clean here.
Maybe someone had this problems before and can share some ideas how to use Jasmine power here not switching to promise hell.
Aucun commentaire:
Enregistrer un commentaire