Skip to content

Commit

Permalink
QA-7400 updated steps and locators for all USH scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kbo001 committed Jan 21, 2025
1 parent 1c17eca commit 452b890
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions common_utilities/selenium/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dateutil.parser import parse
from selenium.webdriver.support.select import Select
from selenium.common.exceptions import TimeoutException, ElementClickInterceptedException, \
UnexpectedAlertPresentException, StaleElementReferenceException, NoSuchElementException
UnexpectedAlertPresentException, StaleElementReferenceException, NoSuchElementException, JavascriptException
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
Expand Down Expand Up @@ -382,9 +382,13 @@ def get_element(self, xpath_format, insert_value):
return element

def wait_for_ajax(self, value=300):
wait = WebDriverWait(self.driver, value)
wait.until(lambda driver: self.driver.execute_script('return jQuery.active') == 0)
wait.until(lambda driver: self.driver.execute_script('return document.readyState') == 'complete')
try:
wait = WebDriverWait(self.driver, value)
wait.until(lambda driver: self.driver.execute_script('return jQuery.active') == 0)
wait.until(lambda driver: self.driver.execute_script('return document.readyState') == 'complete')
except JavascriptException:
print("Undefined JQuery")
time.sleep(20)

def is_date(self, string, fuzzy=False):
"""
Expand Down
11 changes: 7 additions & 4 deletions common_utilities/selenium/webapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, driver, settings):


self.form_submit = (By.XPATH, "//div[contains(@id,'submit')]//button[contains(@class,'submit')]")
self.form_submission_successful = (By.XPATH, "//*[contains(@class='alert-success')][contains(text(), 'successfully saved')]")
self.form_submission_successful = (By.XPATH, "//div[contains(@class,'alert-success')][contains(text(), 'successfully saved') or .//p[contains(text(), 'successfully saved')]]")
self.form_500_error = (By.XPATH, "//*[contains(text(),'500 :')]")
self.search_all_cases_button = (By.XPATH,
"(//*[contains(text(),'Search All')]//parent::div[@class='case-list-action-button btn-group formplayer-request']/button)[1]")
Expand Down Expand Up @@ -86,19 +86,22 @@ def open_app(self, app_name):
self.application_header = self.get_element(self.app_header_format, app_name)
self.scroll_to_element(self.application)
self.js_click(self.application)
time.sleep(10)
self.wait_for_ajax()
self.is_visible_and_displayed(self.application_header, timeout=200)

def navigate_to_breadcrumb(self, breadcrumb_value):
self.link = (By.XPATH, self.breadcrumb_format.format(breadcrumb_value, breadcrumb_value))
self.wait_for_element(self.link)
self.js_click(self.link)
time.sleep(5)

def open_menu(self, menu_name):
self.caselist_menu = self.get_element(self.menu_name_format, menu_name)
self.caselist_header = self.get_element(self.menu_name_header_format, menu_name)
self.scroll_to_element(self.caselist_menu)
self.js_click(self.caselist_menu)
time.sleep(5)
self.wait_for_ajax()
assert self.is_visible_and_displayed(self.caselist_header)

Expand Down Expand Up @@ -207,10 +210,10 @@ def select_case_and_continue(self, case_name):
def async_restore_resubmit(self):
time.sleep(10)
if self.is_present_and_displayed(self.async_restore_error, 20):
self.js_click(self.async_restore_error)
time.sleep(5)
self.click(self.async_restore_error)
time.sleep(10)
self.scroll_to_element(self.form_submit)
self.wait_to_click(self.form_submit)
self.js_click(self.form_submit)
else:
print("No Asynchronous restore error present")

Expand Down

0 comments on commit 452b890

Please sign in to comment.