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

如何用Robot Framework的Open Browser方法禁用Chrome扩展并实现最大化及弹窗规避?

Got it, here's how you can achieve all your requirements using Robot Framework's Open Browser method instead of Create WebDriver:

First, you'll need to configure ChromeOptions with the same settings you used before, then pass those options directly to Open Browser (or convert them to capabilities for older versions). Here's a complete example:

*** Settings ***
Library    SeleniumLibrary

*** Test Cases ***
Launch Chrome with Custom Config
    # Initialize ChromeOptions object
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    
    # Disable the default automation extension (avoids related popups)
    Call Method    ${chrome_options}    add_experimental_option    useAutomationExtension    ${FALSE}
    
    # Open Chrome in maximized mode
    Call Method    ${chrome_options}    add_argument    start-maximized
    
    # Block the "extensions disabled by admin" popup
    # These extra settings suppress policy-related infobars and automation notifications
    Call Method    ${chrome_options}    add_argument    --disable-infobars
    Call Method    ${chrome_options}    add_argument    --disable-extensions
    Call Method    ${chrome_options}    add_experimental_option    excludeSwitches    ['enable-automation']
    
    # For SeleniumLibrary 4.x+, pass options directly to Open Browser
    Open Browser    ${HOMEPAGE_URL}    chrome    options=${chrome_options}
    
    # If you're using an older version, convert options to capabilities instead:
    # ${capabilities}=    Call Method    ${chrome_options}    to_capabilities
    # Open Browser    ${HOMEPAGE_URL}    chrome    desired_capabilities=${capabilities}
    
    # Proceed with your test steps...
    Go To    ${HOMEPAGE_URL}

Breakdown of what each setting does:

  • useAutomationExtension=False: Disables Selenium's default automation extension, which is often the source of the "extension disabled" warning.
  • start-maximized: Ensures Chrome launches in a fully maximized window, just like your original code.
  • --disable-infobars: Hides the "Chrome is being controlled by automated test software" info bar, which sometimes triggers related policy popups.
  • --disable-extensions: Turns off all extensions, which prevents the admin disable notification from appearing in the first place.
  • excludeSwitches=['enable-automation']: Removes the automation-related switch that tells Chrome it's being controlled by a script, further reducing popup triggers.

This setup should replicate exactly what your Create WebDriver code did, but using Open Browser instead.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 08:11:12