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