【发布时间】:2019-03-12 03:28:29
【问题描述】:
这对每个人来说可能都很明显,但我正在学习,对我来说不是:)
在 sendkeys 函数中,如果我通过命令行指定 pid,它会失败。如果我在文件中指定它,它可以工作。它确实被设置了,因为 echo 对这两种方法都有效。当我说失败时,我的意思是 1910193 没有出现在屏幕截图的框中。为什么?
我的命令
rm screenshot.jpg; casperjs mytest.js --pid="1910193"
我的代码
var casper = require('casper').create()
var x = require('casper').select
// obviously, these are not both used at the same time
var pid = '1910193'; // specified in file
var pid = casper.cli.get("pid") // specified on cmdline
casper.echo(pid); // works with both specification methods
casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1');
casper.start('https://myurl.net');
casper.then(function () {
this.sendKeys('#Account', pid);
console.log('searching.....');
casper.capture('screenshot.jpg')
});
casper.run();
【问题讨论】:
标签: command-line casperjs options