Hello!
I want to get a WebElement with a XPath expression based on another WebElement.
// With 'Table.getRowsOfATableByXPath(param)' I get all tag <tr> contained into param.List<WebElement> rows = CustomKeywords.'Table.getRowsOfATableByXPath'('//*[@id="dzA26"]/table')
for(int row = 1; row < rows.size(); row++) {
WebElement element = rows.get(row).findElement(By.xpath('/td[4]')) println element.getText();
}
}
The result expected is something like:
//*[@id="dzA26"]/table/tbody/tr[row]/td[4]
However this error occured
Test Cases/Filters/Search FAILED because (of) org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:“/td[4]”}
I hope my question is clear.
Thank’s a lot for your help!
**EDIT 1 **: Current solution
The current solution find is to use a second time the first XPath expression but I don’t like this solution…
List<WebElement> rows = CustomKeywords.'Table.getRowsOfATableByXPath'('//*[@id="dzA26"]/table')
for(int row = 1; row < rows.size(); row++) {
WebElement element = rows.get(row).findElement(By.xpath('//*[@id="dzA26"]/table/tbody/tr[' + row + ']/td[4]')) println element.getText();
}
}