python - selenium 未启用 chrome 69 上的 Flash

标签 python selenium google-chrome flash selenium-chromedriver

在 google chrome 更新到版本 69 后,之前编写的用于在 python 上使用 selenium 启用 flash 的代码无法正常工作。如果有人找到了它的解决方案,请帮助我和社区

options = Options()
prefs = {
    "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,
    "PluginsAllowedForUrls": "URL"
}
options.add_experimental_option("prefs",prefs)

browser = webdriver.Chrome(options=options)

最佳答案

将此参数添加到 chrome_options。

chrome_options.add_argument("--disable-features=EnableEphemeralFlashPermission")

在我的代码中:

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-features=EnableEphemeralFlashPermission")

chrome_prefs = {"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,
                "PluginsAllowedForUrls": "BEST URL EVER"}

chrome_options.add_experimental_option("prefs",chrome_prefs)

driver = webdriver.Chrome(chrome_options=chrome_options, service_log_path='NUL')

关于python - selenium 未启用 chrome 69 上的 Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52251595/

相关文章:

python - 使用线程并行运行子进程

c# - WebDriverWait 没有在等待我指定的元素

html - 带有波斯字体的谷歌浏览器未确定的行为;有些部分显示为正方形

javascript - 着色器编译错误

python - 你应该如何读取二维整数数组?

python - 通过 google colab 安装 python 3.7 作为默认 python

python - 从python中的.eml文件解析excel附件

java - 如何在单个浏览器中运行多个 UI 测试?

c# - Selenium:在for循环中使用错误的元素

javascript - 需要帮助编写 Google Chrome 扩展程序(初学者)