My code is very simple, just like:
// I want to verify the browser status code in this line.
And actually, I’d like to navigate to every link and button on my homepage and make sure each one return status code 200, is there a better way to do this?
I’d tried WebUI.verifyAllLinksOnCurrentPageAccessible(), but it only return passed or failed, and even the result is somewhat inaccuracy.
you can get a status code for each page using a Web Service Request. Basically you are getting status codes for each endpoint on a page, not the page itself. Try this code:
String url = "http://www.google.com"
RequestObject ro = new RequestObject()
ResponseObject resp = WSBuiltInKeywords.sendRequest(ro)
You should get 200 in a Console.
Using getStatusCode method also helps to get status code then will use assert to perform the validation status code