开发者

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

开发者 https://www.devze.com 2023-03-14 03:22 出处:网络
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.

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 becau开发者_JS百科se all of the code samples imply the existence of a Ruby or Rails code base.


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.


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. :-)


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")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号