I am newbie to selenium webdriver. I am trying to validate broken images/links
Scenario:
- Take any sample url from any secured application which is located at different domain. Ex - footer link – Stores link :
https://username:password@sample.com/some/linkOrimageUrl
Execute the above url using the below code in java.
URL url = new URL(LnkOrImgurl);
HttpURLConnection httpURLConnect= HttpURLConnection)url.openConnection();
httpURLConnect.setConnectTimeout(3000);
httpURLConnect.connect(); message = ""+httpURLConnect.getResponseMessage(); System.out.println(message); httpURLConnect.disconnect();Checking the http response code –
200 – SUCCESS or 401 – UNAUTHORIZED
- Expected http response code -
200
But it throws me always 401- error when i execute this piece of code. Am i doing something wrong here?