0

I'm programming a boot that interacts with a google page (google meet) for this I'm using selenium webdriver, but when i run the code find_element in python it gives the following error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:

{"method":"xpath","selector":"/html/body/div[1]/div[3]/div/div[2]/div[3]/div/span/span"}

here is my code:

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

hora = 360
driver = selenium.webdriver.Chrome(r"C:\Users\adelson\Desktop\chromedriver")

def segunda():
    if now.hour == 21:
        os.startfile('link da reunião')
        sleep(20)
        my_button = driver.find_element_by_xpath("/html/body/div[1]/div[3]/div/div[2]/div[3]/div/span/span")
        my_button.click()
        sleep(hora)

while True:

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

#segunda
    if data.isoweekday() == 1:
        segunda()
    sleep(120)
5
  • You aren't calling driver.get() to load a page. Does Chrome load the page by default when it starts? Commented Oct 26, 2020 at 16:22
  • I agree with @JohnGordon, replace os.startfile('link da reunião') with driver.get(...) and post back with the results.
    – user5386938
    Commented Oct 26, 2020 at 16:24
  • @JustinEzequiel it worked, but it opens a chromedriver tab and for several reasons i need to open the normal chrome, is there any way i can do this? Commented Oct 26, 2020 at 17:05
  • "for several reasons i need to open the normal chrome" -- care to give an example? Selenium is for controlling an instance of the browser opened by the driver and not AFAIK for controlling an already running instance.
    – user5386938
    Commented Oct 26, 2020 at 18:14
  • See oreilly.com/library/view/selenium-essentials/9781784394332/… if perhaps you want to load a particular user's profile.
    – user5386938
    Commented Oct 26, 2020 at 18:18

1 Answer 1

0

clearly, the error states that it is not able to locate whichever element you're searching for. double-check the XPath you have is correct. you can inspect the element in the browser by right-clicking on it. and copy the full Xpath

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.