 <p>You can use the <code>start-with</code> in xpath to locate an attribute value that starts with a certain text.</p> <p>For example, assume you have the following link on the page:</p> <pre><code>&lt;a href="mylink_somerandomstuff"&gt;link text&lt;/a&gt; </code></pre> <p>Then you can use the following xpath to find links that have an href that starts with 'mylink':</p> <pre><code>//a[starts-with(@href, "mylink")] </code></pre>