1

前往会议:

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)

问题: 我使用 selenium 加入 google meet。它要求输入,当我按下回车键时,它应该按下聊天按钮。但它给出的错误是它找不到元素,即使我可以在那里看到它。我已经尝试了所有可能的方法。我试着寻找班级,寻找标签,一切。有时它会找到一个元素(我不知道它是否是正确的 1)但无法单击它...我尝试查找并单击其他元素,但仍然没有。它只会在我去 google meet 时发生,我什至不能在加入课程之前按下静音按钮。

额外信息:

  • 该按钮是一个 div,但具有“role='button'”,其余的是跨度和 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

我整天都在尝试,找不到其他任何解决方案。

4

0 回答 0