简体   繁体   English

使用Robot Framework的Open Browser方法禁用Chrome扩展

[英]Disable Chrome extensions with Robot Framework's Open Browser method

I need to open Chrome maximised with an experimental option to prevent a pop warning about extensions "disabled by your administrator". 我需要使用实验性选项将Chrome最大化打开,以防止弹出有关扩展名“由管理员禁用”的警告。

Using Create WebDriver, I can get this working with 使用Create WebDriver,我可以将其与

Open Chrome With Options
  ${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
  Call Method       ${options}    add_experimental_option      useAutomationExtension    ${FALSE}
  Call Method       ${options}    add_argument      start-maximized
  Create WebDriver  Chrome    chrome_options=${options}
  Go To             ${HOMEPAGE}

However, when I try something equivalent with Open Browser (see below), although the "useAutomationExtension" is working, the start-maximised setting is ignored. 但是,当我尝试使用与“打开浏览器”等效的方法(见下文)时,尽管“ useAutomationExtension”正在工作,但开始最大值设置将被忽略。 Why is this? 为什么是这样?

Open Chrome with Capabilities
  ${args}=              Create List   start-maximised
  ${chrome_options}=    Create Dictionary
  ...    useAutomationExtension     ${FALSE}
  ...    args                       ${args}
  ${capabilities}=     Create Dictionary
  ...    chromeOptions    ${chrome_options}
  Open Browser  ${HOMEPAGE}  ${BROWSER}    desired_capabilities=${capabilities}

Desired capabilities and chrome options are two different configurations. 所需功能和镶边选项是两种不同的配置。 The keyword "Open Browser" doesn't support chrome options, so the only way to add options to chrome is by keywords "Create WebDriver" 关键字“打开浏览器”不支持chrome选项,因此向chrome添加选项的唯一方法是通过关键字“ Create WebDriver”

You need to add all the params in the list. 您需要在列表中添加所有参数。 Then pass this list to Dictionary object and pass it to open a browser. 然后将此列表传递给Dictionary对象,并将其传递给打开浏览器。

All the chrome options need to be passed as a dictionary object to Open Browser with key desired_capabilities. 所有的chrome选项都需要作为字典对象传递给具有所需的关键功能的Open Browser。

Ex. 防爆。

${options} =     Create List    --start-maximized    --disable-web-security <<any options that you need to add>>
${arguments} =     Create Dictionary    args=${options}
${capabilities} =     Create Dictionary    chromeOptions=${arguments}
Open Browser    https://www.google.com    remote_url=${grid_url}    browser=${BROWSER}    desired_capabilities=${capabilities}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Robot Framework:打开Chrome浏览器而不启动URL - Robot Framework: Open a chrome browser without launching URL 打开浏览器选项卡以执行机器人框架测试用例 - Open browser tabs to execute robot framework test case 机器人框架中的 chrome 选项 - chrome options in robot framework 如何在 Ubuntu 22.04 中使用 Robot Framework 进行自动化测试中选择 Google Chrome 或 Firefox 作为默认 Web 浏览器 - How to choose Google Chrome or Firefox as default web browser in Automation test using Robot Framework in Ubuntu 22.04 Robot Framework:如何在Robot Framework中使用用户创建的浏览器实例 - Robot Framework: How to use User created browser instance in Robot framework 有没有办法将 Chrome 扩展程序包含到自动 Chrome 浏览器中? - Is there a way to include Chrome extensions into automated Chrome browser? 机器人框架的SeleniumLibrary引发错误“ chromedriver.exe不是受支持的浏览器” - Robot Framework's SeleniumLibrary throws an error “chromedriver.exe is not a supported browser” 如何从机器人框架调用python方法 - How to call a python method from robot framework 如何打开带有扩展程序的brave浏览器? 硒,蟒蛇 - How to open brave browser with extensions? Selenium, Python 是否可以使用Pytest运行Robot Framework的单元测试? - Is it possible to run Robot Framework's unittests with Pytest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM