diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-08-25 16:19:11 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-09-01 12:36:46 +0200 |
commit | 2433d6ad42e3347706b55b5f482d68e1ee1e4653 (patch) | |
tree | bfe83b73b327b4a87108e24ed127b43fdf9b0b1b | |
parent | 40be360e184b4cac81a0666c6238282c7d0c9301 (diff) | |
download | Ishtar-2433d6ad42e3347706b55b5f482d68e1ee1e4653.tar.bz2 Ishtar-2433d6ad42e3347706b55b5f482d68e1ee1e4653.zip |
factorization of access_from_dropdown for tests
-rw-r--r-- | archaeological_context_records/tests.py | 28 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 42 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 22 | ||||
-rw-r--r-- | ishtar_common/tests.py | 19 |
4 files changed, 26 insertions, 85 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index a089c1dc5..a99fbefe6 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -1500,19 +1500,7 @@ class SeleniumTestsContextRecords(SeleniumTests): pks, geojsons = self.pks_and_geojson() # from operation for i in range(1, 3): - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/operation_search/"]' - ).click() + self.access_from_dropdown('operation') details = self.selenium.find_element_by_xpath( "//tbody/tr[" + str(i) + ']/td/a[@class="display_details"]' ) @@ -1525,19 +1513,7 @@ class SeleniumTestsContextRecords(SeleniumTests): self._test_cr(j, pks, copy.deepcopy(geojsons), method="from operation") # from search bar for i in range(1, 5): - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/record_search/"]' - ).click() + self.access_from_dropdown('record') self._test_cr(i, pks, copy.deepcopy(geojsons)) # from bottom table, multiple displays for i in range(1, 4): diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 17e327bd0..afc8a0f7e 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -2884,19 +2884,7 @@ class SeleniumTestsBaseFinds(SeleniumTests): pks, geojsons = self.pks_and_geojson() # from operation for i in range(1, 3): - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/operation_search/"]' - ).click() + self.access_from_dropdown('operation') details = self.selenium.find_element_by_xpath( "//tbody/tr[" + str(i) + ']/td/a[@class="display_details"]' ) @@ -2909,19 +2897,7 @@ class SeleniumTestsBaseFinds(SeleniumTests): self._test_bf(j, pks, copy.deepcopy(geojsons)) # from context record for i in range(1, 5): - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/record_search/"]' - ).click() + self.access_from_dropdown('record') details = self.selenium.find_element_by_xpath( "//tbody/tr[" + str(i) + ']/td/a[@class="display_details"]' ) @@ -2934,19 +2910,7 @@ class SeleniumTestsBaseFinds(SeleniumTests): self._test_bf(j, pks, copy.deepcopy(geojsons)) # from search for i in range(1, 9): - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/find_search/"]' - ).click() + self.access_from_dropdown('find') self._test_bf(i, pks, copy.deepcopy(geojsons), from_search=True) # from bottom table for i in range(1, 8): diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 45cdc93dd..75ded665c 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -4339,30 +4339,12 @@ class SeleniumTestsOperations(SeleniumTests): def test_geo_items(self): pks, geojsons = self.pks_and_geojson() - self.WebDriverWait(self.selenium, self.waiting_time).until( - lambda driver: driver.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - ) - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/operation_search/"]' - ).click() + self.access_from_dropdown('operation') ope = models.Operation.objects.get(pk=pks["Poly"]) slug_pk_poly = ope.SLUG + "-" + str(ope.pk) self._test_operation(2, slug_pk_poly, copy.deepcopy(geojsons), "Poly") - dropdown = self.selenium.find_element_by_xpath( - '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' - ) - self.scroll(dropdown) - dropdown.click() - self.selenium.find_element_by_xpath( - '//div[@class="dropdown-menu show"]/a[@href="/operation_search/"]' - ).click() + self.access_from_dropdown('operation') ope = models.Operation.objects.get(pk=pks["Pt"]) slug_pk_pt = ope.SLUG + "-" + str(ope.pk) self._test_operation(1, slug_pk_pt, copy.deepcopy(geojsons), "Pt") diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 2077a3781..2049b7828 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -3634,6 +3634,25 @@ class SeleniumTests(StaticLiveServerTestCase): element, ) + def access_from_dropdown(self, slug): + if slug == 'contextrecord': + slug = 'record' + if slug == 'basefind': + slug = 'find' + self.WebDriverWait(self.selenium, self.waiting_time).until( + lambda driver: driver.find_element_by_xpath( + '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' + ) + ) + dropdown = self.selenium.find_element_by_xpath( + '//a[@class="nav-link dropdown-toggle"][@id="dropdown-menu-main"]' + ) + self.scroll(dropdown) + dropdown.click() + self.selenium.find_element_by_xpath( + '//div[@class="dropdown-menu show"]/a[@href="/' + slug + '_search/"]' + ).click() + def assertNotInDOM(self, xpath): self.selenium.implicitly_wait(self.waiting_time / 5) try: |