自动加入谷歌会议

问题描述

我正在使用这个自动加入 google meet 的代码。一切正常,但是当即将加入时,有一个弹出窗口说:“允许会议使用摄像头和麦克风。”有一个关闭按钮,我想抓住它并单击它,然后继续执行其余的代码。我试了好几次都没有用。所以问题是:我怎样才能让它工作?

代码是:

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&ltmpl=default&ltmplcache=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")

看来我现在已经解决了这个问题,但我有这个错误

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)

    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...