title: How to extract the text content from multiple span elements using Selenium and Python
body: <p>How to select text content from multiple DIV elements using selenium?</p>
  <p>On the website I intend to collect information it contains div and span with the same class.</p>
  <p>How can I collect this information separately?</p>
  <p>I need the contents inside the panel-body div &gt; span of each block</p>
  <pre><code>driver.find_element_by_xpath(&quot;.//div[@class='panel-body'][1]/span[1]&quot;).text
  driver.find_element_by_xpath(&quot;.//div[@class='panel-body'][1]/span[2]&quot;).text
  driver.find_element_by_xpath(&quot;.//div[@class='panel-body'][1]/span[3]&quot;).text
  
  driver.find_element_by_xpath(&quot;.//div[@class='panel-body'][2]/span[1]&quot;).text
  driver.find_element_by_xpath(&quot;.//div[@class='panel-body'][2]/span[2]&quot;).text
  </code></pre>
  <p>html
  </p>
  <pre><code>        &lt;div class=&quot;panel-heading&quot;&gt;
              &lt;h3 class=&quot;panel-title&quot;&gt;Identificação&lt;/h3&gt;
          &lt;/div&gt;
  
  
          &lt;div class=&quot;panel-body&quot;&gt;
              &lt;span class=&quot;spanValorVerde&quot;&gt;TEXT&lt;/span&gt;&lt;br&gt;
              &lt;span style=&quot;font-size:small;color:gray&quot;&gt;TEXT&lt;/span&gt;&lt;br&gt;
              &lt;br&gt;
              &lt;span class=&quot;spanValorVerde&quot;&gt;TEXT&lt;/span&gt;
          &lt;/div&gt;
  
  
      &lt;/div&gt;
  
      &lt;div class=&quot;panel panel-success&quot;&gt;
  
      
          &lt;div class=&quot;panel-heading&quot;&gt;
              &lt;h3 class=&quot;panel-title&quot;&gt;Situação Atual&lt;/h3&gt;
          &lt;/div&gt;
  
  
          &lt;div class=&quot;panel-body&quot;&gt;
              &lt;span class=&quot;spanValorVerde&quot;&gt;TEXT&lt;/span&gt; &lt;br&gt;
              &lt;span class=&quot;spanValorVerde&quot;&gt;TEXT&lt;/span&gt;
          &lt;/div&gt;
  
  
      &lt;/div&gt;
  </code></pre>