Reputation: 10242
I got everything working with Ironworker and casperjs and I have one more step which fails: enabling cookie support in this setup.
I'm starting casper with the --cookies-file=cookies.txt
param and the cookies.txt file is chmoded with the right permissions but somehow there's no cookie support when I visit a test page and screenshot it.
Any idea how to enable this feature with IronWorker?
Upvotes: 0
Views: 191
Reputation: 399
Based on casperjs example but without phantomjs (it is already included in phantom-1.9 stack)
casper.worker:
runtime "binary"
stack "phantom-1.9"
exec "run.sh"
# Include the CasperJS library
dir "casperjs"
# Include the Javascript file that Casper will execute
file "simple.js"
run.sh:
casperjs/bin/casperjs --verbose --ignore-ssl-errors=yes --ssl-protocol=any --cookies-file=cookies.txt simple.js
simple.js:
var casper = require('casper').create();
casper.userAgent('Mozilla/5.0 (X11; Linux i586; rv:31.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36')
casper.start('https://hud.iron.io/', function() {
this.fill('form[action="/sessions"]', { email: '[email protected]', password: 'super_hard_pass' }, true);
this.click('input[name="commit"]');
this.echo(this.getTitle());
});
casper.wait('10000');
casper.thenOpen('https://hud.iron.io/account', function() {
this.echo(this.getTitle());
this.echo(this.evaluate(function() {return document.querySelector(".account-header").innerText}));
});
casper.run();
Upvotes: 1