使用Selenium时,我无法单击/查找Google Meet中的元素

问题描述

参加会议:

from time import sleep

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("prefs",{
    "profile.default_content_setting_values.media_stream_mic": 1,"profile.default_content_setting_values.media_stream_camera": 1,"profile.default_content_setting_values.geolocation": 2,"profile.default_content_setting_values.notifications": 2
})
chrome_options.add_argument("--disable-infobars")
driver = webdriver.Chrome(r'../Other Projects/chromedriver.exe',options=chrome_options)
febxp = driver.find_element_by_xpath


def Rmunify():
    # Goes to Rmunify
    driver.get('https://sts.platform.rmunify.com/Account/SignIn?ReturnUrl=%252fissue%252fwsfed%252fwww%253fwa%253dwsignin1.0%2526wtrealm%253dhttp%25253a%25252f%25252flaunchpad.platform.rmunify.com%25252frp%2526wctx%253drm%25253d0%252526id%25253dpassive%252526ru%25253d%2525252f%2526wct%253d2020-10-20T13%25253a09%25253a46Z%2526wreply%253dhttps%25253a%25252f%25252fwww.rmunify.com%25252f')
    # Types email
    febxp("/html/body/div[2]/div/div[2]/div[1]/div/form/div[1]/div[2]/input").send_keys("")
    # Types password
    febxp("/html/body/div[2]/div/div[2]/div[1]/div/form/div[1]/div[3]/div/input").send_keys("")
    # Presses Sign In
    febxp("/html/body/div[2]/div/div[2]/div[1]/div/form/div[3]/input").click()
    driver.implicitly_wait(1)
    # Goes to classroom main page
    driver.get("https://classroom.google.com/a/chace.enfield.sch.uk")
    driver.implicitly_wait(1)
    # Presses Verify
febxp("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button").click()
    driver.implicitly_wait(1)
    # Select the class
    input("Press once class is selected: ")
    febxp("/html/body/div[2]/div[2]/div[1]/div/div[2]/div[2]/div/span/a").click()
    driver.implicitly_wait(1)


def Main():
    # Turns mic off
    # febxp(
    #     "/html/body/div[1]/c-wiz/div/div/div[5]/div[3]/div/div/div[2]/div/div/div[1]/div/div[3]/div[1]/div/div/div").click()
    # # Turns Camera off
    # febxp(
    #     "/html/body/div[1]/c-wiz/div/div/div[5]/div[3]/div/div/div[2]/div/div/div[1]/div/div[3]/div[2]/div/div").click()
    # # Joins call
    # febxp(
    #     "/html/body/div[1]/c-wiz/div/div/div[5]/div[3]/div/div/div[2]/div/div/div[2]/div/div[2]/div/div/div[1]").click()
    driver.implicitly_wait(1)
    # Go to main part to say goodbye
    while True:
        try:
            Choice = input("What to do? (G,C): ")
            elif Choice.lower() == "c":
                # Goes to chat
                febxp("/html/body/div[1]/c-wiz/div[1]/div/div[5]/div[3]/div[3]/div/div[2]/div[2]/div[1]/div[1]").click()

出现问题的地方:

                # Goes to chat
                febxp("/html/body/div[1]/c-wiz/div[1]/div/div[5]/div[3]/div[3]/div/div[2]/div[2]/div[1]/div[1]").click()

并给出错误

    febxp("/html/body/div[1]/c-wiz/div[1]/div/div[5]/div[3]/div[6]/div[3]/div/div[2]/div[1]").click()
  File "C:\Users\Diaboli Sica\AppData\Local\Programs\Python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py",line 394,in find_element_by_xpath
    return self.find_element(by=By.XPATH,value=xpath)
  File "C:\Users\Diaboli Sica\AppData\Local\Programs\Python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py",line 978,in find_element
    'value': value})['value']
  File "C:\Users\Diaboli Sica\AppData\Local\Programs\Python\python37\lib\site-packages\selenium\webdriver\remote\webdriver.py",line 321,in execute
    self.error_handler.check_response(response)
  File "C:\Users\Diaboli Sica\AppData\Local\Programs\Python\python37\lib\site-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":"/html/body/div[1]/c-wiz/div[1]/div/div[5]/div[3]/div[6]/div[3]/div/div[2]/div[1]"}
  (Session info: chrome=86.0.4240.111)

