Capturing Firefox network logs with Selenium WebDriver using Java

Viewed 418

Is there a way to capture network logs while running an automated test on Firefox? I tried to use

LogEntries logs = driver.manage().logs().get(LogType.BROWSER);

This does not work.

2 Answers

Try this

System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt");

After refreshing the project folder, we shall get the FFLogs.txt file where the logs shall be captured.

OR.... Follow the official docs

Official Docs: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html

Here's the Java example in the documentation above. You can specify the logging level by including it in the .setLogLevel method of FirefoxOptions class.

FirefoxOptions options = new FirefoxOptions();
options.setLogLevel(FirefoxDriverLogLevel.TRACE);
WebDriver driver = new FirefoxDriver(options);

You can refer to the documentation for the different levels of logging.

you can use: System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt"); After refreshing the project folder, we shall get the FFLogs.txt file where the logs shall be captured.

Related