运行 使用机器人框架进行测试时,在 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}
我的环境设置:
- Google Chrome 52.0.2743.116
- 机器人框架 3.0
- Selenium2Library 1.7.4
- Chrome驱动程序 2.23.409687
也许有人知道如何让它与机器人框架一起工作吗?
这就是我设法禁用它的方法(使用其他 Whosebug 答案中建议的丑陋技术)。
*** 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(二十二)x64 位
- Python 2.7.10
- Google Chrome 52.0.2743.116
- 机器人框架 3.0
- Selenium2 库 1.8.0b2
- 硒 2.53.6
- Chrome驱动程序 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
)。
我正在尝试模拟一个基于 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}
我的环境设置:
- Google Chrome 52.0.2743.116
- 机器人框架 3.0
- Selenium2Library 1.7.4
- Chrome驱动程序 2.23.409687
也许有人知道如何让它与机器人框架一起工作吗?
这就是我设法禁用它的方法(使用其他 Whosebug 答案中建议的丑陋技术)。
*** 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(二十二)x64 位
- Python 2.7.10
- Google Chrome 52.0.2743.116
- 机器人框架 3.0
- Selenium2 库 1.8.0b2
- 硒 2.53.6
- Chrome驱动程序 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
)。