Changeset e58a09 in indico


Ignore:
Timestamp:
04/13/12 10:13:40 (13 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
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)
Message:

[FIX] Several fixes for Chrome

Location:
indico/tests/python/functional
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • indico/tests/python/functional/lecture_test.py

    r09fd0c re58a09  
    4242        ed.send_keys("12/07/2011 18:00") 
    4343        self.click(css="button") 
     44        self.wait_for_jquery() 
     45 
    4446 
    4547    def test_tools(self): 
     
    133135        self.click(id="_GID1_existingAv0") 
    134136        self.click(xpath="//button[@type='button']") 
     137 
     138        # wait for overlay to go away 
     139        self.wait_remove(css='.ui-widget-overlay') 
     140 
    135141        self.click(ltext="Add") 
    136142        self.click(id="add_new_user") 
     
    146152        self.click(id="checkParticipant1") 
    147153        self.click(id="send_email") 
    148         self.click(css="input[type=\"text\"]") 
    149154        self.type(css="input[type=\"text\"]", text="test") 
    150155        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 
    151164        self.click(css="button.ui-button") 
    152165        self.click(id="checkParticipant1") 
  • indico/tests/python/functional/meeting_test.py

    r09fd0c re58a09  
    3333        self.type(id="sessionTitle", text="Session 1") 
    3434        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 
    3540        self.click(ltext="Add new") 
    3641        self.click(ltext="Contribution") 
     
    4045        # wait for overlay to go away 
    4146        self.wait_remove(css='.ui-widget-overlay') 
     47        self.wait_for_jquery() 
    4248 
    4349        self.click(ltext="Add new") 
     
    4551        self.type(id="breakTitle", text="coffe break") 
    4652        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 
    4859        self.click(ltext="Add new") 
    4960        self.click(ltext="Session") 
     
    5263        self.click(css="button.ui-button") 
    5364 
    54         # wait for overlay to go away 
    5565        self.wait_remove(css='.ui-widget-overlay') 
     66        self.wait_for_jquery() 
    5667 
    5768        self.click(ltext="Reschedule") 
  • indico/tests/python/functional/seleniumTestCase.py

    r09fd0c re58a09  
    2323""" 
    2424 
     25from functools import wraps 
     26 
    2527# Test libs 
    2628from selenium import webdriver 
     29from selenium.common.exceptions import NoSuchElementException, StaleElementReferenceException 
    2730from selenium.webdriver.common.alert import Alert 
    2831from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 
     
    105108 
    106109    @classmethod 
    107     def waitForAjax(cls, sel, timeout=5000): 
    108         """ 
    109         Wait that all the AJAX calls finish 
    110         """ 
    111         time.sleep(1) 
    112         sel.wait_for_condition("selenium.browserbot.getCurrentWindow()" 
    113                                ".activeWebRequests == 0", timeout) 
    114  
    115     @classmethod 
    116     def waitForElement(cls, sel, elem, timeout=5000): 
    117         """ 
    118         Wait for a given element to show up 
    119         """ 
    120         sel.wait_for_condition("selenium.isElementPresent(\"%s\")" % elem, timeout) 
    121  
    122     @classmethod 
    123     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     @classmethod 
    131110    def go(cls, rel_url): 
    132111        webd.get("%s%s" % (Config.getInstance().getBaseURL(), rel_url)) 
     
    145124                unittest.TestCase.failUnless(cls, func(*args)) 
    146125            except AssertionError, e: 
    147                 print "left %d" % triesLeft 
    148126                exception = e 
    149127                triesLeft -= 1 
     
    174152 
    175153    @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 
    176172    @name_or_id_target 
    177173    def select(cls, elem, label=''): 
     
    179175 
    180176    @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        """ 
    183181        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 
    187186            time.sleep(1) 
    188187            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') 
    189218 
    190219class LoggedInSeleniumTestCase(SeleniumTestCase): 
Note: See TracChangeset for help on using the changeset viewer.