【发布时间】:2021-09-23 20:14:51
【问题描述】:
我正在尝试自动化一个在我的测试中运行良好的消息传递网站,但现在浏览器不断要求我阻止或允许麦克风。解决办法是什么?我请求你的帮助!
注意:通过我的代码,它开始通过麦克风捕获音频,但我不想录制音频,但我必须接受此站点的麦克风。
这是我在 python 中为此自动化创建的__init__
def __init__(self):
#init declara o driver para ser acessado no self, acessar o programa todo
chrome_options = Options()
#caminho do chromium
try:
chrome_options.binary_location = dir_absolutle + '\\chrome-win' + '\\chrome.exe'
except:
chrome_options.binary_location = os.getcwd() + '\\chrome-win' + '\\chrome.exe'
#chrome_options.add_argument("--headless")
#chrome_options.add_argument("--disable-infobars")
#chrome_options.add_argument("--disable-extensions")
#chrome_options.add_argument("disable-media-stream")
#chrome_options.add_argument("allow-file-access-from-files")
#usar som ou video falso
#chrome_options.add_argument("use-fake-device-for-media-stream")
#chrome_options.add_argument("use-fake-ui-for-media-stream")
# Pass the argument 1 to allow and 2 to block
chrome_options.add_experimental_option("prefs",{\
"profile.default_content_setting_values.media_stream_mic" : 2})
chrome_options.add_argument('--ignore-certificate-errors-spki-list')
#chrome_options.add_argument("--unlimited-storage")
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.add_argument('--lang=pt-BR')
chrome_options.add_argument('--disable-notifications')
chrome_options.add_argument('--disable-gpu')
#chrome_options.add_experimental_option("excludeSwitches", ["disable-popup-blocking"])
args = ["hide_console", ]
#caps = webdriver.DesiredCapabilities.CHROME.copy()
#caps['acceptInsecureCerts'] = True
try:
caminho_chromedriver = dir_absolutle + '\\chromedriver.exe'
except:
caminho_chromedriver = os.getcwd() + '\\chromedriver.exe'
#caminho_chromedriver = r'C:\Users\Daniel pc\Desktop\whatsappcdb\chromedriver.exe'
self.driver = webdriver.Chrome(executable_path=caminho_chromedriver,options=chrome_options, service_args=args)
self.wait = WebDriverWait( #aqui a variavel self.wait está recebendo o webdriverwait com as caracteristicas
driver=self.driver,
timeout= 10,
poll_frequency=6
)
pass
如果我取消选中
#chrome_options.add_argument("use-fake-device-for-media-stream")
#chrome_options.add_argument("use-fake-ui-for-media-stream")
它将开始录制音频,我不希望它开始录制。如何不初始化此录音?
谢谢
【问题讨论】:
标签: python selenium selenium-chromedriver sendmessage