Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Jun 07, 2019 20:34

How to set Performance logs on Chrome driver for Selenium project in Java on Perfecto

When you want to capture HAR, measure performance with Chrome driver

Step-by-step guide

Based upon http://chromedriver.chromium.org/logging/performance-log 

You can set the performance log of the driver

Here's a Java Selenium sample: https://github.com/PerfectoCode/Samples/tree/master/Selenium/Java/Selenium%20Chrome%20Performance%20Logs 

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();
    }



https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8457#c10