pythongoogle-chromeselenium-webdriverselenium-chromedriver

Python Selenium How to set the specific microphone device in different Chrome


I want to set the specific microphone device in different Chrome, e.g. Chrome A using "Microphone A", Chrome B using "Microphone B". I know the Firefox can doing this using

profile.set_preference("media.default.audio_capture", "Microphone A")

However, I cannot find any information of this in Chrome. How to make it in Chrome using Python Selenium

I tried to using this but not working



prefs = {

    "profile.default_content_setting_values.media_stream_mic": 1,


"mediaDevices.defaultAudioInput": "Microphone A" 

}

Solution

  • prefs = {
    
    "profile.default_content_setting_values.media_stream_mic": 1,
    "media.default_audio_capture_device": "Device ID" 
    }
    

    Device ID can be found on Chrome setting using Dev tool. In my case, the microphone A is

    {0.0.1.00000000}.{6c057a49-4423-4c97-8806-f51e62014e85} Write the code like this:

     prefs = {
    
    "profile.default_content_setting_values.media_stream_mic": 1,
    "media.default_audio_capture_device": "{0.0.1.00000000}.{6c057a49-4423-4c97-8806-f51e62014e85}" 
    }