【发布时间】:2017-06-12 22:57:05
【问题描述】:
我知道这个问题已经被问过好几次了,尽管我已经查看了这些问题,但我不确定如何解决这个问题。
我正在检查文本“EUR”是否包含在名为“currency”的 div 中。这以前对我有用,但我已经开始使用 lint 并且遇到了很多此类错误。
这是我遇到的错误
Failed: text.indexOf(...).isDisplayed is not a function
这是我的代码
checkBuyerCurrency (text, buyerCurrency) {
let currencyPromise = new Promise(function (resolve, reject) {
const commonUtils = new CommonUtils();
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.className("currency")), 4000));
var checkCurrency = element(by.className("balances"));
checkCurrency.getText().then(function (text) {
expect (text.indexOf("EUR").isDisplayed()).toBe(true);
console.log("EUR only buyer");
});
});
}
我需要将text 设为变量还是将其转换为字符串?由于我使用Expect 语句的方式,我不完全确定如何执行此操作
感谢您的帮助
【问题讨论】:
-
indexOf() 将返回一个数字或 -1 如果不存在... .isDisplayed() 不是数字的函数。这可能有效——expect(text.indexOf("EUR")).not.toBe(-1)
-
感谢一百万的回复。如果我想将期望更改为 if,那么它将类似于...如果包含“EUR”//然后做某事//,知道我将如何实现它吗?
标签: node.js protractor aurelia angularjs-e2e e2e-testing