I’m writing a Python script using Selenium to log into Google as a user and join a Google Meet. The goal is for this bot to turn on the screen recording option. Everything works fine until the point where it tries to click the “More options” button. No matter what variant I try for targeting the “More options” button, the click never works, and it always throws an empty exception.
Here is my function to enable recording:
def enableRecording(driver):
# Click the "More options" button
try:
time.sleep(2)
# Open more options
more_options_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable(
(By.XPATH, '//button[@aria-label="More options"] | //div[@class="VfPpkd-Bz112c-Jh9lGc"] | //div[@class="VfPpkd-Bz112c-J1Ukfc-LhBDec"] | //div[@class="M5zXed"]')
)
)
more_options_button.click()
print("Clicked 'More options' button")
except Exception as e:
print(f"Error clicking 'More options': {e}")
driver.save_screenshot('error_more_options_screenshot.png')
...
I’ve tried various XPath expressions to locate the “More options” button but none of them work. Below are the XPath expressions I have tried:
//button[@aria-label=”More options”]
//div[@class=”VfPpkd-Bz112c-Jh9lGc”]
//div[@class=”VfPpkd-Bz112c-J1Ukfc-LhBDec”]
//div[@class=”M5zXed”]
Despite these efforts, the click never registers and the exception is always empty. I’m also taking a screenshot for debugging but it hasn’t been very helpful.
How can I reliably click the “More options” button in a Google Meet using Selenium?
Additional Information:
I’m using ChromeDriver with the latest version of Chrome.
I’ve ensured that the element is within the viewport and is not hidden.
Any advice or solutions on how to resolve this issue would be greatly appreciated!