find_elements return epmty list #47

wants to merge 1 commit into


None yet

5 participants



I am tried to use "find_elements" method for check if some element exits on the page, but it falls if elements not found, so I added empty array that should be returned by default.


Had exactly the same issues, so added similar logic in my pull request.


I agree that this change leads to a cleaner API, but committing it would break compatibility with the old code.

Some users of this module will have written code against the existing interface. Future versions of Selenium::Remote::Driver should not break existing code.

As a compromise, I would suggest creating a new method that behaves as you describe and documenting this as the best approach to use, while retaining the existing behaviour of "find_elements" so existing code contineus to work.

@brianmed brianmed was assigned Mar 28, 2013

While I disagree about how much to prioritize backcompat, the behavior of blowing-up-if-nothing is found is consistent with the rest of the the interface. Changing the behavior for this one method could cause unexpected results, so this patch should be rejected.

The current behavior is also consistent with the docs, which state under "USAGE (read this first)":

So a rule of thumb while invoking methods on the driver is if the method did not croak when called, then you can safely assume the command was successful even if nothing was returned by the method.

@markstos markstos closed this Jul 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment