首页 > 解决方案 > Selenium,Python - 试图点击 react-text 标签或点击它所属的类的第 n 次出现会导致错误“找不到元素”

问题描述

我试过了

driver.find_element_by_xpath('//span[@style="Text_in_style"]')

但没有这样的元素给出错误。我知道我想要的“list-group-item report-item”位置是 20 个中的第 13 个,所以我可以以某种方式获得第 13 个类名称“list-group-item report-item”吗?谢谢!

如您所见,两种跨度样式在下面具有完全相同的结构,只是跨度样式除外

标签: pythonseleniumtestingbeautifulsoupautomation

解决方案


buttons = driver.find_elements_by_xpath('//*[@class="list-group report-group-list"]')
buttons[3].click()

谢谢!谷歌


推荐阅读