2

I have been using a web app in chrome (a meeting client) which makes use of webRTC (Need mic and camera access) while trying to use locally installed chrome browser for executing tests.

Chrome instance triggered by Testcafe is not allowing the access of mic and camera. Is there a way to pass chrome capabilities as we do for Selenium and Protractor?

There are some alternatives for browserstack plugins provided however we are looking at implementing it for the locally installed browser where we can enable the mic and camera access.

Workaround tried: Tired to feed fake media stream using chrome browser related arguments such as --use-fake-ui-for-media-stream --use-fake-device-for-media-stream. (Unsuccessful)

Test Code:

import {Selector, t} from 'testcafe';

fixture(`Test Page`)
    .page('XXXXXXXXXXXXXX');

test('Validating Sanity of WebApp', async t => {
    await t
    .click(Selector('#create_meeting_btn1'));
});

Command line trigger code:

testcafe chrome test.js

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Bharadwaj Pendyala
  • 324
  • 1
  • 3
  • 16

1 Answers1

2

Chrome doesn't allow calling the getUserMedia API from insecure origins. You need to run TestCafe over HTTPS. See the step-by-step instruction in this comment as mentioned below.

  1. Specify localhost as the hostname when starting TestCafe:

    testcafe --hostname localhost ...
    
  2. Obtain a valid SSL certificate or register a self-signed certificate as a valid in your operating system and enable HTTPS mode in TestCafe:

    testcafe --ssl pfx=/path/to/cert.pfx ...
    

I've tried the following example and it worked for me with --hostname localhost:

fixture `WebRTC`
    .page`https://webrtc.github.io/samples/src/content/getusermedia/canvas/`;

test(`test`, async t => t.wait(30000));
Toby Speight
  • 27,591
  • 48
  • 66
  • 103
mlosev
  • 5,130
  • 1
  • 19
  • 31
  • Thank you @mlosev, I wasn't sure about ssl config while I was reading through the same conversation in GitHub before. I gave it a try after you commente, this works prefectly. – Bharadwaj Pendyala Oct 17 '19 at 10:13
  • see the executable example [here](https://github.com/DevExpress/testcafe-examples/tree/master/detached-examples/mock-camera-microphone-access) – mlosev Oct 12 '20 at 09:37