pytest-dev/pytest-splinter

Confusing error message when elements are not found

vdboor opened this issue · 1 comments

An error message like: AttributeError: 'ElementList' object has no attribute 'click'
is often caused by the following:

element_list = browser.find_by_id("#non-existing")
element_list.click()

This happens because the ElementDoesNotExist error is masked in ElementList.__getattr__():

    def __getattr__(self, name):
        try:
            return getattr(self.first, name)
        except (ElementDoesNotExist, AttributeError):
            raise AttributeError(
                u"'{0}' object has no attribute '{1}'".format(
                    self.__class__.__name__, name
                )
            )

Simply removing except ElementDoesNotExist would fix this issue

Closing, this seems to be a bug in splinter instead