'Safaridriver not support select audio/ video device

Problem In Mac OS, when use Safaridriver open a Safari browser for WebRTC samples, the audio input source only display Mock device (audio: Mock audio device 1/ Mock audio device 2 , video: Mock video device 1/ Mock video device 2) but not display Mac OS physical or Virtual audio/video device . Safaridriver control Safari browser actually result : enter image description here

Except result : enter image description here

Research

  1. Manually open Safari browser , user can set Use Mock Capture Devices (Safari browser->Develop->WebRTC→Use Mock Capture Devices). enter image description here

  2. If enable Use Mock Capture Devices , thin-client meeting or WebRTC samples can reproduce above problem .Debug WebRTC samples source code , navigator.mediaDevices.getUserMedia get device return Mock device . enter image description here

  3. From safaridriver readMe, no configure can set Use Mock Capture Devices , because WebDrier test not support live media capture "For security reasons, Safari does not permit live media capture during a WebDriver test session. Instead, mock capture devices and streams with well-known contents are provided for testing purposes. " (In Mac OS , cd/Library/Apple/System/Library/CoreServices/SafariSupport.bundle/Contents/MacOS , man safaridriver)

  4. From safaridriver debug log, safaridriver not provide any configure for SafaridirverLog


2022/04/02 10:45:35:854  HTTPServer: --> HTTP 200
2022/04/02 10:45:35:855  HTTPServer: --> {"value":{"sessionId":"DC112ED7-A4DC-42B6-B545-673CBF3C0737","capabilities":{"safari:platformVersion":"12.2.1","safari:automaticInspection":false,"webkit:WebRTC":{"DisableICECandidateFiltering":false,"DisableInsecureMediaCapture":false},"browserVersion":"15.3","strictFileInteractability":false,"browserName":"Safari","safari:useSimulator":false,"safari:automaticProfiling":false,"setWindowRect":true,"acceptInsecureCerts":false,"safari:platformBuildVersion":"21D62","safari:diagnose":true,"platformName":"macOS"}}}
  1. From selenium-safari-driver-4.1.3 (The latest release), no configure for Use Mock Capture Devices

Reproduce demo SafariDriverDebug.java

import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.safari.SafariOptions;
 
import org.openqa.selenium.WebDriver;
public class SafariDriverDebug {
public static void main(String[] args) throws  Exception{
    SafariOptions options = new SafariOptions();
    options.setCapability("safari:diagnose", "true");
    //options.setCapability("safari:automaticProfiling", "true");
    WebDriver driver = new SafariDriver(options);
    // Launch Website
    driver.navigate().to("https://webrtc.github.io/samples/src/content/devices/input-output/");
    Thread.sleep(3000);
    // Close the Browser
    driver.close();
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source