量角器:如何在element.all(locator).each(eachFunction)中使用browser.sle



期望:要打印的 elem[0] 文本、睡眠、要打印的 elem[1] 文本、睡眠等...

实际:打印出每个元素的文本,然后在最后执行一次browser.sleep。

一旦我开始工作,我想实际单击每个链接并断言加载相应的配置文件页面。

我还应该提到我有SELENIUM_PROMISE_MANAGER:假的,正在使用摩卡

describe.only('clicking each user in the list', () => {
it('should display the correct profile page', async () => {
await element.all(by.repeater('user in currentNode.children')).each(async (elem)=> {
console.log(await elem.getText())
await browser.sleep(5000)
});
})
});

看起来这成功了

describe.only('clicking each user in the list', () => {
it('should display the correct profile page', async () => {
const elements = await element.all(by.repeater('user in currentNode.children'));
for (const element of elements) {
const text = await element.getText()
await browser.sleep(1000)
console.log(text)
}

最新更新