I cant click/find elements in Google Meet when using Selenium

1.1k Views Asked by At

Getting to Meeting:

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()

Where the problem occours:

                # 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()

And gives the error:

    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)

Problem: I use selenium to join a google meet. it asks for input and when I press enter it should press the chat button. but it gives the error saying it can't find the element even though I can see it there and then. I have tried every method possible. I tried looking for the class, looking for tags, everything. sometimes it would find an element (I don't know if it was the right 1) but can't click it... I have tried looking and clicking on other elements and still nothing. it only happens as soon as I go to google meet, I can't even press the mute button before joining the class.

Extra Info:

  • The button is a div but has "role='button'", the rest are spans and divs.
  • The random XPATHs bunched together were to try different ways to find the button.\n
  • I have tried using XPATHs, stuff like //something[@something=''], class names, tag names but none work.\n
  • I have checked for iframes but I am pretty sure it does not use an iframe.

Inspect element image:

Inspect element XPATH:

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

Inspect element 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>

Inspect element selector

  • #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

I have been trying all day and could not find a solution to anything else.

0

There are 0 best solutions below