How to find elements without using the tag attribute?
问题 image = driver.find_elements_by_xpath("//img[contains(@class,'ui_qtext')]") copy = driver.find_elements_by_xpath("//p[contains(@class,'ui_qtext')]") I have this two elements with different tag_names. How do i locate them without the tag_name? Or how do i "combine" this two? Both have the same class_name. 回答1: To remove the dependency on the tagNames you can use either of the following Locator Strategies: Using xpath : image_copy = driver.find_elements_by_xpath("//*[contains(@class,'ui_qtext')