enter image description here

As on the image I have to click on the 6th item on the list. I can easily do this with IList<IWebElement> But is there any way to do the same thing with the help of 2005256 digit which is available end of the div tag?


3 Answers 3


You can use a CSS Selector looking for a substring at the onclick attribute:


This will look for the client regardless of the position. If you want by position:

#searchpanel-clientlist li:nth-of-type(6)
  • Wow.This is working soo smooth.
    – ChathuD
    Mar 14, 2019 at 7:48
  • :) Grateful in helping Mar 14, 2019 at 8:00

I think the CSS Selector is the best solution, but you could also loop through all the row elements and get the onclick attribute text with element.GetAttribute("onclick"). This should the full onclick string and now you can use your programming language to find if it contains the number and use elements that match.

  • Thanks Niels,But still im confused on how to use this on my code.Will it be possible to show me the exact way?
    – ChathuD
    Mar 13, 2019 at 17:52

Try the below Xpath and share your feedback

(//div[@class='row client - selection row'])[5]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.