gpt4 book ai didi

javascript - 在 then [protractor] 的参数中查找元素

转载 作者:行者123 更新时间:2023-11-30 12:07:53 24 4
gpt4 key购买 nike

这是我的问题,

element.all(by.repeater('user in users')).then(function(rows) {
// would like to find an element in rows by.css for.exemple
}

编辑:

我准确地说我正在使用搜索元素

rows[rows.length - 1]

我已经试过了

rows[rows.length - 1].element(by.css('.fa.fa-trash-o')).click();

但是我得到了一个错误

element is not attached to the page document

感谢您的回答!

最佳答案

此错误通常发生在页面动态变化并且您试图访问某些尚未显示/加载的元素时。 wait()函数可用于等待元素加载后再访问它。方法如下 -

element.all(by.repeater('user in users')).then(function(rows) {
var ele = rows[rows.length - 1].element(by.css('.fa.fa-trash-o'));
browser.wait(protractor.ExpectedConditions.visibilityOf(ele), 10000);
ele.click();
}

希望对您有所帮助。

关于javascript - 在 then [protractor] 的参数中查找元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34650815/

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