0

I'm trying to get to a download on the other side of this form, but there's no button to click. How can I tell casperJS to execute the function document.forms.item(0).submit() so I can get to the file?

<form action="/Login?ReturnUrl=GetRecepisse&amp;r=++7DsodrsYlc9WAUmEBtwVkiAONQjiyw3tjrpi5kjPlx6dDdwAim9zIzxpYGZpE+gtwXyLoyR5svQKRnulLAdg==" method="post">
    <input id="TempUsername" name="TempUsername" type="hidden" value="" />
            <input id="TempPassword" name="TempPassword" type="hidden" value="" />    


    <script language="javascript" type="text/javascript">
        document.forms.item(0).submit();
    </script>
</form>

Thanks in advance for your help.

brainstormtrooper
  • 485
  • 2
  • 6
  • 18
  • I tried : `casper.start(casper.cli.raw.get('target')); //page.evaluate(function() { casper.evaluate(function() { this.echo('Here in evaluation'); document.forms[0].submit(); });` But it doesn't seem to do anything... – brainstormtrooper Apr 06 '17 at 07:26

1 Answers1

0

Well, I finally got it working by making a POST request instead...

casper.start();

casper.open(casper.cli.raw.get('target'), {
method: 'post',
data:   {
    'TempUsername': '',
    'TempPassword': ''
}

});

Then I just used the on('resource.received',... method to capture the returned file...

brainstormtrooper
  • 485
  • 2
  • 6
  • 18