我必须通过以下声明文本:
expect(accessPolicyPage.accessPolicyName).toEqual(element.all(by.binding("pol.name")).get(0).getText());
它给我一些如下所示的长错误。
Expected 'Access Policy Name 01' to equal ({ ptor_: ({ controlFlow: Function, schedule: Function, setFileDetector: Function, getSession: Function, getCapabilities: Function, quit: Function, actions: Function, touchActions: Function, executeScript: Function, executeAsyncScript: Function, call: Function, wait: Function, sleep: Function, getWindowHandle: Function, getAllWindowHandles: Function, getPageSource: Function, close: Function, getCurrentUrl: Function, getTitle: Function, findElementInternal_: Function, findElementsInternal_: Function, takeScreenshot: Function, manage: Function, switc
最佳答案
您在控制台上看到的是一个“可怕的”promise 对象表示。如果您需要一个真正的值,使用 then()
明确解决 promise :
element.all(by.binding("pol.name")).get(0).getText().then(function (text) {
expect(accessPolicyPage.accessPolicyName).toEqual(text);
});
或者,由于 accessPolicyPage.accessPolicyName
是预先定义的实际文本,您可以只交换匹配器中的内容,让 expect()
解析 promise 隐含地:
expect(element.all(by.binding("pol.name")).get(0).getText()).toEqual(accessPolicyPage.accessPolicyName);
此选项更简单,通常推荐使用。
关于javascript - toEqual 通过绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36302419/