使用Python在Chrome Selenium中激活Flash
我将Selenium与Python结合使用,用于一些在线相机界面。问题是我似乎无法在Selenium的Chrome中激活Flash 我发现问题与我的问题相近,但没有一个解决方案有效: 我尝试的所有参数都没有改变任何东西,我得到的只是“get Flash Player”链接 这是我的密码:使用Python在Chrome Selenium中激活Flash,python,selenium,selenium-chromedriver,Python,Selenium,Selenium Chromedriver,我将Selenium与Python结合使用,用于一些在线相机界面。问题是我似乎无法在Selenium的Chrome中激活Flash 我发现问题与我的问题相近,但没有一个解决方案有效: 我尝试的所有参数都没有改变任何东西,我得到的只是“get Flash Player”链接 这是我的密码: chrome_options = Options() prefs = { "profile.default_content_setting_values.plugins" : "1", "profile.c
chrome_options = Options()
prefs = {
"profile.default_content_setting_values.plugins" : "1",
"profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-
player" : "1",
"PluginsAllowedForUrls": "ADRESS"
//The player is in a frame, I tried to pass both the host and the framed page
}
chrome_options.add_argument("--disable-web-security")
chrome_options.add_argument("--allow-running-insecure-content")
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
谢谢我找到了解决这个问题的方法。首先,您进入chrome中特定URL的设置页面。然后您必须按Tab键25次才能进入flash设置的下拉菜单。按空格键打开下拉列表,然后按“a”键移动到“允许”选项,即“a”是因为它没有使用箭头键 这可能不是最好的解决方案,但对我来说很有效
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("chrome://settings/content/siteDetails?site=https%3A%2F%2Fwww.YOUR-URL.com")
actions = ActionChains(driver)
actions = actions.send_keys(Keys.TAB * 25)
actions = actions.send_keys(Keys.SPACE)
actions = actions.send_keys("a")
actions = actions.send_keys(Keys.ENTER)
actions.perform()
这是一个非常简单的解决方案,我希望我的答案有用。谢谢,本
这个解决方案对我很有效,只是稍微调整了一下。请在下面找到我的解决方案
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome(executable_path="C:\\py\\selenium\\chrome\\chromedriver2.exe", options=options)
## Step one visit the site you want to activate flash player
driver.get("https://helpx.adobe.com/flash-player.html")
## Step 2 Once your page is loaded in chrome, go to the URL where lock sign is there visit the
##setting page where you will see that the flash is disabled.
## step 3 copy that link and paste below
driver.get("chrome://settings/content/siteDetails?site=https%3A%2F%2Fhelpx.adobe.com")
## below code is for you to reach to flash dialog box and change it to allow from block.
actions = ActionChains(driver)
actions = actions.send_keys(Keys.TAB * 12)
actions = actions.send_keys(Keys.SPACE)
actions = actions.send_keys("a")
actions = actions.send_keys(Keys.ENTER)
actions.perform()
## This Step will bring you back to your original page where you want to load the flash
driver.back()
关于检查这个讨论,这是我之前看到的讨论之一,我不知道我是否正确实现了这些,但它不会改变任何东西因为它是一个公共url,你能共享这个url吗?它不是一个公共url,抱歉