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?
-
Xpath with Element's attribute might help stackoverflow.com/questions/45177646/…– Toan Tran VanMar 12, 2019 at 7:36
3 Answers
You can use a CSS Selector looking for a substring at the onclick attribute:
div[onclick*='2005256']
This will look for the client regardless of the position. If you want by position:
#searchpanel-clientlist li:nth-of-type(6)
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?– ChathuDMar 13, 2019 at 17:52
Try the below Xpath and share your feedback
(//div[@class='row client - selection row'])[5]