Using browser module to submit form in node.js

I used the browser module (https://github.com/shinout/browser) to test form submission in node.js and it was successful by running the following code:

var $b = new browser();
$b.submit({
  from : 'https://accounts.google.com/Login',
  selector: "#gaia_loginform",
  data : {
    Email  : "XXXXXX@gmail.com",
    Passwd : "XXXXXXXX"
  }
});

// authenticated access
$b.browse('https://mail.google.com/mail/u/0/?ui=html&zy=d')
.after(); // browse after previously registered function

$b.on("end", function(err, out) {
  console.log(out.url, out.result, out.responseHeaders);
});

$b.run();

But when I add additional code after $b.run()

$b.browse('https://mail.google.com').after();
$b.run();

I got the following error:

Junjo.register cannot be called when the template is frozen.

I don't know why. Any help would be appreciated.

From what I was able to read from sources, the browser module does not support running multiple jobs with single browser instance. Method $b.run() marks the object as frozen, which causes methods like browse to throw the error you are getting.