量角器:如何在element.all(locator).each(eachFunction)

时间:2018-08-14 19:25:09

标签: angularjs selenium-webdriver protractor

期望: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)
            });
        })
});

1 个答案:

答案 0 :(得分:0)

看起来像这样的花招

    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)
            }
相关问题