【发布时间】:2013-07-31 16:55:48
【问题描述】:
我正在使用 CasperJS 填写一些表单(输入字段、选择框等)。我已将 jquery 注入到脚本中,但我不知道如何使其其余部分正常工作。
我基本上是在尝试“找到”页面上的单个元素并在其中找到标签并更改值。更改此设置后,我想单击 html 名称为“add_phone”的提交按钮。
这是我目前所拥有的 - 请注意,我正在使用最新版本的 CasperJS 1.1.0-DEV 和 PhantomJS v1.9.1
执行时返回以下错误:
TypeError: 'undefined' is not a function (evaluating 'this.evaluate(function() {
return $('table').find('select').val();
});
代码:
var casper = require('casper').create({
clientScripts: ['includes/jquery.min.js'],
verbose: true,
logLevel: 'debug',
loadImages: false
});
var url = 'http://www.simplysellular.com/displayphone.php?manufacturers=Apple&phones=iPhone+5+(ATT/GSM)+32GB&affiliates_id=14&affiliates_tracking_id=2072&utm_source=sellcell&utm_medium=web&utm_campaign=sellcell&condition_id=15';
casper.start(url);
var deviceValue = this.evaluate(function() {
return $('table').find('select').val();
});
this.echo(deviceValue);
casper.exit();
【问题讨论】:
标签: javascript phantomjs casperjs headless-browser