简体   繁体   English

使用 Selenium WebDriver 使用 Java 捕获 Firefox.network 日志

[英]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.

相关问题 使用 Java 使用 Selenium WebDriver 捕获浏览器日志 - Capturing browser logs with Selenium WebDriver using Java 使用相同的Firefox窗口在Selenium WebDriver(Java)中运行多个测试 - Using the same Firefox Window to run multiple tests in Selenium WebDriver (Java) 如何使用带有Java的Selenium WebDriver将命令写入Firefox控制台? - How to write commands into the Firefox console using Selenium WebDriver with Java? Selenium 与 java 问题使用 webdriver.firefox.marionette - Selenium with java issue using webdriver.firefox.marionette 在 Java 程序 (Firefox) 中使用 Selenium Webdriver 获取无法连接错误 - Getting cannot connect error using Selenium Webdriver in Java program (Firefox) 如何使用带有Java的Selenium Webdriver在Firefox中禁用不安全密码警告 - How to disable Insecure Password Warning in Firefox using Selenium Webdriver with Java 如何使用 Selenium webdriver 和 Java 为 firefox 设置代理? - How do I set a proxy for firefox using Selenium webdriver with Java? 无法使用 java 在 firefox 上的 selenium webdriver 中处理警报 - Unable to handle alerts in selenium webdriver on firefox using java 使用 selenium webdriver java 4.0v 捕获网络流量 - Capture network traffic using selenium webdriver java 4.0v 通过监视Selenium Webdriver中的网络流量来捕获Post参数 - Capturing Post parameters by monitoring network traffic in Selenium Webdriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM