在量角器中检索子元素的数组
I'm trying to count/retrieve a specific DOM element from an array in Protractor. openMenu
is a valid DOM element.
我正在尝试从Protractor中的数组中计算/检索特定的DOM元素。 openMenu是一个有效的DOM元素。
var openSelectbox = $('body > .ui-select-container');
var openMenu = openSelectbox.$('.ui-select-choices');
var choices = openMenu.all(by.css('.ui-select-choices-row'));
According to the docs I should now be able to call choices.count()
for an int count of elements matched. Instead, it returns an object with callback/closure keys. Not a promise, either.
根据文档,我现在应该能够将choices.count()调用为匹配的元素的int计数。相反,它返回一个带回调/闭包键的对象。也不是承诺。
choices
should match three DOM elements. In the end, I need to use something like choices.get(1).click();
.
选择应匹配三个DOM元素。最后,我需要使用像choices.get(1).click();这样的东西。
1 个解决方案
#1
I think you have to select your stuff differently:
我认为你必须以不同的方式选择你的东西:
var openSelectbox = element(by.css('body > .ui-select-container'));
var openMenu = openSelectbox.element(by.css('.ui-select-choices'));
var choices = openMenu.all(by.css('.ui-select-choices'));
I got this stuff from here: https://github.com/angular/protractor/blob/master/docs/locators.md#user-content-finding-sub-elements
我从这里得到了这些东西:https://github.com/angular/protractor/blob/master/docs/locators.md#user-content-finding-sub-elements
更多相关文章
- 停止鼠标用javascript双击某些元素
- 从Python中的列表元素中删除URL
- python selenium-webdriver 定位frame中的元素 (十三)
- Django模型选择:使用元组的第一个元素
- python 按位置关系输出矩阵元素
- 使用python如何在列表列表中找到元素,而关键元素是内部列表的元素
- 对numpy数组的每n个元素求平均值
- 008 Python基本语法元素小结
- Python根据第一项从2d数组中删除元素