2

I am in stuck and cannot allow using camera and microphone in WebDriver:

enter image description here

How can I handle this by WebDriver? I did not find any helpful info on the Internet related to this.

Thanks in advance.

PS: How can I close the microphone/camera popup in Python / Selenium? -- is not solving my case (I don't need "fake").

Ratmir Asanov
  • 5,889
  • 5
  • 24
  • 38

1 Answers1

4

You can allow/block the different contents though the preferences:

from selenium import webdriver


options = webdriver.ChromeOptions()
options.add_argument("--disable-infobars")
options.add_argument("--window-size=800,600")

options.add_experimental_option("prefs", { \
    "profile.default_content_setting_values.media_stream_mic": 1,     # 1:allow, 2:block 
    "profile.default_content_setting_values.media_stream_camera": 1,  # 1:allow, 2:block 
    "profile.default_content_setting_values.geolocation": 1,          # 1:allow, 2:block 
    "profile.default_content_setting_values.notifications": 1         # 1:allow, 2:block 
  })

driver = webdriver.Chrome(chrome_options=options)
Ratmir Asanov
  • 5,889
  • 5
  • 24
  • 38
Florent B.
  • 39,675
  • 6
  • 77
  • 97