Selenium text not working
<p>I have this span tag:</p>

<pre><code>&lt;span class="pricefield" data-usd="11000"&gt;$11,000&lt;/span&gt;
</code></pre>

<p>And I want to get the text for it (<code>$11,000</code>). Naturally I should be using <code>text</code> like so:</p>

<pre><code># empty
print self.selenium.find_element_by_css_selector(".pricefield").text
</code></pre>

<p>But it prints nothing.</p>

<p>This doesn't work either:</p>

<pre><code># None
print self.selenium.find_element_by_css_selector(".pricefield").get_attribute("text")
# None
print self.selenium.find_element_by_css_selector(".pricefield").get_attribute("value")
</code></pre>

<p>However, I can get the elements attributes just fine:</p>

<pre><code># 11000
print self.selenium.find_element_by_css_selector(".pricefield").get_attribute("data-usd")
</code></pre>

<p>Why doesn't this work? Did something change in Selenium? I am using 2.52.0.</p>

<p><code>get_attribute("textContent")</code> or <code>get_attribute("innerText")</code> are the attributes you are looking for.</p>

python selenium