简体   繁体   中英

Capturing Firefox network logs with Selenium WebDriver using Java

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.

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM