Can't choose an element in the span

Hi, a have this code on the site and I need to chose 4th element.

< span class=“mat-option-text”>text1< /span>
< span class=“mat-option-text”>text2< /span>
< span class=“mat-option-text”>text3< /span>
< span class=“mat-option-text”>text4< /span>

I try to use //span[@class=‘mat-option-text’][4] but it always choose 1th element.
How can I choose 4th?

If you can post the url is more simple to detect the xpath

Try in this mode



Thanks a lot! It’s really work!

1 Like