Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara integration with page-objects gem

Is it possible to use the page-object gem and capybara to automate Ruby on Rails testing? When I attempt to access a page object after starting up my test I receive the following error:

Unable to pick a platform for the provided browser (RuntimeError)

This makes sense as I think I'd have to pass the browser instance of capybara to the page-object, not sure if anyone else has tried this before.

like image 375
Armando Avatar asked Jan 14 '12 23:01

Armando


3 Answers

There is a gem that lets you use the Page Object pattern with capybara: SitePrism. Find it here: https://github.com/natritmeyer/site_prism

like image 184
Nat Ritmeyer Avatar answered Nov 05 '22 08:11

Nat Ritmeyer


Currently there is no support for capybara but it has been requested a few times. Part of the challenge is that the API was built upon selenium and watir which are much richer than capy and in it would be a very large undertaking to build add that functionality to the page-object gem to make capy behave the same way.

I've thought several times about splitting the page-object gem into a "basic" form that will allow capybara to utilize and an "advanced" form that will add the additional capabilities found in selenium and watir but haven't seen enough demand.

like image 42
Cheezy Avatar answered Nov 05 '22 07:11

Cheezy


https://github.com/andyw8/capybara-page-object looks like it started existing in the last 8 months or so.

like image 33
Peter Mounce Avatar answered Nov 05 '22 07:11

Peter Mounce