Skip to content

Commit

Permalink
Use pytest.raises in element finding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Jun 8, 2016
1 parent 79cef4c commit 6c9e23c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 143 deletions.
10 changes: 2 additions & 8 deletions py/test/selenium/webdriver/common/children_finding_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ def test_should_find_element_by_xpath(self):
def test_should_not_find_element_by_xpath(self):
self._load_page("nestedElements")
element = self.driver.find_element_by_name("form2")
try:
with pytest.raises(NoSuchElementException):
element.find_element_by_xpath("select/x")
self.fail("Expected NoSuchElementException to have been thrown")
except NoSuchElementException as e:
pass

def test_finding_dot_slash_elements_on_element_by_xpath_should_find_not_top_level_elements(self):
self._load_simple_page()
Expand Down Expand Up @@ -101,11 +98,8 @@ def test_should_find_element_by_id_when_multiple_matches_exist(self):
def test_should_find_element_by_id_when_no_match_in_context(self):
self._load_page("nestedElements")
element = self.driver.find_element_by_id("test_id_div")
try:
with pytest.raises(NoSuchElementException):
element.find_element_by_id("test_id_out")
self.fail("Expected NoSuchElementException to have been thrown")
except NoSuchElementException as e:
pass

def test_should_find_element_by_link_text(self):
self._load_page("nestedElements")
Expand Down
Loading

0 comments on commit 6c9e23c

Please sign in to comment.