【问题标题】:Protractor: Checking to see if a link contains certain text. Expected [ true, true ] to be [ true, true ]量角器:检查链接是否包含某些文本。预期 [ true, true ] 为 [ true, true ]
【发布时间】:2017-06-14 14:50:11
【问题描述】:

我正在测试,如果用户在页面顶部显示的货币为“EUR”和另一种货币“GBP”,那么我期待一个包含文本“EUR”的链接和另一个包含文本“GBP”的链接位于页面下方。这包含在一个名为 "nav-tabs au-target" 的 div 中 当我运行我的脚本时,我收到以下错误: Expected [ true, true ] to be [ true, true ]

这是我的页面对象文件:

if(text.indexOf("EUR") >-1 && text.indexOf("GBP") >-1){
expect(element.all(by.linkText("EUR"&&"GBP")).isDisplayed())
.toBe([true, true]);
console.log("EUR AND GBP buyer");}

我尝试查看 "nav-tabs au-target" 是否包含链接文本“EUR”和“GBP”而不是 element.all,但努力让它工作 谢谢

【问题讨论】:

    标签: node.js jasmine protractor aurelia e2e-testing


    【解决方案1】:

    这可能不是 Protactor 或您的应用程序的问题,而是 Jasmine 的 API 使用不正确。

    特别是:

    expect(actualValue).toBe(expectedValue)
    

    将做以下检查:

    actualValue === expectedValue
    

    这不适用于对象或数组。

    对于对象或数组,您应该使用toEqual 而不是toBe,这将在两个值之间进行深度比较。

    您可以在以下fiddle 中看到这一点。

    【讨论】:

    • 不客气!如果答案有帮助,请考虑将其标记为正确,这样它就不会出现在“未回答”部分。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-19
    • 2023-03-29
    • 2020-12-10
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2014-07-27
    相关资源
    最近更新 更多