On the webpage I am testing, a GET call is made when the user clicks an option in a select list. The GET looks like this:
GET /mediaportal/captions/SCH/Follow%20Up%20with%20the%20Robles%20Family_SCH.xml
How can I tell Ruby to listen for the GET request and capture it, or more specifically capture and put into a variable the url that is requested in the GET above.
(I’m using the watir-webdriver gem, I’m hoping there is something in there that would allow me to do that.)
Ok – I did a little bit of more research and it turns out that there is a HTTP proxy thing bundled with the webrick web server. (A common experience with Ruby – the solution is often closer than expected.) The answer to this question sums it up nicely and points towards a blog post that gives a code example for how to do it.
You start a server using WEBrick::HTTPProxyServer and then you should be able to intercept all traffic. A challenge may be to interact with this server from your test code. It may be hard to do this without setting up some kind of server. But if you just want to listen for a specific call then you could start the server as part of your test suite and then shut it down when the call appears.