diff options
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index ca3b40303..1c757dd2a 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3548,8 +3548,23 @@ class SeleniumTests(StaticLiveServerTestCase): + "window.scrollBy(0, elementTop-(viewPortHeight/2));", element) + ''' + arguments: + i is the number of the row (starting at 1) + target and source are a tuple of french/english slugs corresponding respectively to the slug of the item of + which we want some details and the slug of the item from which we launched the search + ''' + def click_on_details(self, i, target, source=None): + table = '//table[contains(@id, ' + target[0] + ') or contains(@id, ' + target[1] + ')]' + if source: + table += '[contains(@id, ' + source[0] + ') or contains(@id, ' + source[1] + ')]' + details = table + '/tbody/' + '/tr[' + str(i) + ']/td/a[@class="display_details"]' + details = self.selenium.find_element_by_xpath(details) + self.scroll(details) + details.click() + def assertNotInDOM(self, xpath): - self.selenium.implicitly_wait(5) + self.selenium.implicitly_wait(3) try: self.WebDriverWait(self.selenium, 2).until( self.EC.visibility_of_element_located((self.By.XPATH, xpath)) @@ -3562,20 +3577,24 @@ class SeleniumTests(StaticLiveServerTestCase): def assertMap(self, dic_base, slug_pk, features_collecs=None): dic_base = {'type': 'FeatureCollection', 'features': [dic_base]} - mapdivs = self.selenium.find_elements_by_class_name("window-map") mapid = None - for mapdiv in mapdivs: - if slug_pk in mapdiv.get_attribute("id"): - mapid = mapdiv.get_attribute("id") - break + timeout = 20 + t = time() + while not mapid and time()-t < timeout: + mapdivs = self.selenium.find_elements_by_class_name("window-map") + for mapdiv in mapdivs: + if slug_pk in mapdiv.get_attribute("id"): + mapid = mapdiv.get_attribute("id") + break id = int(re.search(r'\d+$', mapid).group()) # TODO: use the map and not the map_features in the js function if features_collecs: self.WebDriverWait(self.selenium, 2).until( self.EC.visibility_of_element_located((self.By.ID, "http-geo-items-ready-"+slug_pk)) ) - print(id) + print('id : ', id) print('mapid : ', mapid) + print('slug_pk : ', slug_pk) print(self.selenium.execute_script('return base_features_type(arguments[0])', mapid)) base_features, geo_items_feats = self.selenium.execute_script('return get_features_by_id(arguments[0])', mapid) base_features['features'][0]['properties'].pop('name') @@ -3586,4 +3605,8 @@ class SeleniumTests(StaticLiveServerTestCase): if features_collecs: print('feat : ', geo_items_feats) print('dic : ', features_collecs) - self.assertEqual(geo_items_feats, features_collecs) + try: + self.assertEqual(geo_items_feats, features_collecs) + except: + self.selenium.implicitly_wait(10000) + self.selenium.find_element_by_xpath('doesnet') |