Search code examples
seleniumselenium-webdriverxpathselenium-chromedriverxpath-1.0

How to write xpath for li content for breadcrumb items


I want to write an xpath for verify the Custom Report text without index.

HTML:

<ol>
    <li>
        <a href="https://dumpy.url.com">Lw2_0702230135</a>
    </li>
    <li>
        <a href="https://dumpy.url.com">Report</a>
    </li>
    <li>
        Custom Report
    </li>
</ol>

Solution

  • You can use the following xpath:

    //ol/li[contains(text(), "Custom Report")]