TestProject Forum
Powered by leading experts in the test automation community

Searching for input element with Xpath relative path not working

I am trying to find an input element of FuelUX Repeater.

http://getfuelux.com/javascript.html#repeater

WebElement repeater = driver.findElement(By.id("repeaterIllustration"));
WebElement repeaterPagination = repeater.findElement(By.xpath(	"//div[contains(@class, 'repeater-pagination')]"));

I need the first input element under “repeaterPagination”.
While searching like this it works :

WebElement pageInput = repeaterPagination.findElement(By.xpath("//input[contains(@class, 'repeater-secondaryPaging')]"));

But when I tried :

WebElement pageInput = repeaterPagination.findElement(By.xpath("//descendant::input"));
WebElement pageInput = repeaterPagination.findElement(By.xpath("//input"));
WebElement pageInput = repeaterPagination.findElement(By.xpath("/input"));

None of those seem to work for me.
I can’t use the first option because some pages won’t have the ‘repeater-secondaryPaging’ class on the input element.

What am I missing ?

If you want to do a relative xpath search in selenium you need to add the dot ‘.’ character before slash, like so :

WebElement pageInput = repeaterPagination.findElement(By.xpath("./input"));