0

How to check the this http response in selenium web driver? Is it possible to verify the same?

xyz
  • 21,367
  • 33
  • 107
  • 150
  • did you at least try the scenario where selenium gets to such page? Or more generally: What have you tried so far? – Pavel Janicek Mar 31 '14 at 07:08
  • Related to http://stackoverflow.com/questions/17657037/catching-a-404-error-with-selenium, http://stackoverflow.com/questions/2354827/checking-http-status-code-in-selenium and http://stackoverflow.com/questions/6509628/webdriver-get-http-response-code – xyz Mar 31 '14 at 07:20
  • Possible duplicate of [How to get HTTP Response Code using Selenium WebDriver with Java?](https://stackoverflow.com/questions/6509628/how-to-get-http-response-code-using-selenium-webdriver-with-java) – SiKing Nov 03 '17 at 21:11

2 Answers2

0

If you want to assert on the status of AJAX requests, then you can create a Browsermob proxy and use it's REST API to verify each request

Robbie Wareham
  • 3,607
  • 1
  • 17
  • 35
  • @Pavel m trying this HttpURLConnection conn = (HttpURLConnection) url.openConnection(); String output; BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream()))); System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { System.out.println(output); – user2931238 Mar 31 '14 at 09:18
0

Try this. It work for you :P

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String output;
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
 System.out.println(output);}

Once done verify the response code(using asserts). Let me know if u still face issue.

Vikas Gahlaut
  • 41
  • 2
  • 8