繁体   English   中英

使用机器人框架运行测试时,在Chrome上禁用Flash插件

[英]Disable Flash Plugin on chrome when running test with robot framework

我正在尝试模拟一个测试,该测试将基于vjs播放器播放视频,因此我需要禁用Flash插件才能使其正常工作(默认播放器为jwplayer)。 以下是我的部分代码(作为关键字),对我来说仍然无效:

*** Keywords ***
Open Chrome Without Flash
  [Arguments]         ${url}
  ${options}=         Evaluate                  sys.modules['selenium.webdriver'].ChromeOptions()     sys, selenium.webdriver
  ${profile}=         Create Dictionary         plugins.plugins_disabled=Adobe Flash Player
  Call Method         ${options}    add_experimental_option    prefs    ${profile}
  Create Webdriver    Chrome                    chrome_options=${options}
  Go To               ${url}

我的环境设置:

  • 谷歌浏览器52.0.2743.116
  • 机器人框架3.0
  • Selenium2Library 1.7.4
  • Chromedriver 2.23.409687

也许有人知道如何使其与机器人框架一起工作?

这就是我设法禁用它的方式(使用其他StackOverflow答案中建议的丑陋技术)。

*** Settings ***
Documentation     Test disabling Flash Plugin in Chrome
Library           Selenium2Library    15.0    5.0

*** Test Cases ***
    Open Chrome And Disable Flash    https://www.adobe.com/devnet/video/articles/fmp_player/_jcr_content/articlecontentAdobe/videomodal_0.content.html

*** Keywords ***
Open Chrome And Disable Flash
    [Arguments]    ${url}
    Open Browser    about://plugins    Chrome
    Wait Until Page Contains    Plug-ins
    ${myElement}=    Get Web Element    xpath=//div[2]/div[2]/div[2]/table/tbody/tr/td/div[1]/div[1]/span[.='Adobe Flash Player']/../../../div[contains(@class,'plugin-actions')]/span/a[contains(@class,'disable-group-link')]
    Click Element    ${myElement}
    Go To    ${url}

我的环境设置:

  • Linux-Fedora版本22(二十二)x64bit
  • Python 2.7.10
  • 谷歌浏览器52.0.2743.116
  • 机器人框架3.0
  • Selenium2Library 1.8.0b2
  • 硒2.53.6
  • Chromedriver 2.22.397932

尚未针对您的情况进行测试,但这是我如何禁用Chrome中的插件的结果:

*** Test Cases ***
Open Chrome
  Set Options
  Goto  ${SOME_URL}

*** Keywords ***
Set Options
  ${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
  ${disabled}=  Create List  Adobe Flash Player
  ${preferences}=  Create Dictionary  plugins.plugins_disabled=${disabled}
  Call Method  ${options}  add_experimental_option  prefs  ${preferences}
  Create WebDriver  Chrome  chrome_options=${options}

您可能需要验证Flash插件的名称(上述代码中的Adobe Flash Player )。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM