I have problem creating Selenium query to select specific element from list using XPath.
//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?
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
//li[normalize-space() = 'Addressing machine wholesaling']
will select your first
li element, as requested.