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
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();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.