Searching for input element with Xpath relative path not working

  • 1 Replies
  • 937 Views
Searching for input element with Xpath relative path not working
« on: February 18, 2016, 17:26:06 pm »
I am trying to find an input element of FuelUX Repeater.

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

Code
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 :
Code
WebElement pageInput = repeaterPagination.findElement(By.xpath("//input[contains(@class, 'repeater-secondaryPaging')]"));

But when I tried :
Code
WebElement pageInput = repeaterPagination.findElement(By.xpath("//descendant::input"));
Code
WebElement pageInput = repeaterPagination.findElement(By.xpath("//input"));
Code
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 ?

*

Oren

  • **
  • 59
Re: Searching for input element with Xpath relative path not working
« Reply #1 on: February 21, 2016, 13:50:03 pm »
If you want to do a relative xpath search in selenium you need to add the dot '.' character before slash, like so :

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

 

Sitemap 1 2 3 4 5 6 7 8