javascriptweb-scrapingphantomjscasperjsspookyjs

Why CasperJS fills text input with [object Object]


I use this code to fill text input

spooky.then([{question: question}, function(question) {
       this.fill('form[name="askmore"]', { questionask: question}, false);
 }]);

I have a valid sting in question. Here's a form markup:

<form action="" name="askmore" id="askmore" method="post" onsubmit="return false;">
<table cellspacing="0" cellpadding="0" border="0">
<tbody><tr><td>
<input type="text" maxlength="400" name="questionask" id="questionask" style="padding-left:15px; margin-left:45px; font-size:20px; width:480px; height:43px; border:0px; background-color:#d4d4d4; ">
</td>
<td>
<img hspace="15" src="/images/button.png" id="send" style="cursor: pointer;">
</td></tr></tbody></table></form>

Anyone know how to fix this? I think I'm doing it just like in the example from CasperJS documentation


Solution

  • Simply don't pass question as an argument:

    spooky.then([{question: question}, function() {
        this.fill('form[name="askmore"]', { questionask: question}, false);
    }]);