Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could I use Capybara on frameworks outside Rails (PHP)? [closed]

I would like to test my php web app (specifically Magento) with Capybara. I've used Capybara with success when I used rails before so I want to replicate the success. Does anyone know if this is possible or maybe there is a Capybara for php?

like image 928
cleong Avatar asked Sep 28 '22 22:09

cleong


1 Answers

Yes this is possible. You have to define the url where your server serves the pages you want to test. For example, if you use rspec simply do it in the spec_helper.rb. Additionally you have to specify a different driver that does not want to start the app (which is not present), for example selenium:

Capybara.app_host = 'http://www.site-to-test.com' # where your site lives
Capybara.default_driver = :selenium # use selenium to control the external browsers

A basic Gemfile would look like this:

source 'https://rubygems.org'

gem "rspec", '~> 3.0'
gem "capybara"
gem "selenium-webdriver", '~> 2.45'

If you run your tests, it will fire up the browser window (if your browser is installed in some non default path you will have to configure this, too), will open your page and interact with it.

like image 133
Markus Avatar answered Oct 02 '22 09:10

Markus