gpt4 book ai didi

protractor - Protractor :如何单击页面对象中的所有删除按钮

转载 作者:行者123 更新时间:2023-12-04 13:50:00 29 4
gpt4 key购买 nike

我有一个表,其中包含3行数据和3个删除按钮。我想删除所有数据行,因此想在我的页面对象中编写一个方法来做到这一点……这应该很简单,但我无法使其正常工作。我正在这样尝试:

this.rows = element.all(by.repeater('row in rows'));

this.deleteAllFriends = function() {
this.rows.each(function(row) {
row.$('i.icon-trash').click();
})
};

但这会引发错误:
Error: Index out of bound. Trying to access index:2, but locator: by.repeater("row in rows") only has 1 elements

显然,索引 Protractor 期望下一个不再存在,因为它已被删除。 我该如何解决?

这也不起作用,并引发相同的错误:
this.deleteButtons = $$('i.icon-trash');

this.deleteAllFriends = function() {
this.deleteButtons.each(function(button) {
button.click();
});
};

这也行不通...
this.deleteAllFriends = function() {
while(this.deleteButton.isDisplayed()) {
this.deleteButton.click();
}
};

最佳答案

使用今天的version >= 1.3.0 of Protractor,您现在可以do this at once

$$('i.icon-trash').click();

feat(protractor): allow advanced features for ElementArrayFinder

关于protractor - Protractor :如何单击页面对象中的所有删除按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25896061/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com