如何解决这个问题?这部分测试将不基于 Angular。
function Menu(container) {
this.container = container;
this.elements = this.getItems();
}
Menu.prototype.getItems = function() {
var arr = this.container.$('> li');
...
};
谢谢大家!
最佳答案
您可以使用:scope
实验性 CSS 选择器(不适用于 IE):
The :scope CSS pseudo-class matches the elements that are a reference point for selectors to match against.
this.container.$(":scope > li");
或者,您可以使用 by.xpath()
locator :
this.container.element(by.xpath("./li"));
关于javascript - 我可以在 Protractor 中使用 '>' css 选择器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31571029/