How do I make Python click a button in google?

Asked

Viewed 418 times

1

I’m making a bot that enters google Meet at scheduled times, got the part of opening the meetings at the desired times, but I bumped into the problem that the program needs to click the "enter" button is I don’t know how do I do it, my most recent attempt was with Selenium but when I run this error appears on the console: Attributeerror: module 'Selenium.webdriver.Chrome' has no attribute 'find_elements_by_xpath'

if you can suggest a way to make a click that is simpler than Selenium is also valid

import os
from datetime import date
from datetime import datetime
from time import sleep
from selenium import webdriver

hora = 3600
driver = webdriver.chrome

def segunda():
    if now.hour == 16:
        os.startfile('link da reunião')
        sleep(10)
        driver.find_elements_by_xpath("/html/body/div[1]/c-wiz/div/div/div[5]/div[3]/div/div/div[2]/div/div[1]/div[2]/div/div[2]/div/div[1]/div[1]/span/span").click()
        sleep(hora)

while True:
    
    now = datetime.now()
    data = date(now.year, now.month, now.day)

#segunda
    if data.isoweekday() == 1:
        segunda()

1 answer

-1


Hello, you are doing well. To click on a button you must locate it using by: xpath, id, class or tag and then use the method .click().

1 - geckodriver

my_button = drive.find_element_by_id("my-button")
my_button.click()

2 - edited

Error in your code

# Preste mais atencao

drive = webdrive.chrome  # errado
drive = webdrive.Chrome()  # certo

Another way to search for an element. Although not the focus of the question...

from selenium.webdriver.common.by import By

# resto do seu código

my_button = drive.find_element(By.ID, "my-button")
my_button.click()

You can use the form you think best to find the element as id, xpath, tag name, class and css selector.

Read the documentation in more detail!!!

Thanks for the downvotes :)

  • the find element method of the following error: module 'Selenium.webdriver.Chrome' has no attribute 'find_element_by_id'

  • His question was "how to click a button" and that’s what I tried to answer. I added more details...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.