If you have something like :
<tbody>
<webelement>1<webelement/>
<webelement>2<webelement/>
<webelement>3<webelement/>
</tbody>
And you want 2 or 3, you can add [2] or [3] which is equivalent to [position()=2]
or [position()=3]
.
So for your XPath it would be ..//tbody[position()=2 or position()=3]
if you're looking for either of those positions. Note that you cannot use shorthand as in the previous statement if you are searching for multiple positions.
UPDATE:
filterRowXpath= "(((//div[@id=\"tabItemFilters\"]//div[@id=\"RowExpGridWidgetGridPanel\"]//div[@class=\"x-grid3-body\"]//tbody)[" + i + "])//td)[position()=2 or position()=3]
This will give you two node results back, instead of executing separate xpaths for each one.
List<WebElement> filterRows = driver.findElements(By.xpath(filterRowXpath));
Then apply your condition to the WebElements. You were almost there in the snippet posted in your original question.