Changeset e58a09 in indico
- Timestamp:
- 04/13/12 10:13:40 (13 months ago)
- Branches:
- master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 4c7d4152dff271ba5df5a8606605969cab454080
- Children:
- e3e124
- Parents:
- 09fd0c
- git-author:
- Pedro Ferreira <jose.pedro.ferreira@…> (04/12/12 12:02:08)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (04/13/12 10:13:40)
- Location:
- indico/tests/python/functional
- Files:
-
- 3 edited
-
lecture_test.py (modified) (3 diffs)
-
meeting_test.py (modified) (4 diffs)
-
seleniumTestCase.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/tests/python/functional/lecture_test.py
r09fd0c re58a09 42 42 ed.send_keys("12/07/2011 18:00") 43 43 self.click(css="button") 44 self.wait_for_jquery() 45 44 46 45 47 def test_tools(self): … … 133 135 self.click(id="_GID1_existingAv0") 134 136 self.click(xpath="//button[@type='button']") 137 138 # wait for overlay to go away 139 self.wait_remove(css='.ui-widget-overlay') 140 135 141 self.click(ltext="Add") 136 142 self.click(id="add_new_user") … … 146 152 self.click(id="checkParticipant1") 147 153 self.click(id="send_email") 148 self.click(css="input[type=\"text\"]")149 154 self.type(css="input[type=\"text\"]", text="test") 150 155 self.click(css="button.ui-button") 156 157 @self.retry() 158 def _retry(): 159 title = self.wait(css='.ui-dialog-title') 160 self.assertTrue('E-mail sent' in title.text) 161 162 _retry() 163 151 164 self.click(css="button.ui-button") 152 165 self.click(id="checkParticipant1") -
indico/tests/python/functional/meeting_test.py
r09fd0c re58a09 33 33 self.type(id="sessionTitle", text="Session 1") 34 34 self.click(css="button.ui-button") 35 36 # wait for overlay to go away 37 self.wait_remove(css='.ui-widget-overlay') 38 self.wait_for_jquery() 39 35 40 self.click(ltext="Add new") 36 41 self.click(ltext="Contribution") … … 40 45 # wait for overlay to go away 41 46 self.wait_remove(css='.ui-widget-overlay') 47 self.wait_for_jquery() 42 48 43 49 self.click(ltext="Add new") … … 45 51 self.type(id="breakTitle", text="coffe break") 46 52 self.click(css="button.ui-button") 47 self.click(css="ul.ui-tabs-nav li:nth-child(2)") 53 54 self.wait_remove(css='.ui-widget-overlay') 55 self.wait_for_jquery() 56 57 self.click(css='.ui-tabs-nav li:nth-child(2)') 58 48 59 self.click(ltext="Add new") 49 60 self.click(ltext="Session") … … 52 63 self.click(css="button.ui-button") 53 64 54 # wait for overlay to go away55 65 self.wait_remove(css='.ui-widget-overlay') 66 self.wait_for_jquery() 56 67 57 68 self.click(ltext="Reschedule") -
indico/tests/python/functional/seleniumTestCase.py
r09fd0c re58a09 23 23 """ 24 24 25 from functools import wraps 26 25 27 # Test libs 26 28 from selenium import webdriver 29 from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException 27 30 from selenium.webdriver.common.alert import Alert 28 31 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities … … 105 108 106 109 @classmethod 107 def waitForAjax(cls, sel, timeout=5000):108 """109 Wait that all the AJAX calls finish110 """111 time.sleep(1)112 sel.wait_for_condition("selenium.browserbot.getCurrentWindow()"113 ".activeWebRequests == 0", timeout)114 115 @classmethod116 def waitForElement(cls, sel, elem, timeout=5000):117 """118 Wait for a given element to show up119 """120 sel.wait_for_condition("selenium.isElementPresent(\"%s\")" % elem, timeout)121 122 @classmethod123 def waitPageLoad(cls, sel, timeout=30000):124 """125 Wait for a page to load (give it some time to load the JS too)126 """127 sel.wait_for_page_to_load(timeout)128 time.sleep(2)129 130 @classmethod131 110 def go(cls, rel_url): 132 111 webd.get("%s%s" % (Config.getInstance().getBaseURL(), rel_url)) … … 145 124 unittest.TestCase.failUnless(cls, func(*args)) 146 125 except AssertionError, e: 147 print "left %d" % triesLeft148 126 exception = e 149 127 triesLeft -= 1 … … 174 152 175 153 @classmethod 154 def execute(cls, code): 155 return webd.execute_script(code) 156 157 @classmethod 158 def jquery(cls, selector): 159 return cls.execute("var elem = $('%s'); return elem?elem[0]:null;" % selector) 160 161 @classmethod 162 def wait_for_jquery(cls, timeout=5): 163 while timeout: 164 active = webd.execute_script('return jQuery.active') 165 if active == 0: 166 return 167 time.sleep(1) 168 timeout -= 1 169 raise Exception('timeout') 170 171 @classmethod 176 172 @name_or_id_target 177 173 def select(cls, elem, label=''): … … 179 175 180 176 @classmethod 181 @name_or_id_target 182 def wait_remove(cls, timeout=5, **kwargs): 177 def wait(cls, timeout=5, **kwargs): 178 """ 179 Wait for a given element to show up 180 """ 183 181 while timeout: 184 elem = elem_get(**kwargs) 185 if not elem: 186 break 182 try: 183 return elem_get(**kwargs) 184 except NoSuchElementException: 185 pass 187 186 time.sleep(1) 188 187 timeout -= 1 188 raise Exception('timeout') 189 190 @classmethod 191 def retry(cls, max_retries=2): 192 def _retry(f): 193 @wraps(f) 194 def _wrapper(): 195 i = 0 196 for i in range(0, max_retries): 197 try: 198 return f() 199 except: 200 time.sleep(1) 201 raise Exception("'max_retries' exceeded") 202 return _wrapper 203 return _retry 204 205 @classmethod 206 def wait_remove(cls, css, timeout=5): 207 ts = time.time() 208 while True: 209 if not cls.jquery(css): 210 return 211 212 time.sleep(1) 213 214 if time.time() - ts > timeout: 215 break 216 217 raise Exception('timeout') 189 218 190 219 class LoggedInSeleniumTestCase(SeleniumTestCase):
Note: See TracChangeset
for help on using the changeset viewer.
