将多个变量从php传递到casperjs
Passing Multiple variables from php to casperjs
我有phantomjs和casperjs在Web服务器上工作。我有一个网页,上面有一个表格和两个字段(姓名和电子邮件地址)。
我需要将"name"answers"email"作为变量输入到我的casper脚本中。从读取
将参数从php传递到casperjs/fontomjs
和
http://phantomjs.org/api/system/property/platform.html
我知道你需要放var系统和var args,但对我来说这一切似乎都是双重的。
Php代码
$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代码
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');
从表面上看,我需要把两者都放在一个论点中,然后把它们分开,但我该怎么做呢?
编辑:发布的方法不起作用
var casper = require("casper").create({
verbose: true,
});
var name = casper.cli.args[0];
var email = casper.cli.args[1];
另请参阅:非常接近您问题的答案;关于使用CLI 的官方CasprJS文档
相关文章:
- 使用php或javascript从facebook相册URL中删除多余的部分
- 将PHP变量传递给jQuery时遇到问题
- 通过javascript重定向html传递php变量
- 将数组从PHP传递到Javascript
- 如何在php文件中获取$.post-ajax传递的值
- Javascript运行php文件,然后下载文件
- PHP中的setcookie仅适用于localhost
- 如何使用jquery处理php循环通过元素
- 通过Ajax将JavaScript函数传递给PHP文件
- 而循环只设置php中输入字段中的第一个值
- 我需要从php调用javascript或jquery
- 如何通过php页面将数据库值检索到jquery自动完成框中
- PHP AJAX图片上传示例不上传
- 通过php页面中的js强制下载txt
- 将多个变量从php传递到casperjs
- 使用 casperjs 和 PHP 来保存数据
- 单击按钮以在PHP中运行casperJS,并在带有按钮的相同PHP页面中返回结果
- 不能在casperjs中使用PHP的JSON字符串
- 将数据从CasperJS脚本发送到PHP
- 如何运行CasperJS脚本不使用PHP exec或shell_exec