发布时间:2022-06-06 09:57:38 人气:266 作者:多测师
python中可以使用selenium库来获取ul下有多少li。
selenium 是一套完整的web应用程序测试系统,包含了测试的录制(selenium IDE),编写及运行(Selenium Remote Control)和测试的并行处理(Selenium Grid)。
示例:
from selenium import webdriver
chrome = webdriver.Chrome()
chrome.get('https://www.bilibili.com')
ul = chrome.find_element_by_xpath('//*[@id="primary_menu"]/ul')
lis = ul.find_elements_by_xpath('li')
len(lis) # 有多少个li
lis[-1].text # 最后一个li
lis[-1].click()
以上内容为大家介绍了Python怎么查看ul下有多少li?希望对大家有所帮助,如果想要了解更多Python相关知识,请关注多测师。https://www.e70w.com/xwzx/