Skip to content

Commit

Permalink
ElementList now accepts slice objects (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfehler authored and andrewsmedina committed Jun 25, 2019
1 parent ebd8b13 commit f678603
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion splinter/element_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, list, driver=None, find_by=None, query=None):
self.query = query

def __getitem__(self, index):
if not isinstance(index, int):
if not isinstance(index, int) and not isinstance(index, slice):
return self.first[index]
try:
return self._container[index]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_element_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def walk(self):


class ElementListTest(unittest.TestCase):
def test_slice(self):
"""ElementList should work with slice operations."""
elem_list = ElementList([1, 2, 3, 4, 5])
new_elem_list = elem_list[2:5]
self.assertTrue(len(new_elem_list) == 3)

def test_method_that_verifies_if_the_list_is_empty(self):
"should verify if the list is empty"
the_list = ElementList([1, 2, 3])
Expand Down

0 comments on commit f678603

Please sign in to comment.