1

When I try to open a page with flash using an automated python script with Selenium I reach the page in the picture below. And I cannot pass.

Flash Activation Page

It's a remote server running Ubuntu 16.04, without access to a monitor or a keyboard/mouse.

Python version: 3.5.2

Selenium version: 3.14.1

Geckodriver 0.26.0

Follows my code:

import pyvirtualdisplay
print ("pyvirtualdisplay Display Version: %s" % (pyvirtualdisplay.__version__))
from selenium import webdriver
print ("Selenium webdriver Version: %s" % (webdriver.__version__))

display = pyvirtualdisplay.Display(visible=0, size=(800, 600))
display.start()

profile = webdriver.FirefoxProfile()
profile.native_events_enabled = False
profile.set_preference("plugin.state.flash", 2)
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
driver = webdriver.Firefox(profile)
driver.set_page_load_timeout(60)
url = 'https://www.ultrasounds.com/US.html'
driver.get(url)

driver.close()
driver.quit()
display.stop()
quit()

Here's the output:

Python 3.5.2 (default, Apr 16 2020, 17:47:17)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvirtualdisplay
>>> print ("pyvirtualdisplay Display Version: %s" % (pyvirtualdisplay.__version__))
pyvirtualdisplay Display Version: 0.2.4
>>> from selenium import webdriver
>>> print ("Selenium webdriver Version: %s" % (webdriver.__version__))
Selenium webdriver Version: 3.14.1
>>>
>>> display = pyvirtualdisplay.Display(visible=0, size=(800, 600))
>>> display.start()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] oserror=None return_code=None stdout="None" stderr="None" timeout_happened=False>
>>>
>>> profile = webdriver.FirefoxProfile()
>>> profile.native_events_enabled = False
>>> profile.set_preference("plugin.state.flash", 2)
>>> profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
>>> driver = webdriver.Firefox(profile)

>>> driver.set_page_load_timeout(60)
>>> url = 'https://www.ultrasounds.com/US.html'
>>> driver.get(url)
>>>
>>>
>>> import pyautogui
>>> im1 = pyautogui.screenshot('flash_activation_page.jpg')
>>> driver.close()
>>> driver.quit()
>>> display.stop()
<Display cmd_param=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] cmd=['Xvfb', '-br', '-nolisten', 'tcp', '-screen', '0', '800x600x24', ':1001'] oserror=None return_code=0 stdout="" stderr="" timeout_happened=False>
>>>
4

1 回答 1

1

使用Firefox>= 69,您将无法做到这一点:

在 Firefox 69 中删除了始终激活 Adob​​e Flash 插件的设置。有关详细信息,请参阅此兼容性文档


Flash Player 不再总是被激活

发布时间:2019 年 6 月 15 日

类别:插件

发布:火狐 69

描述

作为正在进行的Flash 插件支持弃用的一部分,Firefox 69 已从页面通知对话框中删除了“始终激活”选项,并从附加组件管理器中删除了“记住此决定”选项。这意味着,从现在开始,Firefox 将在每次浏览器会话期间询问用户是否要在网站上显示 Flash 内容,并且用户将无法更改此行为。

在撰写本文时,根据Firefox 公开数据报告,只有一半的 Firefox 用户安装了 Flash Player ,而且这个数字还在稳步下降。鉴于 2020 年 Firefox 和其他浏览器将取消对 Flash 的支持,如果您的网站仍然依赖包括旧版视频播放器在内的任何 Flash 内容,我们强烈建议您尽快制定迁移计划。

于 2020-05-26T01:17:21.537 回答