Reputation: 170
Using java, I can get the http response code of a url (like this), and using selenium I am able to get all elements from a webpage (like this).
Is there a way I can get the response code of an element? Because an element is not a link, its not like getting the response of a url. (which is what all the other stack overflow questions go over.)
Really, I'm just trying to see if all the elements of a webpage were loaded (got a response 200) and to see which ones did not load (maybe they got a response 404). Like on the network tab in browser inspect. (Is there some built in selenium feature that allows access to the network tab? I couldn't find any.)
Update: I was calling it 'element' in the question, but I found out it is actually called 'resource'.
Example of browser Network Tab
Upvotes: 1
Views: 1303
Reputation: 301
This can go very subjective. First Selenium is not a tool to achieve what you are looking at and as far as I know Selenium does not have any interface to introspect the browser debugging/developer tools. You may use the browser's native developer APIs to query the network tab and its events.
Now coming to HTTP Response, a status code = 200 does not guarantee that all the elements are loaded, just because of the nature of modern web applications and dynamic content in them. When you say https Response, it gets associated with a Resource. Mostly nobody treats a web element as a Resource.
What you have highlighted in the image is a couple of javascript not loaded.
Upvotes: 1