personal web log written by izabeera and dryobates

casperjs tricks

Capture screenshot of the content in the frame

by izabeera

Some time ago I had to scrape some data from site, that have many framesets in the html structure.

It looked like this bellow:

  <frame name=”first”>
    <frame name=”next”>
      <form name=”myForm”>

How to submit form “myForm” by using CasperJS?

First think was: “Don't panic, you can use javascript” :) But I'm very lazy woman ;) and I didn't want to write any javascript's code (even it could be few lines in jQuery). I had made research and I found answer – object Page provided by phantomjs and swichToFrame ( function.

Summarizing, in CasperJS swich to frame will be look like bellow:


    return "frame[name=first]";
}, function then(){'first');
    this.wait(10000, function() {'next');
        this.fill('form', {…}, true);
}, function timeout(){
    this.echo('Ohh no :/');

Iza Kartowicz-Stolarska. IT engineer. I work in programming since 2005. During this time I gained wealth of experience in writing web applications... and loved Python and Vim :) I enjoy working with people which have positive attitude to the world. Email: