I have problem creating Selenium query to select specific element from list using XPath.
I've tried //li[contains(text(), 'Addressing machine wholesaling')]
but seems I need to merge inner spans somehow. Is there any way to do this?
Here is the example of list. I need to select first li
element at this case.
<ul aria-labelledby="businessActivitySuggestionsProbableHeader1" class="anzsicList probable">
<li activity="55" index="0" role="option" class="">
<span class="matchText">Addressing</span>
<span class="matchText">machine</span>
<span class="matchText">wholesaling</span>
</li>
<li activity="4554" index="1" role="option" class="">
<span class="matchText">Machine</span> manufacturing (including accounting,
<span class="matchText">addressing</span>, business, enveloping, letter folding, numbering, photocopying or duplicating)
</li>
</ul>
If it's impossible maybe there other way to do that rather then using XPath?
CodePudding user response:
This XPath,
//li[normalize-space() = 'Addressing machine wholesaling']
will select your first li
element, as requested.