0

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>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
músic a
  • 1
  • 2

2 Answers2

0

Given the 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>

To identify the element with text Custom Report you can use the following xpath based locator strategy:

//ol/li[last()]

Code (Python):

element = driver.find_element(By.XPATH, "//ol/li[last()]")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

You can use the following xpath:

//ol/li[contains(text(), "Custom Report")]
risahbhc32
  • 135
  • 2
  • 12