Select Page
Selenium Testing

Collecting Network Events using Selenium WebDriver

Collecting Network Events using Selenium WebDriver is simple, you just need to enable performance logging in Chrome Desired capabilities.

Collecting Network Events using Selenium WebDriver
Listen to this blog

Collecting Network Events using Selenium WebDriver is simple, you just need to enable performance logging in Chrome Desired capabilities.

Once you enable Performance Log, Timeline, Network,
and Page events can be collected.

Enabling Logging in Desired Capabilities

DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.INFO);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);  

Collecting Network Events

WebDriver driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);

driver.get("https://codoid.com/about-codoid/");

List<LogEntry> entries = driver.manage().logs().get(LogType.PERFORMANCE).getAll();
System.out.println(entries.size() + " " + LogType.PERFORMANCE + " log entries found");
for (LogEntry entry : entries) {
          System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
}  

Note

If tracing is enabled, `ChromeDriver` will start a browser-wide trace when Chrome is launched, and will continue tracing until Chrome closes.

Reference

Performance Log
Demo code for the GTAC 2013 talk “Web Performance Testing with WebDriver” by Michael Klepikov

Comments(0)

Submit a Comment

Your email address will not be published. Required fields are marked *

Talk to our Experts

Amazing clients who
trust us


poloatto
ABB
polaris
ooredo
stryker
mobility