问题: 我使用硒来参加Google聚会。它要求输入,当我按Enter时,应该按聊天按钮。但是它给出了错误消息,即使我在那里可以看到它也找不到它。我尝试了所有可能的方法。我试图寻找课程,寻找标签,一切。有时它会找到一个元素(我不知道它是否是正确的1),但是无法单击它……我尝试查找并单击其他元素,但还是一无所获。它只会在我去Google Meet时发生,甚至在加入课程之前我都无法按下静音按钮。

其他信息:

  • 该按钮为div,但具有“ role ='button'”,其余为span和div。
  • 随机的XPATH捆绑在一起是为了尝试不同的方式来查找按钮。\ n
  • 我尝试使用XPATH,类似// something [@ something =''],类名,标记名,但没有用。\ n
  • 我已经检查了iframe,但是我很确定它没有使用iframe。

检查元素图像:

检查元素XPATH:

  • /html/body/div[1]/c-wiz/div[1]/div/div[5]/div[3]/div[6]/div[3]/div/div[2]/div[1]

检查元素HTML:

  • <div jsshadow="" role="button" class="uArJ5e UQuaGc kCyAyd QU4Gid foXzLb IeuGXd M9Bg4d" jscontroller="VXdfxd" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue;touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc(preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd;focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef" jsname="VyLmyb" aria-label="Show everyone" aria-disabled="false" tabindex="0" data-tooltip="Show everyone" aria-expanded="false" data-tab-id="1" data-tooltip-vertical-offset="-12" data-tooltip-horizontal-offset="0"><div class="Fvio9d MbhUzd" jsname="ksKsZd"></div><div class="e19J0b CeoRYc"></div><span jsslot="" class="l4V7wb Fxmcue"><span class="NPEfkd RveJvd snByac"><div class="ZaI3hb"><div class="gV3Svc"><span class="DPvwYc sm8sCf azXnTb" aria-hidden="true"><svg focusable="false" width="24" height="24" viewBox="0 0 24 24" class="Hdh4hc cIGbvc NMm5M"><path d="M15 8c0-1.42-.5-2.73-1.33-3.76.42-.14.86-.24 1.33-.24 2.21 0 4 1.79 4 4s-1.79 4-4 4c-.43 0-.84-.09-1.23-.21-.03-.01-.06-.02-.1-.03A5.98 5.98 0 0 0 15 8zm1.66 5.13C18.03 14.06 19 15.32 19 17v3h4v-3c0-2.18-3.58-3.47-6.34-3.87zM9 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 9c-2.7 0-5.8 1.29-6 2.01V18h12v-1c-.2-.71-3.3-2-6-2M9 4c2.21 0 4 1.79 4 4s-1.79 4-4 4-4-1.79-4-4 1.79-4 4-4zm0 9c2.67 0 8 1.34 8 4v3H1v-3c0-2.66 5.33-4 8-4z"></path></svg></span><span jscontroller="FTBAv" jsaction="rcuQ6b:npT2md;L6tSXb:B6c1Fe" class="wnPUne N0PJ8e">7</span></div></div></span></span></div>

检查元素选择器

  • #ow3 > div.T4LgNb > div > div:nth-child(5) > div.crqnQb > div.pHsCke > div.Jrb8ue > div > div.NzPR9b > div.uArJ5e.UQuaGc.kCyAyd.QU4Gid.foXzLb.IeuGXd.M9Bg4d

我整天都在努力,找不到其他解决方案。

解决方法

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

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

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

相关问答

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