Skip to content

Commit

Permalink
Handle case where num_messages is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
MCGallaspy committed Apr 10, 2015
1 parent 71f1477 commit 1772e9b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kalite/testing/mixins/browser_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def browser_check_django_message(self, message_type=None, contains=None, exact=N
"""Both central and distributed servers use the Django messaging system.
This code will verify that a message with the given type contains the specified text."""

WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.CLASS_NAME, "alert")))

# Get messages (and limit by type)
WebDriverWait(self.browser, 30).until(EC.presence_of_element_located((By.CLASS_NAME, "alert")))
messages = self.browser.find_elements_by_class_name("alert")
if num_messages > 0:
messages = WebDriverWait(self.browser, 5).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "alert")))
else:
messages = []

# Check that we got as many as expected
if num_messages is not None:
Expand Down

0 comments on commit 1772e9b

Please sign in to comment.