Fixed infinite loop in assertion

This commit is contained in:
axl89 2016-05-27 10:45:49 +02:00
parent 3f31d27b9d
commit 53b9fa8762

View File

@ -6,6 +6,8 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import StaleElementReferenceException from selenium.common.exceptions import StaleElementReferenceException
import unittest, time, re
class PAN3(PandoraWebDriverTestCase): class PAN3(PandoraWebDriverTestCase):
@ -13,7 +15,6 @@ class PAN3(PandoraWebDriverTestCase):
test_description = u'Creates a simple ICMP check against localhost and checks the result is 1' test_description = u'Creates a simple ICMP check against localhost and checks the result is 1'
tickets_associated = [] tickets_associated = []
def test_pan3(self): def test_pan3(self):
driver = self.driver driver = self.driver
login(driver,"admin","pandora",self.base_url) login(driver,"admin","pandora",self.base_url)
@ -49,6 +50,7 @@ class PAN3(PandoraWebDriverTestCase):
try: try:
element_text = refresh_N_times_until_find_element(driver,5,"table1-1-7",how=By.ID).text element_text = refresh_N_times_until_find_element(driver,5,"table1-1-7",how=By.ID).text
self.assertEqual("1", element_text.lstrip().rstrip()) # The lstrip.rstrip is done because if not, this error is raised: "'1' != u'1 '" self.assertEqual("1", element_text.lstrip().rstrip()) # The lstrip.rstrip is done because if not, this error is raised: "'1' != u'1 '"
break
except StaleElementReferenceException as e_stale: except StaleElementReferenceException as e_stale:
i = i+1 i = i+1
if i > max_retries: if i > max_retries:
@ -58,6 +60,7 @@ class PAN3(PandoraWebDriverTestCase):
next next
except AssertionError as e: except AssertionError as e:
self.verificationErrors.append(str(e)) self.verificationErrors.append(str(e))
break
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()