【问题标题】:Click on a element with same class that matches text and exit in Protractor单击与文本匹配的具有相同类的元素并在量角器中退出
【发布时间】:2015-05-14 07:16:52
【问题描述】:

我可以通过在量角器中使用element.all(by.repeater()) 并使用每个来检查匹配的文本来查找文本。现在,一旦匹配完成并单击匹配的元素,问题就会退出。

我尝试使用.each(),但无法退出迭代。

有什么建议吗?

【问题讨论】:

    标签: javascript testing selenium protractor end-to-end


    【解决方案1】:

    在这种情况下,each() 不是一个好的选择。 听起来真的很像filtering,例如:

    element.all(by.repeater("test in tests")).filter(function (elm) {
        return elm.getText().then(function (text) {
            return text === "Desired text";
        });
    }).then(function(filteredElements) {
        filteredElements[0].click();
    });
    

    【讨论】:

    • 它在 chrome 中运行良好,但是当我在 safari 中使用它时它不起作用?有没有办法做同样的事情,它能够检索filteredElements,但是filteredElements[0].click();无法在 safari 中点击
    • @SPatchamatla 我记得在使用 safari 驱动程序时出现了多个问题。请定义“不工作”。谢谢。
    • 我现在可以让它在 chrome 中工作,即使父标签没有 ng-click,chrome 也可以点击元素。但是在 safari 中,我需要确保它指向具有 ng-click 的子节点,然后只有 safari 才能点击 webElement。
    猜你喜欢
    • 1970-01-01
    • 2017-03-19
    • 2018-10-20
    • 2017-05-27
    • 2017-01-11
    • 2018-08-15
    • 2012-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多