diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-08-25 11:54:27 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 |
commit | ac73c65cd3309e797c8c495454a8e48648f47090 (patch) | |
tree | ed4a2d6d326edcb6dbffb6b75d7a80f954a064e0 /ishtar_common/tests.py | |
parent | 1a950f5e45f23b22d622022ded110fc85028f6f1 (diff) | |
download | Ishtar-ac73c65cd3309e797c8c495454a8e48648f47090.tar.bz2 Ishtar-ac73c65cd3309e797c8c495454a8e48648f47090.zip |
additional tests without nested tabs for testing the ui of basefinds
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 71242db6b..4283e6c6f 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3628,8 +3628,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)) @@ -3642,20 +3657,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') @@ -3666,4 +3685,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') |