【发布时间】:2017-06-13 21:20:13
【问题描述】:
我正在运行一个测试来检查 div 是否包含某些文本。如果它包含此文本,那么我想查看页面下方的链接是否包含相同的文本。 即用户将在页面标题处显示欧元和美元余额,然后页面下方将有一个选项卡包含一个名为“EUR”的链接,另一个选项卡包含一个带有文本“USD”的链接。
当我运行我的脚本时,我得到了错误:
Expected [ true, true ] to be true.
这是我的页面对象文件中的代码
browser.wait(EC.visibilityOf(element(by.className("currencies")), 4000));
var checkBalance = element(by.className("currencies"));
checkBalance.getText().then(function (text) {
if(text.indexOf("EUR") >-1 && text.indexOf("GBP") >-1){
//check if currencies div contains "EUR" and "GBP"
expect(element.all(by.linkText("EUR" && "GBP")).isDisplayed()).toBe(true);
//check if link with text "EUR" and link with "GBP" is displayed
}
【问题讨论】:
-
如果您有多个匹配的元素,请尝试使用
.toBeTruthy();? -
谢谢,我之前实际上使用过 .toBeTruthy() 并且不得不切换到 BeTrue() 并且在此期间忘记了它。这对我有帮助!
标签: node.js protractor aurelia e2e-testing