目的用li标签的value或文本来定位选中li。
测试中报错div和ul中无法使用select。
不知道用什么来选。
用循环遍历判断吧,或者用filter()
比如下面代码:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://www.baidu.com/')
time.sleep(5)
a = driver.find_elements_by_xpath(r'//*[@id="s-top-left"]/a')
d = list(filter(lambda x: x.text=='视频', a))[0]
d.click()
time.sleep(7)