Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

node.js - Unable to allow website camera and microphone access with Selenium ChromeDriver

I am trying to automate the process of joining a conference call but I'm running into issues with video and audio permissions. I want to allow selenium access to video and audio.

enter image description here

After searching online for a solution for over a day, here's what I've tried with zero success:

1.Using just setChromeOptions:

let driver = new Builder()
        .usingServer("http://127.0.0.1:4444/wd/hub/")
        .forBrowser("chrome")
        .setChromeOptions({
            "prefs": {
                "profile.default_content_setting_values.media_stream_mic": 1,
                "profile.default_content_setting_values.media_stream_camera": 1
            },
            "args": ["--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream"]
        })
        .build();

This doesn't seem to do anything. I'm not getting any error when I run this but it's not helping either.

  1. Using capabilites:
let driver = new Builder()
        .usingServer("http://127.0.0.1:4444/wd/hub/")
        .forBrowser("chrome")
        .withCapabilities({ "browserName": "Chrome", "chromeOptions": {
            "args": ["--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream"]
            }
        })
        .build();

Which gives me this error which I haven't been able to figure out how to resolve: enter image description here

I really need this to work and I can't seem to find a way. Any help is highly appreciated.

Node version: v15.5.1

question from:https://stackoverflow.com/questions/65897819/unable-to-allow-website-camera-and-microphone-access-with-selenium-chromedriver

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
prefs ={
    "hardware.audio_capture_enabled":True,
    "hardware.video_capture_enabled": True,
    "hardware.audio_capture_allowed_urls": ["https://www.omegle.com"],
    "hardware.video_capture_allowed_urls": ["https://www.omegle.com"]


}

options.add_experimental_option("prefs",prefs)

driver =webdriver.Chrome(options=options)
driver.get('https://www.omegle.com/')

THis is the settings in python so for node it would be :

let driver = new Builder()
        .usingServer("http://127.0.0.1:4444/wd/hub/")
        .forBrowser("chrome")
        .setChromeOptions({
            "prefs": {
                   "hardware.audio_capture_enabled":True,
                   "hardware.video_capture_enabled": True,
                   "hardware.audio_capture_allowed_urls": ["https://www.omegle.com"],
                   "hardware.video_capture_allowed_urls": ["https://www.omegle.com"]


},
            
        })
        .build();

Note: Change url with your website url


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...