I was working with this code that automatically joins google meets. Everything works perfectly, but when it is about to join, there is a pop-up that says: "allow meet to use camera and microphone." There is a dismiss button, and I want to grasp that and click it, then proceed to the rest of the code. I have tried several times and it did not work.So the question is: how can I make it work?
The code is:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import datetime
import time
import signal
# Code will stop executing after 720 seconds == 10 mins.
signal.alarm(720)
now = datetime.datetime.now()
current_time = now.strftime("%H:%M / %A")
# %A is to get the name of the Day!
justtime = now.strftime("%H:%M")
print (current_time)
# Code to allow access for Microphone, Camera and notifications
# 0 is disable and 1 is allow.
opt = Options()
opt.add_argument("--disable-infobars")
opt.add_argument("start-maximized")
opt.add_argument("--disable-extensions")
# Pass the argument 1 to allow and 2 to block
opt.add_experimental_option("prefs", {
"profile.default_content_setting_values.media_stream_mic": 2,
"profile.default_content_setting_values.media_stream_camera": 2,
"profile.default_content_setting_values.geolocation": 2,
"profile.default_content_setting_values.notifications": 2
})
# Conditions to check time and append if necessary
while justtime != "09:50" or justtime != "13:50" or justtime != "15:20" or justtime != "16:50":
time.sleep(20)
now = datetime.datetime.now()
current_time = now.strftime("%H:%M / %A")
justtime = now.strftime("%H:%M")
print(justtime)
if justtime == "00:22" or justtime == "13:50" or justtime == "15:20" or justtime == "16:50":
print("Class is going to start in 10 Minutes.")
break
# directing to the link to be visited; The program first logs into gmail for all around access of google services.
def gmail_login():
driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1#identifier")
time.sleep(4)
driver.find_element_by_xpath("//input[@name='identifier']").send_keys("enter email here")
time.sleep(2)
# Next Button:
driver.find_element_by_xpath("//*[@id='identifierNext']/div/button/div[2]").click()
time.sleep(5)
#Password:
driver.find_element_by_xpath("//input[@name='password']").send_keys("password here")
time.sleep(2)
#next button:
driver.find_element_by_xpath("//*[@id='passwordNext']/div/button").click()
time.sleep(5)
# #opening Meet:
driver.get(sub)
driver.refresh()
time.sleep(5)
# Turning off video
driver.find_element_by_xpath("//*[@id='yDmH0d']/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[1]/div[1]/div[3]/div[2]/div/div").click()
time.sleep(5)
# turning off audio
driver.find_element_by_xpath("//*[@id='yDmH0d']/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[1]/div[1]/div[3]/div[1]/div/div/div").click()
time.sleep(180)
# Join class
driver.find_element_by_xpath("//*[@id='yDmH0d']/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span").click()
# Conditions which checks the time and goes to the classlink if Classes are happening at that time.
# Math
if current_time == "00:21 / Saturday" or current_time == "22:55 / Tuesday" or current_time == "13:50 / Thursday" or current_time == "15:20 / Friday":
#sub is the class id with the meet link. sub changes with the time accoriding to the class.
sub = "https://meet.google.com/qro-shex-qbh"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
#you will need to change the executable_path=r'chromedriver' to the path where you have downloaded the chromedriver or any browerdrive. I used chromium for the test.
gmail_login()
# Physics
elif current_time == "13:50 / Monday" or current_time == "16:50 / Wednesday":
sub = " ###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
# Nepali
elif current_time == "15:20 / Monday" or current_time == "16:50 / Thursday" :
sub = "###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
#Chemistry 1
elif current_time == "16:50 / Monday" or current_time == "15:20 / Wednesday":
sub = "###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
#Chemistry 2
elif current_time == "13:52 / Tuesday" or current_time == "16:50 / Friday":
sub = "###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
# English
elif current_time == "15:20 / Tuesday" or current_time == "13:50 / Friday":
sub = "###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
# Physics 2
elif current_time == "13:50 / Wednesday" or current_time == "15:20 / Thursday":
sub = "###hangouts meet links here with time variations###"
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver')
gmail_login()
else:
print("No classes right now")
it seems that I have fixed this issue now,but i have this error:
I fixed this problem now. Now I have a problem that when I join, it automatically disconnects. and shows this error:
Traceback (most recent call last):
File "/home/Music/auto/Google-Meet-automation-with-Python/main.py", line 82, in <module>
gmail_login()
File "/home/Music/auto/Google-Meet-automation-with-Python/main.py", line 72, in gmail_login
driver.find_element_by_xpath("//*[@id='yDmH0d']/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span").click()
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='yDmH0d']/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span"}
(Session info: chrome=88.0.4324.96)
question from:
https://stackoverflow.com/questions/65853028/automatically-joining-google-meetings 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…