Nightwatch: how to iterate through elements and click on them

Created on 18 Mar 2016  路  1Comment  路  Source: nightwatchjs/nightwatch

I want to be able to iterate through elements of a particular class and click on them. I tried the following code but it doesn't always click on the element specified

    browser.elements('css selector', element.articleItemTitle,function (links) {
        for (var i=0; i < links.value.length; i++) {
            browser.waitForElementVisible('body');
            browser.pause(1000);
            browser.elementIdClick(links.value[i].ELEMENT);
            browser.waitForElementVisible('.article-detail');
            browser.expect.element(element.postHeroTitle).to.be.present;
            browser.back();
        }
    });

I get the following error:

stale element reference: element is not attached to the page document

>All comments

Please use the mailing list to ask for assistance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaseconey picture chaseconey  路  4Comments

manjero picture manjero  路  4Comments

maxgalbu picture maxgalbu  路  3Comments

aking1012 picture aking1012  路  4Comments

danielbentov picture danielbentov  路  4Comments