0

我正在为此编写一个与谷歌页面(谷歌见面)交互的引导我正在使用 selenium webdriver,但是当我find_element在 python 中运行代码时,它给出了以下错误:

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"}

这是我的代码:

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

1 回答 1

0

显然,错误表明它无法找到您正在搜索的任何元素。仔细检查您拥有的 XPath 是否正确。您可以通过右键单击浏览器中的元素来检查它。并复制完整的 Xpath

于 2020-10-26T16:25:47.597 回答