My Protractor suite is running on a webapp that uses Flash to capture camera and microphone. Of course, the first time anyone uses the app, Flash pops up a dialog box to ask for permission to use the webcam and mic.
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 box itself looks like this:
Protractor gets hung here, because it doesn't seem to know how to click the "Allow" button and the app won't let it continue until it does. Here's what I've tried:
I visited my site-specific Flash security settings to allow access for the webapp. But every time WebDriver runs, it creates a temporary profile on Chrome, which doesn't know about those security settings, so the Settings box pops up anyway.
I set up the Protractor config file to run Chrome with the options 'use-fake-device-for-media-stream', 'use-fake-ui-for-media-stream', and 'disable-bundled-ppapi-flash'. The first two don't make a difference. The last one breaks everything for real.
I tried using this:
browser.actions() .mouseMove(element(by.css('object#flashRecorder')), x, y) .click() .perform();
And even though I'm a crack-shot and I'm pretty sure I nailed the button's coordinates (used some javascript coordinate tracing to be sure), nothing happened.
I used the Chrome flag "user-data-dir=/a/random/path" so that after the first time hitting the dialog and clicking "Allow" and "Remember", the security settings are stored and it doesn't pop up any more. This is the current workaround, but creates some extra overhead for any devs who want to run the tests, and the programmer in me says it isn't kosher for an automated test to require human interaction.
Has anyone found another way to do this?
--use-fake-ui-for-media-stream
argument should do the trick. Can you show how have you passed it to chrome? Thanks. – alecxecapabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['--use-fake-ui-for-media-stream'] }, }
– alecxe--
before, just wanted to check. Good to know. – alecxe