我正在尝试模拟一个基于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}
我的环境设置:
也许有人知道如何使其适用于机器人框架?
答案 0 :(得分:0)
这就是我设法禁用它的方法(使用其他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}
我的环境设置:
答案 1 :(得分:0)
您的案例有点未经测试,但这是我在如何在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
)。