You cannot track network traffic with Selenium
A feature that Selenium does not support, and one that is requested time and again, is monitoring the browser network traffic. The Selenium development team has categorically stated that this will not be added to the WebDriver
API, despite many cries of outrage. Their reasons for not adding it are actually quite sensible.
Selenium drives the browser; it does not interact with the underlying mechanisms that the browser uses. As such, when Selenium loads a page, it is actually asking the browser to load a page. It does not interact with the remote server that is hosting the page—the browser does that—and as a result it doesn't know how the browser is interacting with the remote server. This interaction is not within scope for WebDriver
, and it never has been.
The issue is not completely straightforward, however. The old Selenium 1 API did have some functionality that allowed it to get network traffic, but only if you used Firefox. All involved agreed...