zend-frameworkseleniumcucumbersimpletestheadless-browser

Looking for a "headless browser" equivalent for PHP for Cucumber testing


I'm trying to set up some functional/acceptance/integration testing using Cucumber for my PHP project. I'm trying to understand the best approach to implementing these types of tests.

I understand that Selenium can test javascript, but Selenium is slow and I don't always need to test javascript. I'm looking for a "headless browser" equivalent for PHP.

Would either of these be classified as "headless browsers?"

What have you done to implement integration testing of your Zend Framework project?


Solution

  • First of all, you should use Capybara (a replacement for Webrat). It's used to simplify and standardize the DSL used to interact with the browser and provides some nice features.

    Even though Selenium is a little slow, it's easy to use to get started since it comes bundled with Capybara. FYI: it defaults to using Firefox.

    Example support/env.rb:

    require 'capybara/cucumber'
    
    Capybara.app_host = "http://your.app.com"
    Capybara.default_driver = :selenium
    

    Now that you're using Capybara, you should use capybara-webkit driver (a truly headless browser which uses Webkit behind the scenes). There's a little bit of setup involved, but once you've done that, the speed is improved from using Selenium.

    Example support/env.rb:

    require 'capybara/cucumber'
    
    Capybara.app_host = "http://your.app.com"
    Capybara.default_driver = :webkit