Looking for the equivalent of a "mute browser" for PHP to test the cucumber

I am trying to set up some functional / acceptance / integration tests using Cucumber for my PHP project. I am trying to understand a better 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 am looking for the equivalent of a "mute browser" for PHP.

Will any of them be classified as "mute browsers?"

  • SimpleTest Web Testing
  • Zend_Test_PHPUnit_ControllerTestCase

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

+4
source share
6 answers

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

Although Selenium is a bit slow, it is easy to use to get started, as it comes bundled with Capybara. FYI: Firefox is the default.

Example support/env.rb :

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

Now that you are using Capybara, you should use the capybara-webkit driver (a truly headless browser that uses Webkit backstage). There's a bit of tweaking there, but once you have done that, speed has improved from using Selenium.

Example support/env.rb :

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

If you configured Cucumber to use Webrat, you can configure Webrat to use Mechanize by default . Mechanization is essentially a mute browser. This is what my env.rb file looks like:

 # 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 

Also, according to this article , you can configure Cucumber to use Capybara and configure it to use Celerity (a javascript-enabled headless browser). It also contains instructions for setting up Capybara to use Selenium RC (which I thought was not possible). I have not tried this approach yet, so I donโ€™t know how well it works.

+3
source

Why not use behat ( http://behat.org/ )?

It must have all the requirements listed above and it is written in php.

It has SahiDrvier for handling in-browser testing and Simple php browser.

+3
source

try Codeception: http://codeception.com

UPDATE:

This is similar to Capybara, but with PHP DSL. With the code, you can do something like this:

 $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')); 

You can use Selenium2 for browsing or PHPBrowser (headless) for better performance in js less scripts (PHPBrowser does not execute javascript)

+2
source

Update: It seems that Akephalos is not updating after some time, so this may not be the best solution for working with a newer version of Capybara.


Use Capybara (replacement for Webrat) and Akephalos (headless browser). Capybara is used to interact with Akephalos.

Example 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 
+1
source

If you are using Cucumber, are you no longer using Ruby? Why not use flexibility and non-integrity?

I used Cucumber with Celerity to test the Struts 2 app, as well as the ColdFusion 8 app. Basically, you use Celerity and JRuby (which wraps HtmlUnit) or Culerity, which runs on a native ruby, to control your browser.

I suggest considering one of these two projects to help you get started:

Cheesy UI Testing - Related Blog

WatirMelon Page Objects - Relevant Blog

0
source

Source: https://habr.com/ru/post/1341339/


All Articles