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

如何通过Intern.js配置预加载Firefox/Safari浏览器扩展?

Got it, let's sort out how to preload extensions for Firefox and Safari in your Intern tests, sticking to Intern's native config approach instead of raw Selenium code. Below are ready-to-use configuration examples for each browser, plus a combined setup that includes your existing Chrome config:

Firefox Extension Configuration

For Firefox, you'll leverage the moz:firefoxOptions property in your environment settings. You can provide either a local file path to your .xpi extension file, or its Base64-encoded string (just like you did with Chrome's CRX). Here's the snippet:

{
  "browserName": "firefox",
  "moz:firefoxOptions": {
    "extensions": [
      // Option 1: Local file path relative to your Intern config file
      "./path/to/your/extension.xpi",
      // Option 2: Base64-encoded string of the XPI file
      "U3VwZXJTdHJpbmcgZXhwb3J0IGJhc2U2NCBlbmNvZGVkIGZpbGUgZXhhbXBsZQ=="
    ]
  },
  "browserTimeout": 10000
}

Note: Make sure your Firefox extension is packaged as a valid .xpi file, and that it's compatible with the Firefox version you're testing against.

Safari Extension Configuration

Safari uses .safariextz extension packages, and you'll need to enable Safari's Developer Mode first (go to Safari > Settings > Advanced > check "Show Develop menu in menu bar"). In Intern's config, use the safari.options property to load the extension. Again, you can use a local path or Base64 string:

{
  "browserName": "safari",
  "safari.options": {
    "extensions": [
      // Option 1: Local file path to your .safariextz file
      "./path/to/your/extension.safariextz",
      // Option 2: Base64-encoded string of the safariextz file
      "QmFzZTY0IGVuY29kZWQgc2FmYXJpZXggZXhwb3J0IGZpbGU="
    ]
  },
  "browserTimeout": 10000
}

Important: Safari has stricter extension signing requirements, especially for newer versions. If you're testing locally, you may need to enable "Allow Unsigned Extensions" from the Develop menu.

Combined Full Intern Config

Here's how all three browsers fit into your complete Intern configuration, building on your existing Chrome setup:

{
  "capabilities": { "selenium-version": "3.5.2" },
  "tunnel": "null",
  "tunnelOptions": {
    "host": "selenium.hostaddres.com:4444",
    "port": "4444",
    "path": "/wd/hub"
  },
  "environments": [
    // Your existing Chrome config
    {
      "browserName": "chrome",
      "chromeOptions": {
        "extensions": ["Q3IyNAMAAABFAgAAEqwECqYCMIIBIjANBgkqhkiG9w0BA+LXpUNZoDajG6ywIDAQABEoACNd+U4xNvCvtf7m........."]
      },
      "browserTimeout": 10000
    },
    // Firefox config
    {
      "browserName": "firefox",
      "moz:firefoxOptions": {
        "extensions": ["./path/to/your/firefox-extension.xpi"]
      },
      "browserTimeout": 10000
    },
    // Safari config
    {
      "browserName": "safari",
      "safari.options": {
        "extensions": ["./path/to/your/safari-extension.safariextz"]
      },
      "browserTimeout": 10000
    }
  ],
  "reporters": ["pretty"],
  "functionalSuites": ["dist/functional/tests/**/*.js"]
}

Just replace the placeholder paths or Base64 strings with your actual extension files, and you should be good to go!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:11:53