ElementList¶
-
class splinter.element_list.ElementList(elements: list, driver=
None
, find_by=None
, query=None
)[source]¶ Bases:
object
Collection of elements.
Each member of the collection is by default an instance of
ElementAPI
.Beyond the traditional list methods,
ElementList
provides some other methods, listed below.There is a peculiar behavior on ElementList: you never get an
IndexError
. Instead, you get anElementDoesNotExist
exception when trying to access a non-existent item:>>> element_list = ElementList([]) >>> try: ... element_list[0] ... except ElementDoesNotExist: ... pass
- property first¶
An alias to the first element of the list.
Example
>>> element_list = browser.find_by_css('input') >>> assert element_list[0] == element_list.first
- property last¶
An alias to the last element of the list.
Example
>>> element_list = browser.find_by_css('input') >>> assert element_list[-1] == element_list.last