繁体   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