I would like to automatically grant access to video and audio in Chrome via Chromedriver capabilities.
Based on this (pretty old) answer I tried the following:
Faced similar issue, solved with this:
ChromeOptions options = new ChromeOptions();
options.addArguments("--use-fake-ui-for-media-stream=1");
driver = new ChromeDriver(options);
You can also change default camera using this method:
Map prefs = new HashMap();
prefs.put("media.default_video_capture_Device", "\\\\?\\root#media#0002#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global");
options.setExperimentalOption("prefs", prefs);
Camera code could be obtained from settings window (inspect with dev tools) or from preferences file in Chrome directory.