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

如何通过Selenium在Edge浏览器中加载扩展(含APPX格式)?

Loading APPX Extensions in Edge with Selenium

Hey there! I totally get the confusion—moving from Chrome's CRX extensions to Edge's APPX format feels like a whole different ballgame, especially since Edge doesn’t have a direct addExtensions method like Chrome. Let’s break this down step by step to get your APPX extension loaded successfully.

Step 1: Install the APPX Extension Locally

First, you need to install the APPX file onto your system. You can do this easily via PowerShell:

Add-AppxPackage -Path "C:\full\path\to\your\extension-file.appx"

Replace the path with the actual location of your APPX file. If the extension has dependencies (like .appxbundle or .cer files), install those first to avoid errors.

Step 2: Locate the Extension’s Key Details

Once installed, grab two critical pieces of info:

  1. Extension ID: Open Edge, go to edge://extensions/, toggle on Developer mode (top-right corner), then copy the ID listed under your APPX extension.
  2. Installation Path: Open File Explorer and navigate to:
    C:\Users\<YourUsername>\AppData\Local\Packages\<ExtensionPackageName>\LocalState\extension
    
    To find <ExtensionPackageName>, run this PowerShell command (replace YourExtensionName with a keyword from your extension):
    Get-AppxPackage | Where-Object {$_.Name -match "YourExtensionName"} | Select-Object PackageFullName
    

Step 3: Configure Selenium to Load the Extension

Instead of an addExtensions method, we’ll use Edge’s command-line arguments to load the extension. Here’s a Python example:

from selenium import webdriver
from selenium.webdriver.edge.options import Options

edge_options = Options()

# Option 1: Use the full installation path
edge_options.add_argument(f"--load-extension=C:\\Users\\<YourUsername>\\AppData\\Local\\Packages\\<ExtensionPackageName>\\LocalState\\extension")

# Option 2: Use the extension ID (works for some setups)
# edge_options.add_argument(f"--load-extension=<YourExtensionID>")

# Launch Edge with the configured options
driver = webdriver.Edge(options=edge_options)
driver.get("https://www.example.com")

Key Tips to Avoid Headaches

  • Keep Developer Mode Enabled: Edge requires this to load custom/unpacked extensions like your APPX file.
  • Match WebDriver Version: Ensure your Edge WebDriver matches your installed Edge browser version—mismatches cause weird bugs.
  • Permissions: If your extension needs specific permissions, you might have to accept them manually on first launch (auto-accepting permissions varies by extension type).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:10:04