我有一个文档,可以使用selenium/python命令driver.find_element_by_partial_link_text
找到一个或两个链接。不管是最后一个还是最后两个,我都要返回。在
有办法吗?在
也就是说,页面有时有文本链接stackoverflow.com/xxxxxxx以及stackoverflow.com/iwantthislink. 其他时候只是stackoverflow.com/iwantthislink. 在
当我使用driver.find_element_by_partial_link_text("stackoverflow.com/")
时,它返回stackoverflow.com/xxxxxxx因为它早就来了stackoverflow.com/iwantthislink. 在
我只需要一种方法来始终返回列表中的最后一个元素。在
find_elements_by_partial_link_text
返回一个列表。(注意elements
与element
。)要访问最后一个元素,请执行以下操作:
更好的是,事先测试元素的存在:
^{pr2}$相关问题 更多 >
编程相关推荐