mercredi 17 juin 2020

How can I check the button which clicked is disabled with using protractor?

I want to check the button is disabled after the button clicking, but disabled attribute is dynamic and I can't get the last state of the attribute:

Protractor:

const saveButton = element(by.id('saveButton'));

saveButton.click();
browser.sleep(1000);
await saveButton.isEnabled().then(enabled => {
    expect(enabled).to.be.false;
});

HTML:

<button id="saveButton" [disabled]="isDisabled" mat-button (click)="saveArticle()">
    Save
</button>

Angular:

this.isDisabled = false;

saveArticle() {
    this.isDisabled = true;

    this.http.get('http://url').subscribe((response) => {
        this.isDisabled = false;
    });
}

Disabled attribute changes dynamically like above and this is not working properly. isEnabled() method always return true. How can I verify the button is disabled after clicking?

Aucun commentaire:

Enregistrer un commentaire