【问题标题】:Protractor by.repeater not finding anythingProtractor by.repeater 没有找到任何东西
【发布时间】:2015-07-14 03:30:23
【问题描述】:

如何使用量角器选择以下中继器?

<a ng-repeat="item in filteredItems = (items | filter:'abc')">{{item}}</a>

【问题讨论】:

    标签: javascript angularjs selenium selenium-webdriver protractor


    【解决方案1】:

    你应该使用by.exactRepeater()

    查看source code,您可以看到exactRepeater 会检查转发器中“track by”、“|”之前的部分并作为”。这意味着你不能使用:

    element.all(by.exactRepeater("item in filteredItems"));
    

    但必须使用以下内容:

    element.all(by.exactRepeater("item in filteredItems = (items"));
    

    我同意,这看起来不是特别可读。在这里创建了一个问题:

    更新:问题现在已在后备箱中修复(非常快,感谢@sjelin)。


    而且,或者,您总是可以以通常的 selenium-ish 方式找到它:

    element.all(by.css('a[ng-repeat^="item in filteredItems"]'));
    element.all(by.xpath('//a[starts-with(@ng-repeat, "item in filteredItems")]'));
    

    【讨论】:

    • 很好的答案。我也正要挖掘源代码,量角器太浪费时间了……呃。
    • @Unidan 是的,对编辑感到抱歉,起初混合了定位器。哪个选项最终奏效了?谢谢。
    • 您的第二个示例 (by.exactRepeater("item in filteredItems = (items")))。我根据您的建议进行了编辑,并在您每次编辑时都重新运行,直到它起作用了哈哈:)。只要允许我就接受作为答案。
    • @Unidan FYI,更新了一个链接的量角器问题,如果有兴趣,请关注它。谢谢!
    • @alexce 看到了,不错!
    猜你喜欢
    • 2021-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多