How to bypass the Flash and Microphone Access popup when using Pepper / PPAPI Flash in Chrome (via Selenium)?
Chrome supports two flavors of Flash: NPAPI and PPAPI (Pepper). These two implementations seem to handle camera and microphone resolutions differently. In particular, PPAPI (Pepper) doesn't seem to honor any of the previous permissions.
When using NPAPI, which is the default the first time a Flash site is accessed and asks for permission to use a computer camera and microphone, an Adobe Flash pop-up window asks the user to grant or deny access. I grant access and this grant is remembered. The next time I go to this site, the permission will be granted automatically, no popup.
When I want to test with PPAPI (Pepper) Flash, I specify the command line arguments "--enable-bundled-ppapi-flash" and "--disable-npapi" for Chrome. In this mode, previous grants are ignored and a popup is displayed every time. I didn't understand how to detect this in Selenium and click "Allow".
Does anyone know how to bypass this popup by either clicking Allow or disabling it entirely?
Update: . I found that non-Pepper Flash stores the camera / microphone permissions in a file called "settings.sol" stored in a directory specific to the site requesting access. For example, on Windows, when a host in 22.214.171.124 requests access, the following file is created:
C: \ Users [user] \ AppData \ Roaming \ Macromedia \ Flash Player \ macromedia.com \ support \ flashplayer \ sys # 126.96.36.199 \ settings.sol
Notice the gap in "Flash Player". This file is a local shared object encoded as AMF. I am using the python package pyamf to create a file that provides persistent access to the site:
from pyamf import sol permissions = sol.SOL ('188.8.131.52/settings') permissions[u'always'] = True permissions[u'allow'] = True permissions[u'klimit'] = 100 sol.save (permissions, 'my-settings.sol')
When I copy it to the appropriate directory, access is automatically granted. But again, this doesn't work for Pepper Flash.
Pepper Flash ignores this directory and instead gets a new temporary directory for each Chrome instance:
C: \ Users [user] \ AppData \ Local \ Temp \ scoped_dir5976_6686 \ Default \ Pepper Data \ Shockwave Flash \ WritableRoot # SharedObje karats \ 6DMDJWLP \ macromedia.com \ support \ Flashplayer \ Sys # 184.108.40.206 \ settings.sol
Unfortunately, the directory changes on every call. If I could somehow find out the name of this directory, I could download the file before requesting access.
But I don't know how to find out the name of this directory.
source to share
It turns out my problem was specific to Selenium and how I was using Selenium.
First, back to NPAPI Flash, which stores its Windows permissions in a subdirectory under the user's directory; eg:
Pepper Flash does not use this directory for its permissions, and thus does not implement the settings stored there. Instead, it stores its permission files in a subdirectory under the Chrome user data directory.
When I instantiated the Chrome browser via Selenium, a temporary user data directory was created for the session. For example:
Pepper Flash kept its permission files under this directory, but when the browser session ended, this temporary directory was deleted and the settings were forgotten.
The solution is simple: when launching Chrome through Selenium, specify the Chrome user data directory using the command line argument:
Pepper Flash will store its permissions in this directory, and since it is a permanent directory that is not deleted when the browser session ends, it will be available to the next instance and thus the permissions granted will be preserved.
source to share
On linux, the directory seems to be application specific. Chrome browser seems to store them in
Qt WebEngine programs seem to save them in
I needed to delete the directory to remove the permanent webcam permission (which I gave the site for testing).
source to share