Is it possible? I'm looking around the Selenium docs and don't see any straightforward way to do it.
All help appreciated!
Is it possible? I'm looking around the Selenium docs and don't see any straightforward way to do it.
All help appreciated!
What I did to handle this using Selenium (not Selenium RC) was to convert the HTML tests into JSP and then utilize Java where needed to read headers or do whatever stuff that JavaScript (selenium is just Javascript) couldn't do.
Perhaps you could give a few details about how you plan to use Selenium?
I would not use Selenium for this type of test and suggest that you solve a variety of testing issues with different tools. what we do is:
Use unit tests to test code: methods and classes
Integration tests to test how application components hang together
A Simple functional test framework like Canoo WebTest (or some equivalent) to assert things like Http cache headers, basic page structure, simple redirection and cookie setting / values
Bespoke tests to ensure validity of pages to W3C standards
JSunit to test Javascript classes and methods we created
Selenium to test UI functionality/behaviour and the integration of Javascript into those pages
Its worth spending time breaking out the responsibility of testing different aspects of the system using these different tools since using only Selenium can cause issues:
There are also some techniques - which you may or may not have come across - which you can use to make your Selenium tests more resilient.
I've answered this question a couple times on StackOverflow. Search my previous answers to dig it up. The key that you have to write some custom Java code that extends ProxyHandler and SeleniumServer. You also need to use a release AFTER 1.0 beta 2.
As to the people who ask why you'd want to do this: there are a lot of reasons. In my case, we're testing an AJAX heavy app and when things go wrong, one of the first things we debug is the network wire. That helps us see if the AJAX call happened and, if so, what the response was. We're actually automated the collection of this info and capture it (along with a screenshot) with every Selenium test.
captureNetworkTraffic() API in DefaultSelenium captures http request/response headers and you can access them in html/xml/plain format.
Here is sample code:
Selenium s = new DefaultSelenium(...);
s.start("captureNetworkTraffic=true");
s.open("http://www.google.com");
String xml = s.captureNetworkTraffic("xml"); // html, plain
s.stop();
It seems to me that it can be very useful to test HTTP response headers from selenium. Not in 100% of the cases, perhaps ... but there certainly are some. If you are checking out a sequence of pages, it seems like it would be useful to test some response headers as part of that testing (Content-Type and Pragma leap to mind).
but response for every request made is not captured .assume i have clicked the link and done some thing .only .css,.gif & referel url shown. am i missing something