Selenium在python中按类名查找元素
问题描述
如何过滤具有相同类的元素?
How can I filter elements that have the same class?
<html>
<body>
<p class="content">Link1.</p>
</body>
</html>
<html>
<body>
<p class="content">Link2.</p>
</body>
</html>
解决方案
你可以尝试使用 find_elements_by_class_name:
You can try to get the list of all elements with class = "content"
by using find_elements_by_class_name:
a = driver.find_elements_by_class_name("content")
然后您可以点击您要查找的链接.
Then you can click on the link that you are looking for.
相关文章