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

Chrome自动化控制提示禁用方案咨询(--disable-infobars参数已失效)

Solutions for Disabling Chrome's Automation Infobar After --disable-infobars Was Removed

Hey there! I’ve dealt with this exact headache when building Selenium-based screen recording tools, so I know how frustrating it is to have that infobar mess up your recordings. Let’s go through your options, from ideal workarounds to reliable fallbacks:

1. Use Updated Chrome Arguments & Experimental Options

Chrome replaced --disable-infobars with a set of newer flags and options that target the automation-specific warning. Here’s how to implement them in your Python code:

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

chrome_options = Options()

# Exclude the "enable-automation" switch to prevent the infobar from triggering
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
# Disable the default automation extension that Chrome loads
chrome_options.add_experimental_option('useAutomationExtension', False)
# Block the "AutomationControlled" feature that enables the warning
chrome_options.add_argument('--disable-features=AutomationControlled')

# Optional: Start maximized to avoid layout shifts (helps with recording)
chrome_options.add_argument('--start-maximized')

driver = webdriver.Chrome(options=chrome_options)

This combination works for most recent Chrome versions (90+) and keeps the infobar from appearing without modifying your webpage content.

2. Hide the Infobar via JavaScript (If Flags Fail)

If the above flags don’t work for your specific Chrome version, you can directly hide the infobar element once the page loads. Note that this depends on Chrome’s DOM structure, which might change with updates:

# After navigating to your target page
driver.execute_script("""
// Locate the infobar element (selector may vary; inspect Chrome to confirm)
const infobar = document.querySelector('div[aria-label="Chrome is being controlled by automated test software"]');
if (infobar) infobar.style.display = 'none';
""")

You’ll need to inspect the infobar element in Chrome to get the correct selector if the one above doesn’t work—right-click the infobar, select "Inspect", and grab the element’s unique attributes.

3. Fallback: Add Top Margin to Avoid Overlap

If the above methods stop working (Chrome loves changing these flags!), adding a top margin to your webpage is a reliable fallback. You can inject CSS via Selenium to shift content down:

# Inject margin to push content below the infobar
driver.execute_script("document.body.style.marginTop = '60px';")

Alternatively, you can adjust your FFmpeg recording command to crop the top 60px of the screen, so the infobar is excluded from the final video. This is great if you don’t want to modify the webpage’s appearance.

Bonus: Use Headless Mode (If Visualization Isn’t Needed)

If you don’t need to see the browser window while recording, Chrome’s new headless mode (--headless=new, available in Chrome 112+) doesn’t display the automation infobar at all. Add this flag to your options:

chrome_options.add_argument('--headless=new')

This is perfect for server-side or background recording tasks.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 08:23:10