Protractor clicking through an array of elements

前端 未结 3 1025
陌清茗
陌清茗 2021-01-20 01:13

I\'m quite new to e2e testing and in using protractor / jasmine framework. I know how to get an array of elements and also how to click on an anchor. But how would / is it e

3条回答
  •  -上瘾入骨i
    2021-01-20 01:54

    Managed to figure a workaround, although this doesn't feel quite right. Anyway, if anyone has better suggestion feel free to post :)

    element.all(by.repeater('link in links')).map(
        function(link, index) {
            return {
                index: index,
                href: link.getAttribute('href')
            };
        })
        .then(function(links) {
            for (var i = links.length - 1; i >= 0; i--) {
            browser.get(links[i].href);
            // do some page specific stuff here.
        };
    });
    

提交回复
热议问题