Selenium xPath - Locating element by partial text
<p>I have following HTML code of my Page.</p>

<pre><code>&lt;div class="views-field-wbapi-data-value-2014 wbapi-data-value wbapi-data-value-first"&gt;
    &lt;span class="field-content"&gt;
        &lt;span&gt;
            &lt;a href="http://data.worldbank.org/indicator/SP.POP.TOTL/countries/SC?display=graph"&gt;
                &lt;span class="human-readable"&gt;&lt;/span&gt;
            &lt;/a&gt;
</code></pre>

<p>And</p>

<pre><code>&lt;div class="views-field-wbapi-data-value-2014 wbapi-data-value wbapi-data-value-first"&gt;
    &lt;span class="field-content"&gt;
        &lt;span&gt;
            &lt;a href="http://data.worldbank.org/indicator/NY.GDP.MKTP.CD/countries/SC?display=graph"&gt;
                &lt;span class="human-readable"&gt;91,400&lt;/span&gt;
            &lt;/a&gt;
</code></pre>

<p>I have come up with the following xpath to locate <code>&lt;span class="human-readable"&gt;&lt;/span&gt;</code> of the first HTML code block.</p>

<pre><code>//div[@class='views-field-wbapi-data-value-2014 wbapi-data-value wbapi-data-value-first']/span/span/a/span
</code></pre>

<p>But when I run the above xpath, it gives me 2 matching nodes which is clear to me from the HTML code. There is a slight difference in href parameter of tag 'a'. The first code block contains "SP.POP.TOTL" and the second block contains "NY.GDP.MKTP.CD".</p>

<p>Is there any way I can access partial text of href parameter of 'a' tag and use it in my xpath to differentiate between the 2 blocks?</p>

<p><strong>Note: I cannot use the following xpath:
<code>//a[@href='http://data.worldbank.org/indicator/SP.POP.TOTL/countries/SC?display=graph']/span</code> because I am running a for loop on 40 different countries and every time text after '/countries/' , "SC" , changes. So I have to use partial text , independent of the country prefix.</strong></p>