0

I am trying to get the element by xPath but the text is in the quotation marks and xPath does not work..

Any ideas?

Code when opened as HTML:

<li class="help-menu-item-486 active">
<a href="javascript:void(0)" id="menuItemLink486">
<i id="id31" style="display:none" data-wicket-placeholder=""></i>
Archiv dokumentů
</a>
</li>

Code in the console: enter image description here

Thank you in advance!

I even tried to add % so %Archiv% - but still no luck..

vohratom
  • 422
  • 7
  • 16

1 Answers1

2

As noted in the linked answer above, contains() takes a single string as a first argument, but text() is a selector that returns a set of text nodes. Since contains() can't take a set, it evaluates against the first node in the set, which isn't actually the \nArchiv dokumentů\n text, but a single newline character between the a and i tags, so it doesn't match.

You can use //a[contains(., "Archiv")] to evaluate a as a string, which will use all the text in the a tag.

Forensic_07
  • 1,125
  • 1
  • 6
  • 10
  • Hi Forensic_07 thank you! This is working! I am now a bit more experienced with xpaths thanks to you :-) – vohratom May 11 '21 at 08:34