Implement the Chrome performance log in Selenium Java
Learn how to set performance logs on a Chrome driver for Selenium project in Java in Perfecto when you want to capture a HAR file and measure performance with a Chrome driver.
The following is based on http://chromedriver.chromium.org/logging/performance-log.
You can set the performance log of the driver.
A Java Selenium sample is available at https://github.com/PerfectoCode/Samples/tree/master/Selenium/Java/Selenium%20Chrome%20Performance%20Logs.
Copy
Example
DesiredCapabilities desiredCapabilites = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
desiredCapabilites.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
RemoteWebDriver driver = new RemoteWebDriver(desiredCapabilites);
try {
System.out.println(driver.manage().logs().getAvailableLogTypes());
driver.get("https://google.com/");
for (LogEntry logEntry : driver.manage().logs().get(LogType.PERFORMANCE).getAll())
{
System.out.println(logEntry);
}
} finally {
driver.quit();
}
Related articles
- https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8457#c10
- Perform authentication using Internet Explorer or Microsoft Edge
- Perform authentication using Chrome or Firefox
- Selenium page displays when opening localhost:8080 on desktop
See also the Perfecto Knowledgebase.