-1

i want get network information from firefox with selenium. I did it with chrome driver, like this

logPrefs.enable( LogType.PERFORMANCE, Level.ALL );
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("goog:loggingPrefs", logPrefs);
chromeOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

#and it is log code,

LogEntries logs = driver.manage().logs().get("performance");

I can get network logs and endpoint with this code. How can i get it from firefox? When i try it it is give it a error.

Caused by: org.openqa.selenium.json.JsonException: Unable to determine type from: H. Last 1 characters read: H

thank you

1 Answers1

1

Using Java, here's a way to get the network requests. The output could be more friendy, but the info is in there.

public class CaptureNetworkTraffic {

public static WebDriver driver;
public static String driverPath = \

@SuppressWarnings("deprecation")
public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", pathToDriver);

DesiredCapabilities caps = DesiredCapabilities.chrome();

LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.INFO);

caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

driver= new ChromeDriver(caps);
driver.get("https://www.edureka.co/");

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

}

driver.close();
driver.quit();

}
}
C. Peck
  • 3,641
  • 3
  • 19
  • 36
  • 1
    Hii @C. Peck, thank you for your help it's for chrome how can i do it same with firefox, when i try it's give an error`Caused by: org.openqa.selenium.json.JsonException: Unable to determine type from: H. Last 1 characters read: H ` –  May 26 '21 at 10:29