嗯,这个问题非常明显。
现在,我已经在一个表格的前面,这个表格已经有一些选项标签。但我必须插入一个新的,具有不同的值,我将从.json文件中收到。
问题是:我还没有能够从CasperJS文档中找到合适的解决方案。
我尝试过这样的事情:
this.fill('form.coworkerdiscountcode', {
'CoworkerDiscountCode.DiscountCode': ['Value1']
});
但没有结果。有任何想法吗?
提前致谢。
答案 0 :(得分:0)
您可以执行任何javascript代码,方法是将其传递给casper.evaluate
,如下所示:
casper.evaluate(function() {
var x = document.getElementById("coworkerdiscountcode");
var option = document.createElement("option");
option.text = "Kiwi";
x.add(option);
});