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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With