我试着找一排桌子。首先,我使用了Ranorex,并尝试使用以下rXpath表达式:
/dom[@domain='127.0.0.1']//table//td[@innertext='john.doe@acme.com']/../following-sibling::tr/.[1]Ranorex Spy成功地找到并高亮显示了此标记。但是,当我试图使用Ranorex找到这个元素时,它不会返回任何结果。代码如下
// path is exactly rXpath expression which is used for Ranorex Spy
IList<Ranorex.Core.Element> elements = Host.Local.Find(path);你能告诉我,我的错误在哪里,或者rXpath有什么问题吗?
发布于 2014-05-06 13:07:44
实际上这不是一个解决方案,而是一个解决办法。
下面的XPath检索特定的条目。1是所需元素的索引。
/dom[@domain='127.0.0.1']//table//td[@innertext='john.doe@acme.com']/../following-sibling::tr/.[1]因此,我们的想法是以集合的形式获取所有元素,并使用带有适当索引的元素。
String tableRowShortXpath = "/dom[@domain='127.0.0.1']//table//td[@innertext='john.doe@acme.com']/../following-sibling::tr";
IList<Ranorex.WebElement> elements = Ranorex.Host.Local.Find<Ranorex.WebElement>(tableRowShortXpath);
Ranorex.WebElement desiredElement = elements[rowIndex - 1];就我的目的而言,这已经足够了,尽管如果使用直接的XPath查询找到元素,它的工作速度要慢2倍。
https://stackoverflow.com/questions/23471597
复制相似问题