How to visit one by one a set of subpages after login using horsemanjs?

41 Views Asked by At

I would like to login to application and then, as authorized user, be able to sequentially open a set of pages and do some actions on each (click and read data).

const subpages = ['sub1', 'sub2'];
const horseman = new Horseman();
horseman
    .open('https://website.com/')
    .click("button.loginButton:contains('Sign in')")
    .waitForSelector('input[name="username"]')
    .type('input[name="username"]', 'username')
    .type('input[name="password"]', 'password')
    .click("button:contains('Log in')")
    .wait(1000)

    //pseudo code
    subpages.forEach(function(subpage){ 
        horseman
        .open('https://website.com/' + subpage)
        .click("button:contains('Click Me')")
    });
0

There are 0 best solutions below