Reputation: 23
I'm using Selenium with Python for some camera interface online. The problem is that I can't seem to get Flash activated in Selenium's Chrome.
I find problems close to mine but none of the solutions worked : https://sqa.stackexchange.com/questions/30312/enable-flash-player-on-chrome-62-while-running-selenium-test
None of the parameters I tried changed anything, all I get is the "Get Flash Player" link
Here's my code :
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)
Thank you
Upvotes: 2
Views: 4573
Reputation: 493
Thanks, Ben,
the solution worked for me with slightly tweaking. kindly find my solution below.
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()
Regards
Upvotes: 2
Reputation: 2195
I've found a workaround for this problem. First you go to the settings page for the specific URL in chrome. Then you have to press the Tab-Key 25 times to get to the dropdown menu for the flash setting. Press Space to open the dropdown and then press "a" to move to the option "allow", that "a" is because it hasn't worked with the Arrow Keys.
It might not be the nicest solution, but it works for me.
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()
It's a really simple solution, I hope my answer is useful.
Upvotes: 8