簡體   English   中英

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

[英]Capturing Firefox network logs with Selenium WebDriver using Java

有沒有辦法在 Firefox 上運行自動化測試時捕獲網絡日志? 我試着用

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

這是行不通的。

嘗試這個

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

刷新項目文件夾后,我們將獲得要捕獲日志的 FFLogs.txt 文件。

或者....按照官方文檔

官方文檔https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html

這是上面文檔中的 Java 示例。 您可以通過將其包含在FirefoxOptions class 的.setLogLevel方法中來指定日志記錄級別。

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

您可以參考不同級別logging的文檔。

你可以使用: System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "FFLogs.txt"); 刷新項目文件夾后,我們將獲得要捕獲日志的 FFLogs.txt 文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM