Get Text from Span returns empty string
<p>I'm trying to get the text from the span inside this div with python and selenium:</p>

<pre><code>&lt;div class="product-name"&gt;
    &lt;span class="h1" itemprop="name"&gt;TEXT&lt;/span&gt;
&lt;/div&gt;
</code></pre>

<p>I've tried this, however, this returns an empty string:</p>

<pre><code>line = dr.find_element_by_class_name('product-name').find_element_by_xpath('.//span').text
</code></pre>

<p>Thanks in advance,</p>

<p>I find bs4 more intuitive, prehaps this would suite better? </p>

<pre><code>    from bs4 import BeautifulSoup as bs4


def main():
    html = """&lt;div class="product-name"&gt;
            &lt;span class="h1" itemprop="name"&gt;TEXT&lt;/span&gt;
            &lt;/div&gt;"""
    soup = bs4(html, "html.parser")
    print(soup.find_all('div', {"class": "product-name"}))


if __name__ == '__main__':
    main()
</code></pre>

<p>Concerning your code.. </p>

<pre><code>line = dr.find_element_by_class_name('product-name').find_element_by_xpath('.//span').text
</code></pre>

<p>Maybe supposed to be something more inline with:</p>

<pre><code>line = dr.find_element_by_classname('product-name')
</code></pre>

<p>Might remember wrong. </p>

python selenium web-scraping phantomjs