Netflix Login script What are my options on how the loginToNetflix method is called? Is there a more clean and elegant way of accomplishing this?

loginToNetflix(credentials.username, credentials.password);

function loginToNetflix (username, password) {
casper.start('https://www.netflix.com/Login?locale=en-US', function() {
    this.echo('Attempting login to Netflix - filling and submitting login form');

    this.fill('form#login-form', {
            'email':    username,
         'password':    password,
       'RememberMe':    true
    }, true);
});

casper.then(function() {
    this.echo('Login Complete - Please check the cookie as defined in command line');
    //save the cookie for use by netflix scraper api
    var cookies = JSON.stringify(phantom.cookies);
    fs.write("netflix-cookies.txt", cookies, 644);
});

casper.run(function () {
    this.echo('Done - Exiting!');
    casper.exit();
});
}
Looks alright to me. A small personal nuisance for me,  but a possible improvement would be to pass the credentials in an object

var credentials = {
    username: "xxx",
    password: "yyy"
};


That would make the signature of your function smaller, and after all, the 2 variables are tightly coupled, semantically speaking.

But as I say, peccata minuta. Looks good to me.