vohratom
vohratom

Reputation: 492

Xpath of weird A element with text in the quotation marks

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..

Upvotes: 0

Views: 1037

Answers (1)

Forensic_07
Forensic_07

Reputation: 1135

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.

Upvotes: 2

Related Questions