Search code examples
seleniumselenium-webdriverxpathrobotframework

Get text From xpath under li and class?


I have this xpath: I want to get the number circled in the red --> see the attached image , which is the total number of pages , I did the following

[![enter image description here][1]][1]
<li class="small-screen" xpath="1">1 / 5>/li>

${actual_pages_nb}    Get Text    xpath://li[@class='small-screen']

but the returned text is null , i wanna get 5


Solution

  • but the returned text is null , i wanna get 5

    This means that the keyword was executed without errors, so it found an element with that locator, but probably not the one you need.

    The keywords return the first found element, unless you explicitly indicate the index you need.

    You must find a better locator (and better to confirm with the browser developer tool, the existing o several elements with that locator).