2

I'm starting with Cucumber & Ruby and wondering if the following is possible.

I'm at a page and I know that when I click link, that's going to send a request looking like: http://example.com?param1=value1&param2=value2

Is it then possible to intercept that call and retrieve it's parameters by using Ruby? or if not, any other idea about how to get those values through an automated test?

Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123
mickael
  • 2,033
  • 7
  • 25
  • 38
  • Am I right that you want to intercept request/response, parse it and then automatically construct automated test based on it? – Andrei Botalov Jul 11 '12 at 10:31
  • Yes, that's exactly the scenario, but can't think about how to get that request/response to create the required tests... – mickael Jul 11 '12 at 10:34
  • This question is very similar too yours: http://stackoverflow.com/questions/4487603/can-i-use-selenium-ide-to-generate-cucumber-capybara-steps – Andrei Botalov Jul 17 '12 at 20:46

1 Answers1

0

What you want to do is called test recording. Test recording has many disadvantages and it's not a good idea to use it, see:

I doubt that there is a tool that can generate Cucumber features automatically. Cucumber features are meant to be used as a requirements storage, a mechanism to collaborate with stakeholders and a living documentation. It's overhead to use Cucumber if you don't need any of those sides. I can't imagine test recording tool that will generate features looking good enough to be used for these purposes.

Maybe there is a tool that will generate features or plain Ruby (e.g. Capybara) tests. But I doubt it's needed as Capybara tests are quiet easy to write and tests created using test recording tool will be hard to maintain.

Community
  • 1
  • 1
Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123
  • I was thinking more along the lines of creating some generic feature files (which are useful for everyone in the business) and then implement a lot of logic in the ruby code itself. Kind of: Given I am in the homepage Then user interactions are tracked and in the ruby code, put logic for the specific user interactions we want to track. The problem I'm encountering is that I don't see if ruby can capture HTTP calls/responses to be able to create assertions? – mickael Jul 13 '12 at 08:48
  • @mickael Why do you want to capture those HTTP calls and then reproduce them instead of using Capybara API? – Andrei Botalov Jul 14 '12 at 09:08
  • Am I right? You want to write feature file, write regex at step_defintions. And then generate code inside step defintion using interception requests from browser. – Andrei Botalov Jul 14 '12 at 09:12
  • Sorry Andrey, I didn't see your reply here. Your 2nd comment is what I want. I don't want to reproduce some calls with Capybara, I want to capture the HTTP calls that are done when a user press a click and then check that the calls requested from the browser are indeed what they are supposed to be. This scenario is still pending for now, as I didn't find a way to do it just yet. – mickael Sep 23 '12 at 16:01