LogType.PERFORMANCE returns multiple times while first call from chrome webdriver

41 views
Skip to first unread message

bhavesh makwana

unread,
Aug 1, 2023, 9:09:11 AM8/1/23
to Selenium Users
LogType.PERFORMANCE

returns multiple times logs from LogType.performance while calling first URL from Array and it returns proper for rest of the URLs in Array.

e.g. String[] arrURLs = ['https://www.cypress.io/','https://www.url2.com','https://www.url3.com'];

ChromeOptions options = new ChromeOptions();
LoggingPreferences preferences = new LoggingPreferences();
preferences.enable(LogType.PERFORMANCE, Level.ALL);

ChromeOptions option = new ChromeOptions();

option.addArguments("enable-automation");
option.setCapability(ChromeOptions.CAPABILITY,option);
options.setCapability("goog:loggingPrefs", preferences);
options.addArguments("--remote-allow-origins=*");

ChromeDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();

for (int i=0; i<arrURLs.len; i++){
    driver.get(arrURLs[i]);

LogEntries logs1 = driver.manage().logs().get(LogType.PERFORMANCE);

for (LogEntry log:logs1){
  if (((log1.toString().contains("www.google-analytics.com")) && (log1.toString().contains("\"method\":\"Network.requestWillBeSent")) && log1.toString().contains("tid=")){
    System.out.println(log1.toJson().get("message"));
  }
}
}
Reply all
Reply to author
Forward
0 new messages