Can Protractor click the Adobe Flash Player Settings button?

My Protractor kit runs on a web server that uses Flash to capture the camera and microphone. Of course, the first time someone uses the app, Flash pops up a dialog box to ask permission to use the webcam and microphone.

The HTML for this dialog looks like this:

<div id="flash-container" class="">
<object width="247" height="159" id="flashRecorder" type="application/x-shockwave-flash" data="EIRecorderProcess.swf" style="visibility: visible;">
<param name="allowScriptAccess" value="always">
<param name="wmode" value="transparent">
</object>
</div>

      

And the dialog looks like this:

Flash permissions dialog

The protractor has hung up here because it doesn't seem to know how to press the Allow button and the app won't let you proceed until it does. Here's what I've tried:

  • I have visited the Flash security settings for my site to allow webapp access. But every time WebDriver starts, it creates a temporary profile in Chrome that is unaware of this security setting, so the settings window pops up anyway.

  • I have set up the Protractor config file to launch Chrome with the parameters 'use-fake-device-for-media-stream', 'use-fake-ui-for-media-stream', and "disable-bundled-ppapi-flash". The first two don't matter. The latter tears everything apart for real.

  • I tried using this:

    browser.actions()
    .mouseMove(element(by.css('object#flashRecorder')), x, y)
    .click()
    .perform();
    
          

    And even though I'm a fighter and I'm pretty sure I nailed the coordinate button (a specific javascript coordinate was used to test), nothing happened.

  • I used the Chrome flag "user-data-dir = / a / random / path" so that after first clicking "Allow" and "Remember", the security settings are stored and do not appear anymore. This is a current workaround, but creates additional overhead for any developers who want to run tests, and the programmer in me says it is not kosher for an automated test that requires human interaction.

Has anyone found another way to do this?

+3


source to share


1 answer


This is not a request for Chrome permission; it's Flash. So standard Chrome hackers (like --use-fake-ui-for-media-stream) don't work here.

I solved this problem by creating the required Flash permission file and uploading it to the appropriate directory so that Flash would be satisfied.

The required Flash permissions are stored in a file called "settings.sol" in a directory specific to the host you are accessing. This file is in AMF format and I am using the Python PyAMF library to create it. It works like this:

from pyamf import sol

object = sol.SOL ('www.hostname.com/settings')
object[u'allow'] = True
object[u'always'] = True
object[u'klimit'] = 100
sol.save (object, 'settings.sol')

      

Not specified "www.hostname.com" indicated in the title; it must be the hostname requesting permission.

Then you must upload this file to the correct directory that you may need to create, and this directory refers to the hostname.

Chrome has two directories; one for NPAPI Flash (old technology that is being dropped in Chrome 45) and one for Pepper Flash (new technology).

Old (NPAPI) Flash permissions are stored in a fixed location, and the directory path includes the hostname ("www.hostname.com" in the above example):



C:\Users\UserName\AppData\Roaming\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys\#www.hostname.com\settings.sol

      

The new (Pepper) Flash permissions are stored in the Chrome user directory, which, as you indicated, is generated by the WebDriver for each browser instance. WebDriver returns this directory to you in the 'userDataDir' key from the 'chrome' capabilities. Again in Python:

user_dir = my_driver.capabilities.get ('chrome').get ('userDataDir')

      

Then the settings.sol file must be placed in the following directory, which you must create:

[user_dir]\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\12345678\macromedia.com\support\flashplayer\sys\#www.hostname.com\settings.sol

      

Pay attention to '12345678' here. If you let Flash create a permissions file, a semi-random number will be used here. But since this is the user directory just created, and since we are creating almost the entire path, we can just make it.

Once you have created the appropriate settings.sol file and created the appropriate directory structure and loaded the settings.sol file to the correct location in that directory structure, then Flash will find that file that grants the permission and it will not ask any more.

+2


source







All Articles