网站搜索

selenium - 即使抛出错误时,Chai-As-Promised 测试仍然通过


public clickOnElementWithSelectionMethod(elementKey, selectionMethod, selectionValue) {

let elementToClick = this.getWebElement(elementKey, selectionMethod, selectionValue);

    return assert.eventually.equal(
      elementToClick.click().then(() => {
        return true;
      }, (error: any) => {
        throw new Error(error.message);
      }), true, 'Element "' + elementKey + '" click failed'
    );
}

我在这里将 Protractor 的 Click() API 调用作为 promise 传递。

即使我传递了错误的 selectionValue,它也显示测试通过,但下一个测试会失败。