質問

When loading a web page, it executes many GET request to fetch resources, such as images, css files, fonts and other stuff.

Is there a possibility to capture failed GET requests using Selenium in C#?

役に立ちましたか?

解決

Selenium does not natively provide this capability. I'm coming to this conclusion for two reasons:

  1. I've not seen any function exported by Selenium's API which would allow doing what you want in a cross-platform way.

    (I'm saying "cross-platform way" because I'm excluding from considerations possible non-standard APIs that could be exported by one browser but not others.)

    If there is any doubt I may have missed something, then consider that ...

  2. The Selenium team has quite consciously decided not to provide any means to get the response code of the HTTP request that downloads the page in the first place. It is extremely doubtful that they would have slipped behind the scenes a way to get the response code of the other HTTP requests that are launched to load other resources.

The way to check on any such requests is to have the Selenium browser launched by Selenium connect through a proxy that records such responses. Or to load the page with something else than Selenium.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top