Selenium在python中按类名查找元素 [英] Selenium Finding elements by class name in python

查看:44
本文介绍了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.

这篇关于Selenium在python中按类名查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