如何使用Selenium和Python在https://meet.google.com上单击“要求加入”按钮?

问题描述

我正在尝试使用我现有的Google Chrome个人资料在Google Meet链接中单击“要求加入”按钮。这是代码:

options = webdriver.ChromeOptions()
options.add_argument(r"--user-data-dir=C:\\Users\\Pranil.DESKTOP-TLQKP4G.000\\AppData\\Local\\Google\\Chrome\\User Data")
browser = webdriver.Chrome(ChromeDriverManager().install(),options=options)
delay = 15
browser.get('https://meet.google.com/tws-kcie-aox')
ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,)
time.sleep(5)
join_butt = WebDriverWait(browser,delay,ignored_exceptions=ignored_exceptions).until(EC.presence_of_element_located((By.XPATH,'//*[@id="yDmH0d"]/c-wiz/div/div/div[5]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div')))
join_butt.click()
print(join_butt.text)#this prints Ask to join

但是未单击加入按钮。按钮上最奇怪的“要求加入”文本确实显示在最后一行。这意味着硒已到达正确的按钮。但是为什么不点击按钮呢?

编辑: 根据@Alin Stelian的回答,我将代码更新如下:

browser.get('https://meet.google.com/hst-cfck-kee')
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'd')
join_butt = WebDriverWait(browser,delay).until(EC.presence_of_element_located((By.XPATH,"//span[contains(text(),'Ask to join')]")))
join_butt.click()
print(join_butt)
print(join_butt.text)

这确实有效,因为两个打印语句都可以工作...但是未单击按钮。这是怎么了?

解决方法

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

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

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