我正在尝试找到一个要单击的元素。我可以使用 DevTools 从浏览器中找到该元素,但使用 Selenium 时会遇到错误,找不到元素。
我的代码:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver=webdriver.Chrome()
driver.implicitly_wait(2)
driver.get("https://www.fsmone.com.my/funds/tools/factsheet/aham-bond-fund?fund=MYAFCAPF")
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH,"//div\[@id='content'\]")))
element=driver.find_element(By.XPATH, "//span\[text()='Latest NAV Price '\]")
element.click()
它返回以下错误
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[text()='Latest NAV Price ']"}