flash - 在 saucelabs/selenium webdriver 中禁用 flash?

标签 flash selenium python-2.7 selenium-webdriver saucelabs

我正在尝试使用 saucelabs 自动截取多个站点的屏幕截图,以确保更改代码不会破坏内容。我正在使用 webdriver for python 进行编程,需要在 chrome、firefox 和 IE 上禁用 flash。我试图在网上找到答案,但似乎没有一个是关于禁用闪光灯的,只是与闪光灯对象交互。

最佳答案

下面的代码适用于 chrome,它会禁用 flash 并将默认下载目录设置为不同的文件夹。

from selenium.webdriver.chrome.options import Options   
def _disable_flash_caps(self):
      chromeOptions = Options()
      # prefs = {"download.default_directory" : "C:\\temp", "profile.managed_default_content_settings.plugins": 2}
      prefs = {"download.default_directory" : "C:\\temp", "plugins.plugins_disabled": ["Adobe Flash Player"] }
      chromeOptions.add_experimental_option("prefs",prefs)
      return chromeOptions.to_capabilities()

调用它:

if 'browserName' in cap and cap['browserName'] == 'chrome':
   webdriver.Remote.__init__(self, sel_url, self._disable_flash_caps())

关于flash - 在 saucelabs/selenium webdriver 中禁用 flash?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17113477/

相关文章:

javascript - 在两个不相关的 Web 应用程序之间拖放

php - AS3 中的日期格式

performance - 在 Selenium Framework 中以编程方式检索页面权重

python - 如何使用 matplotlib 循环绘制图像列表?

flash - 动态音频生成 Actionscript 3

javascript - 通过颜色框内的 AS3 外部接口(interface)调用 javascript

c# - 需要帮助使用 Selenium webdriver 获取 WebElement 的完整内部文本

javascript - 如何在 Visual Studio Code 中调试单个 Nightwatch JS 测试

python - Pyhook 在按 6 次后停止捕获按键事件

python - 为什么有些 .xlsx 文件可以用 openpyxl 成功打开,而有些则打不开?