Using Selenium in Python to click through all elements with the same class name

二次信任 提交于 2019-12-03 09:39:18

This is unfortunate, you got two halves of the whole, you cannot find multiple elements by id as ID is unique to a single element.

so combine the iterative method you use with id and the find by elements with classes to get:

like = browser.find_elements_by_class_name('like_picto_unselected')
for x in range(0,len(like)):
    if like[x].is_displayed():
        like[x].click()

I strongly suspect this will work for you. Please tell me if not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!