You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何禁用Chrome for Testing执行测试时的BrowserMetrics文件生成?

禁用Chrome for Testing生成BrowserMetrics.pma文件的方法

可以通过添加Chrome启动参数彻底禁用这类指标文件的生成,具体方案如下:

  • 添加--disable-features=BrowserMetrics参数,直接关闭浏览器的指标收集功能,从根源阻止BrowserMetrics文件的生成。
  • 搭配--metrics-recording-only=false参数,明确禁用指标录制,和上一参数配合使用能确保效果更稳定。

如果是通过Selenium配置ChromeOptions,以下是不同语言的示例代码:

Python 示例

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--disable-features=BrowserMetrics")
chrome_options.add_argument("--metrics-recording-only=false")

driver = webdriver.Chrome(options=chrome_options)

Java 示例

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class TestSetup {
    public static void main(String[] args) {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--disable-features=BrowserMetrics");
        options.addArguments("--metrics-recording-only=false");
        
        WebDriver driver = new ChromeDriver(options);
    }
}

这些参数不会影响常规的Jasmine/Selenium测试执行,同时能彻底解决磁盘空间被大量占用的问题。

内容的提问来源于stack exchange,提问作者Yogesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 13:35:55