4

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

Is it possible to use Capybara/Selenium to test a web application over which you have no access to the code, or it is not a Ruby/Rack application. Worded another way, is it possible to black-box test a web app using Capybara/Selenium? If so, how?

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

Jay Godse
  • 15,163
  • 16
  • 84
  • 131

3 Answers3

0

Yes. You just need to use a "visit" function which goes directly to the URL you want to test.

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")
Melski
  • 309
  • 3
  • 4
0

I don't see any reason why that wouldn't be possible. Assuming your Web Application is accessible via HTTP, you should be fine (this is obviously VERY likely to be true).

All RSpec Request Specs are basically black box tests. That's the point of Request Specs - you want to simulate a real user and exercise your whole Application stack - starting with HTML views down to database access. The same is true for cucumber features.

Writing you Specs might be a little less comfortable, because you can't rely on the Web Application to adhere to Rails conventions.

Anyway... I hope this helps.

Christoph Schiessl
  • 6,818
  • 4
  • 33
  • 45
0

Sure, in fact, the most common initial test is to automate www.google.com. It turns out to be a bad first attempt (the modern Google is very AJAXy and subtle), but it's what everybody thinks of first. Followed quickly by GMail, which is even moreso. :-)

Ross Patterson
  • 9,527
  • 33
  • 48