Selenium Finding elements by class name in python

Sree picture Sree · May 2, 2015 · Viewed 129.4k times · Source

How can I filter elements which having a same class?

<html>
 <body>
  <p class="content">Link1.</p>
</body>
<html>
<html>
 <body>
  <p class="content">Link2.</p>
</body>
<html>

Answer

LittlePanda picture LittlePanda · May 4, 2015

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.