簡體   English   中英

無法使用 python 和 selenium 定位元素

[英]Unable to locate element with python and selenium

我想點擊表示下一步的按鈕,它是由“بعدی”寫的
在這個頁面
https://www.tgju.org/profile/price_dollar_rl/history
這是我的代碼

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("--headless")
browser= webdriver.Firefox(options=options, executable_path="geckodriver.exe")
browser.get('https://www.tgju.org/profile/price_dollar_rl/history');
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait(browser,20)
from selenium.webdriver.common.by import By
browser.find_element_by_xpath('//*[@id="DataTables_Table_0_next"]')

我得到這個錯誤
無法定位元素://*[@id="DataTables_Table_0_next"]
但我復制了確切的身份證件檢查
謝謝

您需要添加等待元素出現。 在此頁面上,它看起來像是動態加載的。

element = WebDriverWait(browser, 10).until(
        EC.presence_of_element_located((By.ID, "DataTables_Table_0_next"))
    )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM