1

The CasperJS Quickstart Guide has this example on filling out a form:

casper.start('http://google.fr/', function() {
    // search for 'casperjs' from google form
    this.fill('form[action="/search"]', { q: 'casperjs' }, true);
});

casper.then(function() {
    // aggregate results for the 'casperjs' search
    links = this.evaluate(getLinks);
    // now search for 'phantomjs' by filling the form again
    this.fill('form[action="/search"]', { q: 'phantomjs' }, true);
});

The form is submitted automatically because of the true parameter being passed to this.fill, and the next casper.then function is called as soon as the new page is loaded.

But when writing Cucumber tests with SpookyJS like so:

    spooky.start("http://www.somepage.com");

    spooky.then(function () {
      this.fill("form", {username: "foo", password: "bar"}, true);
    });

    spooky.then(function () {
      this.echo(this.getPageContent());
      this.echo(this.getCurrentUrl());
    });

By looking at the page content and the URL, I can tell that Spooky is saying it's still on the form page when the spooky.then function is called. But if you add one more spooky.then like so:

    //Empty Spooky.then call so we can do what we want on the correct page
    this.spooky.then(function () {});

    this.spooky.then(function () {
      this.echo(this.getPageContent());
      this.echo(this.getCurrentUrl());
    });

Suddenly, this works. Why is an extra spooky.then call needed here, when it isn't needed while using Casper? I have tested this in Casper and it works as expected, but with Spooky, an extra then call is needed.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
A. Duff
  • 4,097
  • 7
  • 38
  • 69

0 Answers0