如何使用量角器检查单击的按钮是否被禁用?

问题描述 投票:0回答:1

单击按钮后,我想检查按钮是否已禁用,但是禁用的属性是动态的,我无法获得该属性的最后状态:

量角器:

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>

角度:

this.isDisabled = false;

saveArticle() {
    this.isDisabled = true;

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

Disabled属性会像上面那样动态更改,因此无法正常工作。 isEnabled()方法始终返回true。单击后如何确认按钮已禁用?

angular testing protractor bdd chai
1个回答
0
投票

您正在使用茉莉花匹配器吗?如果是这样,这应该足够了:

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

await saveButton.click();
browser.sleep(1000);
expect(await saveButton.isEnabled()).toBe(false);
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.