This post will help to verify HTTP response code 200 of web application using java webdriver. As webdriver does not support direct any function to verify page response code. But using "WebClient" of HtmlUnit API we can achieve this.
Html unit API is GUI less browser for java developer, using WebClent class we can send request to application server and verify response header status.
Below code, I used in my webdriver script to verify response 200 of web application
Html unit API is GUI less browser for java developer, using WebClent class we can send request to application server and verify response header status.
Below code, I used in my webdriver script to verify response 200 of web application
String url =
"http://www.google.com/";
WebClient webClient = new WebClient();
HtmlPage htmlPage = webClient.getPage(url);
//verify response
Assert.assertEquals(200,htmlPage.getWebResponse().getStatusCode());
Assert.assertEquals("OK",htmlPage.getWebResponse().getStatusMessage());