[英]Capturing Firefox network logs with Selenium WebDriver using Java
Is there a way to capture.network logs while running an automated test on Firefox?有没有办法在 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.刷新项目文件夹后,我们将获得要捕获日志的 FFLogs.txt 文件。
OR.... Follow the official docs或者....按照官方文档
Official Docs : https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html官方文档: https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html
Here's the Java example in the documentation above.这是上面文档中的 Java 示例。 You can specify the logging level by including it in the
.setLogLevel
method of FirefoxOptions
class.您可以通过将其包含在
FirefoxOptions
class 的.setLogLevel
方法中来指定日志记录级别。
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
.您可以参考不同级别
logging
的文档。
you can use: System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt");
你可以使用:
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.刷新项目文件夹后,我们将获得要捕获日志的 FFLogs.txt 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.