In HTML documents, id is unique in the document but class is not, so if there are multiple identical class names in the document, you may need to turn the result of find_elements_by_class_name () (element with s) .. For example, if including an attribute makes it unique, you can use get_attribute () to get the attribute, and if you think it, do what you want to do (such as clicking) (below). See code). If not, I think you have to think about how to make it unique in the document. I think that the xpath and css selectors that can be obtained with the development tool of the browser are unique because they are unique.
elems = driver.find_elements_by_class_name("name of the class(*1)") # *1:適切なname of the classを指定してください。
for elem in elems:
attr = elem.get_attribute("Attribute name(*2)") # *2:適切なAttribute nameを指定してください。
if (attr == "Attribute value that you think matches"):
elem.click()
Recommended Posts