【问题标题】:Webdriver.io enable flash for selenium-standaloneWebdriver.io 为 selenium-standalone 启用 flash
【发布时间】:2017-07-15 22:33:58
【问题描述】:

我正在使用 webdriver.ioselenium 独立服务器 和最新的 Google Chrome 驱动程序在 node.js 上编写验收测试

我需要检查 Flash 元素是否可点击,但浏览器一直显示“重新启动 Chrome 以启用 Adob​​e Flash Player”。

我已经看到 article 展示了如何让 Chrome 驱动程序在本地计算机上查看自定义配置文件,但我不明白如何在我的独立服务器上使用它,因为它的配置很差 examples。 您能否解释在 webdriver.io 中为 selenium 独立服务器启用 Adob​​e Flash 播放器的正确方法?

【问题讨论】:

  • 请参阅:How do I do X? SO 的期望是,提出问题的用户不仅会进行研究以回答他们自己的问题,还会分享该研究、代码尝试和结果。这表明您已经花时间尝试帮助自己,它使我们免于重复明显的答案,最重要的是它可以帮助您获得更具体和相关的答案!另见:How to Ask

标签: google-chrome selenium flash webdriver-io


【解决方案1】:

我发现以下方法有效:

browserName: 'chrome',
 'goog:chromeOptions' : {
            args: ['enable-features=RunAllFlashInAllowMode',
                   'disable-features=EnableEphemeralFlashPermission'],
            prefs: {
                "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player": 1,
                'PluginsAllowedForUrls': '/route/to/site.com'
            }
        }

使用临时模式将创建一个允许首选项生效的临时配置文件:

https://developer.chrome.com/extensions/contentSettings https://support.google.com/chrome/a/answer/3538894?hl=en

'goog:chromeOptions' 是从 selenium 3.8 github.com/elgalu/docker-selenium/issues/201 开始引入的——

您可以打开作为 JSON blob 的配置文件并查看添加到 profile.content_settings.exceptions.plugins 和 profile.content_settings.exceptions.flash_data 的站点。

【讨论】:

    【解决方案2】:

    这很容易。您需要创建一个自定义配置文件,您将始终使用它来加载您的 chrome。然后你像手动一样配置浏览器。这意味着为 Flash 制作网站排除项。加载一些扩展或任何你想要预配置的东西。使用此代码,您可以做到

    // setup browser
    var options = {
    desiredCapabilities: {
    browserName: 'chrome',
    chromeOptions: {
    args: ['user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Profile 21v69',
    '--lang=en']
    } //  chromeOptions: {
    } // desiredCapabilities: {
    } // options = {
    
    
    
    var client = webdriverio.remote(options).init();
    

    这里还有 chrome 的所有命令行命令 https://peter.sh/experiments/chromium-command-line-switches/

    【讨论】:

      【解决方案3】:

      另一种可行的方法。可以在 chrome 配置中允许执行 flash 插件 您需要在 wdio.conf.js 中添加代码示例中的最后三个首选项

      chromeOptions : {
              args: chromeArgs,
              prefs: {
                  "download.default_directory": process.env.PWD +'/download',
                  "profile.default_content_setting_values.plugins": 1,
                  "profile.content_settings.plugin_whitelist.adobe-flash-player": 1,
                  "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player": 1
              }
          }
      

      希望对你有帮助

      【讨论】:

        猜你喜欢
        • 2016-04-20
        • 2019-06-27
        • 1970-01-01
        • 2023-01-03
        • 2016-07-13
        • 1970-01-01
        • 2018-08-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多