aivaturi/Selenium-Remote-Driver — Issue #21: Documentation Fix for find_child_element(s)
Author: frezik
Created: 2011-12-21 15:11:19+00:00
State: open

In the documentation for Selenium::Remote::Driver::find_child_element(), it uses an xpath selector like:

my $child = $driver->find_child_element($elem1, "//option[\@value='es_ar']");

However, I've found that this does not exclusively search under the child node, and will return every option tag on the page with value="es_ar".

This version:

my @children = $driver->find_child_elements($elem1, "//option[1]");

Would return the first option tag of every select tag on the page.

I would suggest that xpath selectors be changed to search only under the given parent, but I'm not sure the way it works now is actually wrong. Using '//' at the beginning means you probably do want to search the whole page. Instead, I suggest the documentation for these two functions be fixed to use './', like:

my @children = $driver->find_child_elements($elem1, "./option[\@value='es_ar]");

This correctly searches only children of the parent element.