【问题标题】:can i use '>' css selector in protractor?我可以在量角器中使用'>' css 选择器吗?
【发布时间】:2015-10-12 19:04:16
【问题描述】:

我该如何解决这个问题?这部分测试将不基于 Angular。

function Menu(container) {
    this.container = container;
    this.elements = this.getItems();
}

Menu.prototype.getItems = function() {
    var arr = this.container.$('> li');
    ...
};

谢谢大家!

【问题讨论】:

    标签: javascript selenium selenium-webdriver css-selectors protractor


    【解决方案1】:

    您可以使用:scope 实验性 CSS 选择器(不适用于 IE):

    :scope CSS 伪类匹配作为引用的元素 选择器要匹配的点。

    this.container.$(":scope > li");
    

    或者,您可以使用by.xpath() locator

    this.container.element(by.xpath("./li"));
    

    【讨论】:

    • :范围很棒!
    猜你喜欢
    • 1970-01-01
    • 2012-09-26
    • 2019-04-19
    • 2023-03-22
    • 2016-03-04
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多