Issue
I'm trying to automate a messaging site that was working fine in my tests, but now the browser keeps asking me to block or allow the microphone. What is the solution? I ask for your help!
note: by my code it starts capturing audio through the microphone, but i don't want to record audio, but i have to accept the microphone for this site.
Here's the __init__
I created for this automation in python
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
if i uncheck
#chrome_options.add_argument("use-fake-device-for-media-stream")
#chrome_options.add_argument("use-fake-ui-for-media-stream")
it will start recording audio, I don't want it to start recording. How do I not initialize this recording?
Thanks
Solution
You could save the cookie from the website with pickle
import pickle
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
And adding them back would be
import pickle
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
Answered By - gxzs
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.