Capybara + RSpec: Can it be used for any web application?

I saw railscast at http://railscasts.com/episodes/257-request-specs-and-capybara , which describes how to use Capybara with RSpec in a Rails application.

Is it possible to use Capybara / Selenium to test a web application where you do not have access to the code, or is it not a Ruby / Rack application. In other words, is it possible to use the black box for a web application using Capybara / Selenium? If so, how?

I ask because all code examples imply the existence of a Ruby or Rails code base.

+4
source share
3 answers

I see no reason why this is not possible. Assuming your web application is accessible via HTTP, you should be fine (this is obviously very likely to be true).

All RSpec request specifications are mainly black box tests. What is the point of Spec queries - you want to simulate a real user and implement your entire application stack - from HTML representations to database access. The same can be said about the properties of cucumber.

Your writing Specifications may be a little less convenient because you cannot rely on a web application to adhere to the Rails conventions.

Anyway ... Hope this helps.

0
source

Of course, the most common initial test is automation at www.google.com. This turns out to be a bad first attempt (modern Google is very AJAXy and subtle), but this is what everyone thinks of first. GMail followed quickly, which is even more similar. :-)

0
source

Yes. You just need to use the β€œvisit” function, which goes directly to the URL you want to check.

visit 'http://www.gmail.com' 

Then you can find any of the HTML elements using capybara functions

 find("input#Email").set("superman") all("input#Email")[0].set("superman") 
0
source

All Articles