I try to find a table row. First, I used Ranorex Spy, and try to use the following rXpath expression:
/dom[@domain='127.0.0.1']//table//td[@innertext='[email protected]']/../following-sibling::tr/.[1]
Ranorex Spy finds and highlights this tag successfully. But when I'm trying to find thiselement using Ranorex API, it returns no results. The code is following
// path is exactly rXpath expression which is used for Ranorex Spy
IList<Ranorex.Core.Element> elements = Host.Local.Find(path);
Can you tell me, where is my mistake or are there any issues with rXpath?
Actually it's not a solution, but a workaround.
The following XPath retrieves a specific entry from . And [1] is an index of a desired element
/dom[@domain='127.0.0.1']//table//td[@innertext='[email protected]']/../following-sibling::tr/.[1]
So, the idea is to obtain all elements as a collection, and to use element with an appropriate index.
String tableRowShortXpath = "/dom[@domain='127.0.0.1']//table//td[@innertext='[email protected]']/../following-sibling::tr";
IList<Ranorex.WebElement> elements = Ranorex.Host.Local.Find<Ranorex.WebElement>(tableRowShortXpath);
Ranorex.WebElement desiredElement = elements[rowIndex - 1];
For my purposes it's enough, though it works 2 times slower if the element was found with direct XPath query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With