vendredi 1 mars 2019

Sharing assertions inside page object methods

I'm trying to create a method within a page object that performs a specific test which I'll end up using often. I've followed the documentation example but that's for typing/click, and maybe can't work with expect?

AssertionError: expected undefined to be truthy

That error specifically points to this line inside my test:

await t.expect(await page.nameTextInput.isRequired()).ok()

It's calling the isRequired check inside a "TextInputFeature" I've used inside my page object model:

export default class TextInputFeature {
    constructor(model) {
        this.input = AngularJSSelector.byModel(model);
        this.label = this.input.parent().prevSibling('label');
        this.asterisk = this.label.find('.required');
    }

    async isRequired() {
        await t
            .expect(this.input.hasAttribute('required')).ok()
            .expect(this.asterisk.exists).ok();
    }
}

Aucun commentaire:

Enregistrer un commentaire