如何用Watir解决「管理员已禁用加载未打包扩展」报错并关闭弹窗
Hey there! I’ve dealt with this exact frustrating popup before when automating browsers, so let me share the actionable fixes that actually work to get rid of it:
1. Bypass the Restriction via Command-Line Flags
This is the quickest fix if you’re launching the browser programmatically (like with Selenium, Puppeteer, etc.). Add these flags when initializing your browser instance:
--disable-features=BlockUnpackedExtensions: This directly disables the admin-enforced block on unpacked extensions--load-extension=/full/path/to/your/extension: Specify the exact folder path of your unpacked extension- Optional: Add
--no-first-runand--disable-default-appsto skip other annoying initial setup popups
Example for Python Selenium:
from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--disable-features=BlockUnpackedExtensions") chrome_options.add_argument("--load-extension=/home/your-user/your-extension-folder") driver = webdriver.Chrome(options=chrome_options)
2. Adjust Local Group Policy (Windows Only)
If your Windows system has admin-level group policies blocking unpacked extensions, tweak these settings:
- Press
Win + R, typegpedit.mscand hit Enter to open the Local Group Policy Editor - Navigate to:
Computer Configuration > Administrative Templates > Google > Google Chrome > Extensions - Find the
Configure extension installation blocklistpolicy, double-click it, and set it to Disabled or Not Configured - Next, locate
Allow unpacked extensionsand set it to Enabled - Restart Chrome for changes to take effect
3. Modify Chrome Preference Files (Mac/Linux)
For Mac or Linux users, you can edit Chrome’s core preference settings to allow unpacked extensions:
- Close all Chrome windows completely
- Navigate to Chrome’s preference directory:
- Mac:
~/Library/Application Support/Google/Chrome/Default/Preferences - Linux:
~/.config/google-chrome/Default/Preferences
- Mac:
- Open the
PreferencesJSON file in a text editor - Look for the
extensionssection, then add or modify the line:"allow_unpacked_extensions": true - Save the file and restart Chrome
4. Use a Portable Browser Build
If all else fails, grab a portable version of Chrome (or Edge). Portable builds don’t respect system-wide admin policies, so you can load your unpacked extension without hitting the popup. Just download the portable package, extract it, and launch it directly.
Hope one of these solutions squashes that annoying popup for you! Let me know if you need help with any specific step.
内容的提问来源于stack exchange,提问作者Apzal Bahin

