Python + Selenium:如何单击所有<a> with same XPath

时间:2018-06-27 08:22:48

标签: python selenium

In Python and Selenium, I want to click all the a tag with the same XPath and same title. But I don't think so there is any way to click all the a tag one by one.

If you have any suggestion please help me.

1 个答案:

答案 0 :(得分:0)

尝试一下:

import time

# locate all elements
elements = driver.find_elements_by_xpath("xPath_to_elements")

for x in range(0, len(elements)):
    elements[x].click() # click on every element
    time.sleep(1) # small pause between clicks