寻找一款“无头浏览器”&rd​​quo;相当于PHP用于黄瓜测试

我正在尝试使用Cucumber为我的PHP项目设置一些功能/接受/集成测试。我试图了解实现这些类型的测试的最佳方法。 我知道Selenium可以测试javascript,但是Selenium很慢,我并不总是需要测试javascript。我正在寻找一个与PHP无关的“无头浏览器”。 将这些中的任何一个归类为“无头浏览器吗?” SimpleTest Web测试 Zend_Test_PHPUnit_ControllerTestCase 您如何实施Zend Framework项目的集成测试?     
已邀请:
如果将Cucumber设置为使用Webrat,则可以将Webrat设置为默认使用Mechanize。 Mechanize本质上是一个无头浏览器。这是我的env.rb文件的样子:
# RSpec
require 'rspec/expectations'

# Webrat
require 'webrat'

require 'test/unit/assertions'
World(Test::Unit::Assertions)

Webrat.configure do |config|
  config.mode = :mechanize
end

World do
  session = Webrat::Session.new
  session.extend(Webrat::Methods)
  session.extend(Webrat::Matchers)
  session
end
此外,根据这篇文章,你可以设置Cucumber使用Capybara并将其配置为使用Celerity(一个支持javascript的无头浏览器)。它还包括如何配置Capybara使用Selenium RC(我认为不可能)的说明。我还没有尝试过这种方法,所以我不知道它的效果如何。     
为什么不使用behat(http://behat.org/)? 它应该具有您在上面列出的所有要求,并且它是用PHP编写的。 它有一个SahiDrvier来处理“浏览器内”测试,以及一个简单的php浏览器。     
试试Codeception:http://codeception.com 更新: 它就像Capybara,但有PHP DSL。使用代码,您可以执行以下操作:
$I = new WebGuy($scenario);
$I->wantTo('create wiki page');
$I->amOnPage('/');
$I->click('Pages');
$I->click('New');
$I->see('New Page');
$I->fillField('title', 'Hobbit');
$I->fillField('body', 'By Peter Jackson');
$I->click('Save');
$I->see('page created'); // notice generated
$I->see('Hobbit','h1'); // head of page of is our title
$I->seeInCurrentUrl('pages/hobbit'); 
$I->seeInDatabase('pages', array('title' => 'Hobbit'));
您可以使用Selenium2进行浏览,或使用PHPBrowser(无头)在js less场景下获得更好的性能(PHPBrowser不执行javascript)     
更新:Akephalos似乎暂时没有更新,因此对于使用较新版本的Capybara而言,它可能不是一个好的解决方案。 使用Capybara(Webrat的替代品)和Akephalos(无头浏览器)。 Capybara习惯于与Akephalos互动。 示例
support/env.rb
# Capybara configuration (using Akephalos)
require 'capybara/cucumber'
require 'akephalos'

Capybara.default_driver = :akephalos
Capybara.app_host = 'http://your.web.app'

Capybara.register_driver :akephalos do |app|
  # available options:
  #   :ie6, :ie7, :ie8, :firefox_3, :firefox_3_6
  Capybara::Driver::Akephalos.new(app, :browser => :firefox_3_6)
end
    
如果你正在使用Cucumber,你还没有使用Ruby吗?为什么不使用快速或快速? 我已经使用Cucumber with Celerity来测试Struts 2应用程序以及ColdFusion 8应用程序。基本上,您使用Celerity和JRuby(包装HtmlUnit)或在本机ruby上运行的Culerity来驱动您的浏览器。 我建议看看这两个项目中的一个,以帮助您入门: Cheesy UI测试 - 相应的博客 WatirMelon页面对象 - 对应的博客     
首先,你应该使用Capybara(Webrat的替代品)。它用于简化和标准化用于与浏览器交互的DSL,并提供一些不错的功能。 尽管Selenium有点慢,但由于它与Capybara捆绑在一起,因此很容易上手。仅供参考:它默认使用Firefox。 示例
support/env.rb
require 'capybara/cucumber'

Capybara.app_host = "http://your.app.com"
Capybara.default_driver = :selenium
既然你正在使用Capybara,你应该使用capybara-webkit驱动程序(一个在幕后使用Webkit的真正的无头浏览器)。有一些设置涉及,但一旦你这样做,速度提高了使用Selenium。 示例
support/env.rb
require 'capybara/cucumber'

Capybara.app_host = "http://your.app.com"
Capybara.default_driver = :webkit
    

要回复问题请先登录注册