Accept permission request in chrome using selenium

后端 未结 8 1817
旧巷少年郎
旧巷少年郎 2020-12-10 06:37

I have a HTML/Javascript file with google\'s web speech api and I\'m doing testing using selenium, however everytime I enter the site the browser requests permission to use

8条回答
  •  半阙折子戏
    2020-12-10 07:04

    So I just ran into another question asking about disabling a different prompt box. It seems there may be a way for you to accomplish your goal.

    This page lists options for starting chrome. One of the options is

    --disable-user-media-security
    

    "Disables some security measures when accessing user media devices like webcams and microphones, especially on non-HTTPS pages"

    So maybe this will work for you:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    chrome_options.add_argument("--disable-user-media-security=true")
    
    driver = webdriver.Chrome(executable_path="path/to/chromedriver", chrome_options=chrome_options)
    

提交回复
热议问题