Xpath Get last matching result
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2020
08:31 AM
05-02-2020
08:31 AM
Xpath Get last matching result
I have an xpath expression like this:
//td[@div='id']/nobr[text()='Total AR:']
Upon checking on the inspector element there are multiple matches, both on /td[@div='id'] and nobr[text()='Total AR:']. I only need to get the last result as im sure thats what i need. Basically im trying to do something like this:
//td[@div='id'][last()]/nobr[text()='Total AR:']
how can i get the last result ?
Solved! Go to Solution.
Labels:
- Labels:
-
Chrome
-
Keyword Tests
1 REPLY 1
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2020
02:03 AM
05-03-2020
02:03 AM
Perhaps use the array return of xpath query.
And take the last one.
objectfind = MyPage.contentDocument == null ? null : MyPage.FindChildByXPath(toFind);
if ((typeof objectfind != 'undefined') && (objectfind != null)) {
objectfind = (new VBArray(objectfind)).toArray();
return (objectfind[objectfind.length-1]);
}
else
return null;
Un sourire et ça repart
