I've got phantomjs and casperjs working on a webserver. I've got a webpage up with a form on it and two fields in the form (name and email address).
I need to input both 'name' and 'email' as variables into my casper script. From reading
Pass parameter from php to casperjs/phantomjs
and
http://phantomjs.org/api/system/property/platform.html
I understand you need to put var system and var args but it all seems like double dutch to me.
Php code
$name = $_POST['user_input'];
$email = $_POST['user_input'];
putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
exec('/usr/local/bin/casperjs hello.js $name $email 2>&1',$output);
print_r($output);
casperjs code
var system = require('system');
var args = system.args;
var name = args
var email = args
var casper = require('casper').create({
verbose: true,
});
casper.start('website url');
casper.then(function () {
casper.wait(5000);
this.echo("wait for 5 seconds.");
});
casper.then(function () {
this.sendKeys('#firstname', name);
this.sendKeys('#thereemail', email);
this.click('.button');
From the looks of it I need to get both into one argument and then split them but how would I go about doing that?
Edit: The method posted would not work