Design, Programming, Projects, Technology

Behat and “The current node list is empty.” error.

If your receiving the error “The current node list is empty” while using Behat, then likely your project is returning an HTTP 500 error. This may be because your bundle depends on some other bundle not available in your test environment. This was the case when for me when testing a bundle on travis-ci and i was not able to find documentation on this error.

One solution as suggested on github is to try dumping the contents of the scraper/browser to see what kind of error your getting.

     /**
     * @Then /^I dump the contents$/
     */
    public function iDumpTheContents()
    {
        print_r($this->getSession()->getPage()->getContent());
        //or print_r($this->getSession()->getDriver()->getContent());
        // The following produces "The current node list is empty."
        //print_r($this->getSession()->getDriver()->getText('//html'));
    }

However that will likely not give you any output if the server is returning an HTTP 500 internal server error. Your best bet is to just check your logs and do a search for any errors.

If your trying to run your functional tests on travis-ci then you might want to check out this great article on running Behat scenarios in isolation of your project.

Best of luck.