问题
I am working on robot framework where in i am not able to allow chrome camera allow popup from the browser. Please help on this or code will help a lot.
回答1:
Need to create webdriver with preferences which allows microphone (--use-fake-ui-for-media-stream)
Similar question solution is explained here how to handle web based alert or pop ups in robot framework?
Java or python related solution explained here How do i allow Chrome to use my microphone programatically?
Snippet:
Chrome With Preferences
${chrome_options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
&{SiteOptions} Create Dictionary last_used=${1470931206} setting=${1}
&{media_stream_mic} Create Dictionary https://www.google.nl:443,*=${SiteOptions}
${prefs} Create Dictionary profile.content_settings.exceptions.media_stream_mic=${media_stream_mic}
Call Method ${chrome_options} add_experimental_option prefs ${prefs}
Create WebDriver Chrome chrome_options=${chrome_options}
回答2:
Below is the sample code -
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${chrome_options} add_argument --use-fake-ui-for-media-stream
Call Method ${chrome_options} add_argument --use-fake-device-for-media-stream
Create Webdriver Chrome alias=tab1 chrome_options=${chrome_options}
来源:https://stackoverflow.com/questions/53500111/how-to-access-microphonecamera-in-robot-framework