Skip to content

Commit

Permalink
feat: created method for checking the current page's url
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-hd committed Oct 24, 2024
1 parent 96a169a commit bc686e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
33 changes: 12 additions & 21 deletions tests/functional/test_create_community_gis_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ def navigate_to_search_native_land_digital_database_page(self):
self.accept_cookies()

self.fill_out_and_submit_account_creation_form()
time.sleep(5) # wait for response

# verify user is on select add boundary method page
assert self.select_add_boundary_method_path in self.py.url()
assert self.select_add_boundary_method_path in self.get_current_url()

self.select_native_land_method_and_submit()

# verify user is on select boundary by nld page
time.sleep(4)
assert self.select_nld_add_boundary_method_path in self.py.url()
assert self.select_nld_add_boundary_method_path in self.get_current_url()

def navigate_to_upload_shapefile_page(self):
create_community_url = urllib.parse.urljoin(self.live_server_url, self.create_community_path)
Expand All @@ -108,13 +106,12 @@ def navigate_to_upload_shapefile_page(self):
time.sleep(5) # wait for response

# verify user is on select add boundary method page
assert self.select_add_boundary_method_path in self.py.url()
assert self.select_add_boundary_method_path in self.get_current_url()

self.select_upload_shapefile_and_submit()

# verify user is on select boundary by upload shapefile page
time.sleep(4)
assert self.select_upload_boundary_file_method_path in self.py.url()
assert self.select_upload_boundary_file_method_path in self.get_current_url()

def test_select_native_land_digital_territory_with_share_publicly(self):
self.navigate_to_search_native_land_digital_database_page()
Expand All @@ -128,8 +125,7 @@ def test_select_native_land_digital_territory_with_share_publicly(self):
self.py.get("#community-boundary-continue-btn").click()

# verify user is on the confirm community page
time.sleep(5) # wait for ajax call to finish
assert self.dashboard in self.py.url()
assert self.dashboard in self.get_current_url()

# verify community and boundary exists with the expected values
created_community = Community.objects.get(community_name=self.community_name)
Expand All @@ -150,8 +146,7 @@ def test_select_native_land_digital_territory_without_share_publicly(self):

# verify user is on the confirm community page
time.sleep(5) # wait for ajax call to finish
assert self.dashboard in self.py.url()

assert self.dashboard in self.get_current_url()

# verify community and boundary exists with the expected values
created_community = Community.objects.get(community_name=self.community_name)
Expand All @@ -166,17 +161,15 @@ def test_clicking_upload_shapefile_on_nld_page_navigates_to_upload_shapefile_pag
self.py.get("#navigate-to-option a").click()

# verify user is on the upload shapefile page
time.sleep(4)
assert self.select_upload_boundary_file_method_path in self.py.url()
assert self.select_upload_boundary_file_method_path in self.get_current_url()

def test_clicking_skip_this_step_on_nld_page_navigates_to_confirm_page(self):
self.navigate_to_search_native_land_digital_database_page()

self.py.get("#skip-this-step a").click()

# verify user is on the dashboard page after skipping
time.sleep(4)
assert self.dashboard in self.py.url()
assert self.dashboard in self.get_current_url()

def click_okay_on_alert_dialog(self):
self.alert_dialog.accept()
Expand Down Expand Up @@ -205,7 +198,7 @@ def test_select_shapefile_with_share_publicly(self):
# wait for ajax call
time.sleep(4)
# verify user is on the dashbaord page
assert self.dashboard in self.py.url()
assert self.dashboard in self.get_current_url()

# verify community and boundary exists with the expected values
created_community = Community.objects.get(community_name=self.community_name)
Expand Down Expand Up @@ -234,7 +227,7 @@ def test_select_shapefile_without_share_publicly(self):
# wait for ajax call
time.sleep(4)
# verify user is on the dashbaord page
assert self.dashboard in self.py.url()
assert self.dashboard in self.get_current_url()

# verify community and boundary exists with the expected values
created_community = Community.objects.get(community_name=self.community_name)
Expand All @@ -249,14 +242,12 @@ def test_clicking_select_by_nld_on_upload_shapefile_page_navigates_to_select_by_
self.py.get("#navigate-to-option a").click()

# verify user is on the select by nld page
time.sleep(4)
assert self.select_nld_add_boundary_method_path in self.py.url()
assert self.select_nld_add_boundary_method_path in self.get_current_url()

def test_clicking_skip_this_step_on_upload_shapefile_page_navigates_to_confirm_page(self):
self.navigate_to_upload_shapefile_page()

self.py.get("#skip-this-step a").click()

# verify user is on the dashbaord page
time.sleep(4)
assert self.dashboard in self.py.url()
assert self.dashboard in self.get_current_url()
17 changes: 17 additions & 0 deletions tests/functional/ui_feature_testcase_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import time
import urllib.parse

import pytest
Expand Down Expand Up @@ -33,3 +34,19 @@ def login(self,):

# submit login
self.py.get("[class~='signin-btn']").click()

def get_current_url(self, wait_seconds: int = 8) -> str:
"""
* Switches to the most recent window
* Waits for a couple of seconds to make sure preexisting
actions have completed
* returns the url on the most active window
"""
driver = self.py.webdriver
current_window = driver.window_handles[-1]
driver.switch_to.window(current_window)

time.sleep(wait_seconds)

return driver.current_url

0 comments on commit bc686e6

Please sign in to comment.