From 55bfb1a6fe54f9109fbf6ca7127047fdc978acc8 Mon Sep 17 00:00:00 2001 From: neelimaguntupalli1-nhs Date: Wed, 6 Nov 2024 09:41:45 +0000 Subject: [PATCH] Ravs 961 update record a vaccine tests (#31) * Fixed failing add existing batch test * Fixed fa * Fixed assessment page fields * Fixed consent page fields and site vaccine, batch fields * Fixed vaccinated page field, giving a first stan now to see if all tests pass * Fixed failing age based warning tests * Sorted record a vaccine tests hopefully * Sorted record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully * Sorted most of record a vaccine tests hopefully --------- Co-authored-by: root --- .vscode/settings.json | 4 +- conftest.py | 86 +++------- ...accine_for_patient_with_nhs_number.feature | 12 +- helpers/datetimeHelper.py | 17 ++ helpers/playwrightHelper.py | 45 +++-- init_helpers.py | 14 +- pages/add_vaccines_page.py | 67 -------- pages/assess_patient_page.py | 155 ++++++++++++++---- ...heck_and_confirm_vaccinated_record_page.py | 69 ++++---- pages/choose_vaccines_page.py | 4 +- pages/delete_vaccination_page.py | 11 +- pages/find_a_patient_page.py | 8 +- pages/home_page.py | 48 ++++++ pages/nhs_signin_page.py | 7 + pages/patient_details_page.py | 45 +++-- pages/record_consent_page.py | 89 +++++++--- pages/record_vaccinated_page.py | 134 +++++++-------- pages/site_vaccine_batches_confirm_page.py | 42 +++-- pages/site_vaccine_batches_page.py | 3 +- pages/site_vaccines_add_batch_page.py | 16 +- pages/vaccinator_location_page.py | 82 ++++----- pages/vaccines_choose_site_page.py | 20 ++- pages/vaccines_choose_vaccine_page.py | 18 +- pages/vaccines_view_products_page.py | 14 +- test_data/models/assessing_clinicians.py | 3 - test_data/models/legal_mechanism.py | 5 +- test_data/models/vaccine_type_dose_amounts.py | 8 + tests/test_add_vaccine_batches_steps.py | 1 - tests/test_add_vaccine_steps.py | 6 - tests/test_age_based_warnings_steps.py | 6 +- tests/test_find_a_patient_steps.py | 2 - ...ccine_for_patient_with_nhs_number_steps.py | 17 +- 32 files changed, 609 insertions(+), 449 deletions(-) delete mode 100644 pages/add_vaccines_page.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 64c0bae44..b998ab477 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,9 @@ "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "cSpell.words": [ + "CAREHOME", "immunisation", - "organisation" + "organisation", + "WHITESTONES" ] } diff --git a/conftest.py b/conftest.py index 6d4549e5e..80f323040 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,5 @@ import pytest -from pages.add_vaccines_page import * +# from pages.add_vaccines_page import * from pages.settings_page import * from pages.site_vaccine_batches_page import * from pages.vaccines_page import * @@ -107,46 +107,6 @@ def navigate_to_ravs(request): navigate_to_ravs_login_page(url) return True -# Fixture for clicking back button -@pytest.fixture(scope='function') -def click_back_button_recording_consent(request): - click_back_button() - -def set_vaccinator_location(site, care_model): - select_site(site) - select_care_model(care_model) - if care_model == "Care Home": - enter_carehome_name("WHITESTONES CARE HOME") - click_continue_to_record_a_vaccination_homepage() - -@pytest.fixture(scope='function') -def login_and_navigate_to_homepage(request, navigate_and_login): - click_continue_to_record_a_vaccination_homepage() - -# Fixture for logging in and navigating to appointments open first patient -@pytest.fixture(scope='function') -def login_and_navigate_to_appointments_open_first_patient(request, navigate_and_login): - attach_screenshot("user_has_logged_in") - site = "ST JOHN'S HOUSE" - care_model = "Vaccination Centre" - select_site(site) - attach_screenshot("user_has_selected_site") - select_care_model(care_model) - if care_model == "Care Home": - enter_carehome_name("WHITESTONES CARE HOME") - attach_screenshot("user_has_selected_site") - attach_screenshot("user_has_selected_care_model") - click_continue_to_record_a_vaccination_homepage() - attach_screenshot("user_has_clicked_continue_to_ravs_homepage") - current_date = datetime.now() - fromDate = datetime(2023, 12, 1) - set_from_date(fromDate) - click_active_from_date() - toDate = datetime.today() - set_to_date(toDate) - click_active_to_date_today() - click_first_patient() - # Fixture for logging in and navigating to find a patient @pytest.fixture(scope='function') def login_and_navigate_to_find_a_patient(request): @@ -242,13 +202,13 @@ def check_site_vaccine_type_has_active_batch(site, vaccine, vaccine_type, batch_ # If the batch does NOT currently exist, add a batch # This adds an active batch, so we don't need to do further checks click_view_product(site, vaccine_type) - if not check_batch_number_exists(batch_number, True): + if not check_batch_number_and_expiry_date_exists(batch_number, expiry_date, True): add_vaccine_type_batch(batch_number, expiry_date) return True # If we get this far, the batch does exists but is currently INACTIVE # This reactivates the batch - if not check_batch_number_is_active(batch_number, True): + if not check_batch_number_is_active_with_date(batch_number, expiry_date, True): click_reactivate_batch_link(batch_number) click_reactivate_batch_confirmation_button() @@ -259,30 +219,29 @@ def add_site_vaccine(site, vaccine, vaccine_type, batch_number, expiry_date): # vaccines_choose_site_page enter_site_name(site) select_site_from_list(site) - click_continue_button() + click_continue_to_add_vaccine_button() # choose_vaccine_page - click_vaccine_radiobutton(vaccine) - click_vaccine_type_radiobutton(vaccine_type) - click_continue_button() + click_vaccine_radiobutton_on_add_vaccine_screen(vaccine) + click_vaccine_type_radiobutton_on_add_vaccine_screen(vaccine_type) + click_continue_to_add_batch_button() # vaccines_add_batch_page enter_batch_number(batch_number) enter_expiry_date(expiry_date) - click_continue_button() + click_continue_to_confirm_batch_details_button() # vaccines_check_and_confirm_page - click_confirm_button() + click_confirm_add_vaccine_and_batch_button() def add_vaccine_type_batch(batch_number, expiry_date): click_add_batch_link() - # vaccines_add_batch_page enter_batch_number(batch_number) enter_expiry_date(expiry_date) - click_continue_button() + click_continue_to_confirm_batch_details_button() # vaccines_check_and_confirm_page - click_confirm_button() + click_confirm_add_vaccine_and_batch_button() def assess_patient_with_details_and_click_continue_to_consent(eligible_decision, eligibility_type, staff_role, assessing_clinician, due_date, assessment_date, legal_mechanism, assessment_outcome, assessment_comments, eligibility_assessment_no_vaccine_given_reason=None): @@ -324,9 +283,11 @@ def assess_patient_with_details_and_click_continue_to_consent(eligible_decision, attach_screenshot("clicked_continue_to_record_consent_button") -def record_consent_details_and_click_continue_to_vaccinate(consent_decision, consent_given_by, person_consenting_name, relationship_to_patient, consent_clinician, no_consent_reason=None): +def record_consent_details_and_click_continue_to_vaccinate(consent_decision, consent_given_by, person_consenting_name, relationship_to_patient, consent_clinician, legal_mechanism, no_consent_reason=None): attach_screenshot("before_selecting_consent_clinician") - select_consent_clinician_with_name_and_council(consent_clinician) + + if (legal_mechanism) != "Patient Group Direction (PGD)": + select_consent_clinician_with_name_and_council(consent_clinician) if consent_decision.lower() == 'yes': click_yes_to_consent() @@ -347,22 +308,17 @@ def record_consent_details_and_click_continue_to_vaccinate(consent_decision, co click_save_and_return_button_on_record_consent_page() attach_screenshot("patient_decided_to_not_consent_saved_and_returned") -def enter_vaccine_details_and_click_continue_to_check_and_confirm(vaccinate_decision, care_model, vaccination_date, vaccine, vaccine_type2, vaccination_site, batch_number, batch_expiry_date, dose_amount, vaccinator, vaccination_comments, no_vaccination_reason=None): +def enter_vaccine_details_and_click_continue_to_check_and_confirm(vaccinate_decision, care_model, vaccination_date, vaccine, vaccine_type2, vaccination_site, batch_number, batch_expiry_date, dose_amount, vaccinator, vaccination_comments, legal_mechanism, no_vaccination_reason=None): if vaccinate_decision.lower() == 'yes': click_yes_vaccinated_radiobutton() - if "covid" in (vaccine).lower(): - click_covid_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2) - elif "flu" in (vaccine).lower(): - click_flu_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2) - elif "rsv" in (vaccine).lower(): - click_rsv_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2) - elif "pertussis" in (vaccine).lower(): - click_pertussis_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccine_type2) - + click_vaccine_type(vaccine_type2) set_vaccination_date(vaccination_date) click_care_model_option(care_model) - select_vaccinator_name_and_council(vaccinator) + if care_model == "Care home": + enter_care_home_details("WHITESTONES CARE HOME") + if (legal_mechanism) != "Patient Group Direction (PGD)": + select_vaccinator_name_and_council(vaccinator) enter_vaccination_comments(vaccination_comments) select_vaccination_site(vaccination_site) batch_number_to_select = batch_number.upper() + " - " + batch_expiry_date diff --git a/features/record_a_vaccine_for_patient_with_nhs_number.feature b/features/record_a_vaccine_for_patient_with_nhs_number.feature index 6fed7623d..9ae17afc1 100644 --- a/features/record_a_vaccine_for_patient_with_nhs_number.feature +++ b/features/record_a_vaccine_for_patient_with_nhs_number.feature @@ -32,13 +32,13 @@ Feature: Record vaccine | 12 | 9437540233 | ALBERT HOUSE | Hospital Hub | yes | today-15 | yes | yes | today-7 | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | SDYY2-18E | 19/10/2026 | | 8 | 9474376638 | BECCLES HOUSE | Care Home | yes | today-32 | yes | yes | today-30 | PHYLLIDA ZYLKO | 6/2/1968 | BELL FARM BUNGALOW, CATON GREEN, BROOKHOUSE, LANCASTER, LA2 9JG | Flu | SDYY2-18F | 19/10/2026 | | 9 | 9474405174 | BIRCH HOUSE | Home Of Housebound Patient | yes | today | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-19A | 19/10/2026 | - | 10 | 9474405174 | ALBERT HOUSE | Off-site Outreach Event | yes | today-2 | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-14B | 19/10/2026 | + | 10 | 9474405174 | ALBERT HOUSE | Off-site Outreach Event | yes | today-2 | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | SDYY2-14B | 5/5/2025 | | 11 | 9450134391 | BECCLES HOUSE | Vaccination Centre | yes | today-3 | yes | yes | today | MARIAN PIESSE | 17/7/1994 | 2 BIRCH STREET, LYTHAM ST. ANNES, LANCS, FY8 5DT | Flu | SDYY2-14C | 19/10/2026 | | 12 | 9450140960 | BIRCH HOUSE | Hospital Hub | yes | today-1 | yes | yes| today | DEANA GAMBLES | 5/9/1993 | 10 GRASMERE ROAD, LYTHAM ST. ANNES, LANCS, FY8 2HZ | Flu | SDYY2-20A | 19/10/2026 | - | 1 | 9450141444 | ALBERT HOUSE | Care Home | yes | today-4 | yes | yes | today-2 | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | SDYY2-21A | 19/10/2026 | - | 2 | 9450141711 | BECCLES HOUSE | Home Of Housebound Patient | yes | today-2| yes | yes | today-1 | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | SDYY2-22A | 19/10/2026 | + | 1 | 9450141444 | ALBERT HOUSE | Care Home | yes | today-4 | yes | yes | today-2 | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | SDYY2-21A | 5/5/2025 | + | 2 | 9450141711 | BECCLES HOUSE | Home Of Housebound Patient | yes | today-2| yes | yes | today-1 | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | SDYY2-22A | 5/5/2025 | | 3 | 9450144699 | BIRCH HOUSE | Off-site Outreach Event | yes | today-1 | yes | yes | today-1 | HOPE TULLY | 10/1/1993 | 2 CHAPEL CLOSE, WESHAM, PRESTON, PR4 3HB | Flu | SDYY2-23A | 19/10/2026 | - | 4 | 9437541817 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | SDYY2-24A | 19/10/2026 | + | 4 | 9437541817 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | SDYY2-24A | 5/5/2025 | @recordvaccine Scenario Outline: Record a maternity vaccine with nhs number @@ -46,7 +46,7 @@ Feature: Record vaccine And I search for a patient with the NHS number in the find a patient screen And I open the patient record by clicking on patient When I click choose vaccine button and choose the , , with and click continue - And I assess the pregnant patient's with the details and date as and click continue to record consent screen button + And I assess the pregnant patient's with the details of due date as and assessment date as and click continue to record consent screen button And I record with the details and click continue to vaccinate button And I record details and date as and click Continue to Check and confirm screen Then I need to be able to see the patient , ,
and vaccination details on the check and confirm screen @@ -57,7 +57,7 @@ Feature: Record vaccine Examples: | index | nhs_number | site | care_model | eligibility | due_date | assess_date | consent | vaccination | vaccination_date | name | dob | address | chosen_vaccine | vaccine_type | batch_number | batch_expiry_date | - | 4 | 9473629885 | KINGSTON HOUSE | Off-site Outreach Event | yes | today+50 | today-4 | yes | yes | today-3 | MARGIE PUCKEY | 27/5/1924 | MANSART COURT, 10 OLIVE SHAPLEY AVENUE, MANCHESTER, M20 6QB | Respiratory syncytial virus (RSV) | Arexvy | AREX2-01A | 19/10/2026 | + | 4 | 9473629885 | KINGSTON HOUSE | Off-site Outreach Event | yes | today+50 | today-4 | yes | yes | today-3 | MARGIE PUCKEY | 27/5/1924 | MANSART COURT, 10 OLIVE SHAPLEY AVENUE, MANCHESTER, M20 6QB | Respiratory syncytial virus (RSV) | Arexvy | RSVTEST2 | 31/12/2025 | # | 0 | 9693632109 | ALBERT HOUSE | Vaccination Centre | yes | today | today | yes | yes | today | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | Pertussis | Adacel vaccine suspension | ADAC1-27 | 19/10/2027 | # | 1 | 9693632109 | BECCLES HOUSE | Vaccination Centre | yes | today+100 | today-1 | yes | yes | today-1 | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | Pertussis | Boostrix-IPV suspension | BST01-28B | 19/10/2028 | # | 2 | 9470040228 | BIRCH HOUSE | Hospital Hub | yes | today+290 | today-1 | yes | yes | today | HERBERT HAAG | 14/12/1922 | 10 COASTAL ROAD, HEST BANK, LANCASTER, LA2 6HN | Pertussis | Repevax vaccine suspension | REPE11-29A | 19/2/2029 | diff --git a/helpers/datetimeHelper.py b/helpers/datetimeHelper.py index 3e2269df9..ee96ccc0c 100644 --- a/helpers/datetimeHelper.py +++ b/helpers/datetimeHelper.py @@ -154,6 +154,23 @@ def date_format_with_name_of_month(date_str): year = parsed_date.year return f"{day} {month} {year}" + @staticmethod + def date_format_with_name_of_month_shortened(date_str): + try: + # Try parsing the date as '%d/%m/%Y' + parsed_date = datetime.strptime(date_str, "%d/%m/%Y") + except ValueError: + try: + # If parsing fails, try parsing as '%m/%d/%Y' + parsed_date = datetime.strptime(date_str, "%m/%d/%Y") + except ValueError: + # If parsing as both formats fails, return the original string + return date_str.strftime("%d %b %Y") + + day = parsed_date.day + month = parsed_date.strftime('%b') + year = parsed_date.year + return f"{day} {month} {year}" class DatetimeHelper(BaseDatetimeHelper): def __init__(self): diff --git a/helpers/playwrightHelper.py b/helpers/playwrightHelper.py index 6804d00db..88165553a 100644 --- a/helpers/playwrightHelper.py +++ b/helpers/playwrightHelper.py @@ -117,8 +117,11 @@ def navigate_to_url(self,url): self.page.wait_for_load_state() def wait_for_page_to_load(self, timeout=0.1): - self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 1000) - self.page.wait_for_selector('*', timeout=timeout * 1000) + try: + self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 1000) + self.page.wait_for_selector('*', timeout=timeout * 1000) + except Exception as e: + print(f"Page did not fully load within {timeout} seconds. Proceeding anyway.") def find_elements(self, selector): return self.page.query_selector_all(selector) @@ -161,6 +164,20 @@ def wait_for_element_to_appear(self, locator_or_element, timeout=10): time.sleep(0.5) # Check every 0.5 seconds + def wait_for_element_to_disappear(self, locator_or_element, timeout=10): + start_time = time.time() + while True: + if time.time() - start_time > timeout: + print(f"Timeout: Element '{locator_or_element}' did not appear.") + return None + + element = self.get_element(locator_or_element, wait=True) + if not element or not element.is_visible(): + print(f"Element with locator '{locator_or_element}' appeared on the page.") + return True + + time.sleep(0.5) # Check every 0.5 seconds + def check_element_exists(self, locator_or_element, wait=False, timeout=5): element = self.get_element(locator_or_element, wait=wait, timeout=timeout) if element: @@ -226,8 +243,12 @@ def find_element_and_perform_action(self, locator_or_element, action, inputValue print("Checkbox is already checked.") elif action.lower() == "select_option": if element.is_visible(): - element.select_option(inputValue) - print(f"Selected option '{inputValue}' successfully.") + if isinstance(inputValue, int): + element.select_option(index=inputValue) + print(f"Selected option by index '{inputValue}' successfully.") + else: + element.select_option(value=inputValue) + print(f"Selected option by label '{inputValue}' successfully.") elif action.lower() == "clear": element.fill('') print(f"Cleared text from the element: {element}.") @@ -292,7 +313,7 @@ def release_mouse(self): self.page.mouse.down() self.page.mouse.up() - def get_element_by_type(self, locator_type_or_selector, locator_value=None, name=None): + def get_element_by_type(self, locator_type_or_selector, locator_value=None, name=None, exact=False): # If locator_type_or_selector is just a string, return it as a selector if isinstance(locator_type_or_selector, Locator): return locator_type_or_selector # Directly return the Locator object @@ -303,23 +324,23 @@ def get_element_by_type(self, locator_type_or_selector, locator_value=None, name # Handle known locator types if locator_type_or_selector == "role": - return self.page.get_by_role(locator_value, name=name) + return self.page.get_by_role(locator_value, name=name, exact=exact) elif locator_type_or_selector == "text": - return self.page.get_by_text(locator_value) + return self.page.get_by_text(locator_value, exact=exact) elif locator_type_or_selector == "label": - return self.page.get_by_label(locator_value) + return self.page.get_by_label(locator_value, exact=exact) elif locator_type_or_selector == "placeholder": return self.page.get_by_placeholder(locator_value) elif locator_type_or_selector == "xpath": return self.page.locator(locator_value) elif locator_type_or_selector == "link": - return self.page.get_by_role("link", name=locator_value) + return self.page.get_by_role("link", name=locator_value, exact=exact) elif locator_type_or_selector == "title": - return self.page.get_by_title(locator_value) + return self.page.get_by_title(locator_value, exact=exact) elif locator_type_or_selector == "row": - return self.page.get_by_role("row", name=locator_value) + return self.page.get_by_role("row", name=locator_value, exact=exact) elif locator_type_or_selector == "cell": - return self.page.get_by_role("cell", name=locator_value) + return self.page.get_by_role("cell", name=locator_value, exact=exact) else: # Log a warning for unsupported locator types print(f"Warning: Unsupported locator type '{locator_type_or_selector}'. Assuming it is a selector.") diff --git a/init_helpers.py b/init_helpers.py index c9ee0c899..c133f6b91 100644 --- a/init_helpers.py +++ b/init_helpers.py @@ -209,6 +209,13 @@ def wait_for_element_to_appear(element): element = get_element_by_type(element) return playwright_helper_instance.wait_for_element_to_appear(element) +def wait_for_element_to_disappear(element): + if isinstance(element, (tuple, list)): + element = get_element_by_type(*element) + else: + element = get_element_by_type(element) + return playwright_helper_instance.wait_for_element_to_disappear(element) + def capture_screenshot(filename): return playwright_helper_instance.capture_screenshot(filename) @@ -226,8 +233,8 @@ def click_cell_in_row(row_name, cell_index): def click_link_in_row(row_name, link_index): return playwright_helper_instance.click_link_in_row(row_name, link_index) -def get_element_by_type(locator_type, locator_value=None, name=None): - return playwright_helper_instance.get_element_by_type(locator_type, locator_value, name) +def get_element_by_type(locator_type, locator_value=None, name=None, exact=False): + return playwright_helper_instance.get_element_by_type(locator_type, locator_value, name, exact) def release_mouse(): return playwright_helper_instance.release_mouse() @@ -247,6 +254,9 @@ def date_format_with_age(date): def date_format_with_name_of_month(date): return datetime_helper_instance.date_format_with_name_of_month(date) +def date_format_with_name_of_month_shortened(date): + return datetime_helper_instance.date_format_with_name_of_month_shortened(date) + def get_date_value(date): return datetime_helper_instance.get_date_value(date) diff --git a/pages/add_vaccines_page.py b/pages/add_vaccines_page.py deleted file mode 100644 index c84b556ae..000000000 --- a/pages/add_vaccines_page.py +++ /dev/null @@ -1,67 +0,0 @@ -from init_helpers import * -from test_data.get_values_from_models import get_flu_add_vaccine_checkbox_xpath, get_covid_add_vaccine_checkbox_xpath - -ADD_VACCINE_BUTTON = ("//button[text()='Add vaccine']") -ADD_BATCHES_BUTTON = ("//button[text()='Add batches']") -SELECT_SITE_DROPDOWN = ("//select[@name='SiteId']") -BACK_BUTTON_ON_VACCINES_PAGE = ("(//a[@href='/settings'])[2]") -COVID_VACCINE_CHECK_BOX = ("//input[@class='nhsuk-checkboxes__input' and @name='VaccineProgramIds' and @value='1']") -FLU_VACCINE_CHECK_BOX = ("//input[@class='nhsuk-checkboxes__input' and @name='VaccineProgramIds' and @value='2']") -CANCEL_ADDING_VACCINES_BUTTON = ("//button[text()='Cancel']") -CONFIRM_VACCINE_CHOICES_BUTTON = ("//button[text()='Confirm choices']") -SELECT_VACCINES_LABEL = ("//legend[text()='Select vaccines']") - -def click_back_button_on_vaccines_page(): - find_element_and_perform_action(BACK_BUTTON_ON_VACCINES_PAGE, "click") - -def click_select_vaccines_label(): - release_mouse() - find_element_and_perform_action(SELECT_VACCINES_LABEL, "click") - -def click_cancel_adding_vaccines_button(): - find_element_and_perform_action(CANCEL_ADDING_VACCINES_BUTTON, "click") - -def click_confirm_vaccine_choices_button(): - find_element_and_perform_action(CONFIRM_VACCINE_CHOICES_BUTTON, "click") - -def Click_add_vaccine_button(): - if check_add_vaccine_button_exists() and check_add_vaccine_button_enabled(): - find_element_and_perform_action(ADD_VACCINE_BUTTON, "click") - -def check_add_vaccine_button_exists(): - return check_element_exists(ADD_VACCINE_BUTTON, True) - -def check_add_vaccine_button_enabled(): - return check_element_enabled(ADD_VACCINE_BUTTON, True) - -def check_confirm_choices_button_enabled(): - return check_element_enabled(CONFIRM_VACCINE_CHOICES_BUTTON, True) - -def click_site_radio_button(site): - element = (f"//label[text()='{site}']/preceding-sibling::input[@name='SiteId']") - find_element_and_perform_action(element, "click") - -def click_covid_vaccine_checkbox(): - find_element_and_perform_action(COVID_VACCINE_CHECK_BOX, "click_checkbox") - -def click_flu_vaccine_checkbox(): - find_element_and_perform_action(FLU_VACCINE_CHECK_BOX, "click_checkbox") - -def click_covid_vaccine_type_checkbox(vaccinetype): - element = get_covid_add_vaccine_checkbox_xpath(vaccinetype.lower()) - if check_element_exists(element): - find_element_and_perform_action(element, "click_checkbox") - else: - print("Invalid vaccine type") - -def click_flu_vaccine_type_checkbox(vaccinetype): - element = get_flu_add_vaccine_checkbox_xpath(vaccinetype.lower()) - if element: - find_element_and_perform_action(element, "click_checkbox") - else: - print("Invalid vaccine type") - -def check_vaccine_already_added_warning_message_exists(site, vaccine): - element = (f"//span[text()='{site} already has {vaccine}']") - return check_element_exists(element, True) - diff --git a/pages/assess_patient_page.py b/pages/assess_patient_page.py index 2ceaa362f..326cbdcf7 100644 --- a/pages/assess_patient_page.py +++ b/pages/assess_patient_page.py @@ -2,24 +2,104 @@ from init_helpers import * from pages.record_consent_page import YES_CONSENT_RADIO_BUTTON -ELIGIBLE_YES_RADIOBUTTON = ("#EligibleYes") -ELIGIBLE_NO_RADIOBUTTON = ("#EligibleNo") -ASSESSING_CLINICIAN_DROPDOWN_ELEMENT = ("#AssessmentClinicianId") -ELIGIBILITY_TYPE_DROPDOWN_ELEMENT = ("#EligibilityTypeId") -ASSESSMENT_DATE_INPUT_ELEMENT = ("#AssessmentDate") -COMMENTS_INPUT_ELEMENT = ("#AssessmentComments") -SAVE_AND_RETURN_BUTTON=("//button[text()='Save and return']") -BACK_TO_CHOOSE_VACCINE_BUTTON= ("//a[contains(@href, '/vaccination/add')]") -DATE_INPUT_ELEMENT = ("#AssessmentDate") -GIVE_VACCINE_RADIOBUTTON = ("#AssessmentOutcomeId-1") -VACCINE_NOT_GIVEN_RADIOBUTTON = ("#AssessmentOutcomeId-2") -CONTINUE_TO_RECORD_CONSENT_BUTTON = ("//button[text()='Continue']") -ASSESSMENT_NO_VACCINATION_REASON = ("#AssessmentNoVaccinationReasonId") -ASSESSMENT_DATE_INCORRECT_ERROR_MESSAGE = ("#AssessmentDateError") -STAFF_ROLE_DROPDOWN_ELEMENT = ("#StaffRoleId") -DUE_DATE_DAY = ("#ExpectedDueDateDay") -DUE_DATE_MONTH = ("#ExpectedDueDateMonth") -DUE_DATE_YEAR = ("#ExpectedDueDateYear") +ELIGIBLE_YES_RADIOBUTTON = ("label", "Yes") +ELIGIBLE_NO_RADIOBUTTON = ("label", "No") +ASSESSING_CLINICIAN_DROPDOWN_ELEMENT = ("label", "Assessing clinician") +ELIGIBILITY_TYPE_DROPDOWN_ELEMENT = ("label", "Eligibility type") +ASSESSMENT_DATE_INPUT_ELEMENT = ("label", "Assessment date") +COMMENTS_INPUT_ELEMENT = ("label", "Comments (Optional)") +SAVE_AND_RETURN_BUTTON=("role", "button" "Save and return") +BACK_TO_CHOOSE_VACCINE_BUTTON= ("link", "Back") +DATE_INPUT_ELEMENT = ("label", "Assessment date") +GIVE_VACCINE_RADIOBUTTON = ("label", "Give vaccine") +VACCINE_NOT_GIVEN_RADIOBUTTON = ("text", "Vaccine not given") +CONTINUE_TO_RECORD_CONSENT_BUTTON = ("role", "button", "Continue") +ASSESSMENT_NO_VACCINATION_REASON = ("label", "Reason vaccine not given") +ASSESSMENT_DATE_INCORRECT_ERROR_MESSAGE = ("text", "Error: Date cannot be older") +ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select an assessment date") +ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_LINK = ("text", "Select an assessment date") +EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Expected due date is required") +EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_LINK = ("text", "Expected due date is required") +ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select the assessing clinician") +ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_LINK = ("text", "Select the assessing clinician") +LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select a legal mechanism") +LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_LINK = ("text", "Select a legal mechanism") +ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select an assessment outcome") +ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_LINK = ("text", "Select an assessment outcome") +STAFF_ROLE_DROPDOWN_ELEMENT = ("label", "Staff role") +DUE_DATE_DAY = ("label", "Day") +DUE_DATE_MONTH = ("label", "Month") +DUE_DATE_YEAR = ("label", "Year") +SCREENING_CONSIDERATIONS_ELEMENT = ("text", "Screening considerations") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") + +def check_screening_considerations_exist(): + wait_for_element_to_appear(SCREENING_CONSIDERATIONS_ELEMENT) + return check_element_exists(SCREENING_CONSIDERATIONS_ELEMENT) + +def click_screening_considerations(): + wait_for_element_to_appear(SCREENING_CONSIDERATIONS_ELEMENT) + find_element_and_perform_action(SCREENING_CONSIDERATIONS_ELEMENT, "click") + +def check_assessment_date_missing_error_message_text_exists(): + wait_for_element_to_appear(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_TEXT) + +def check_assessment_date_missing_error_message_link_exists(): + wait_for_element_to_appear(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_LINK) + +def click_assessment_date_missing_error_message_link(): + wait_for_element_to_appear(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(ASSESSMENT_DATE_MISSING_ERROR_MESSAGE_LINK, "click") + +def check_expected_due_date_missing_error_message_text_exists(): + wait_for_element_to_appear(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_TEXT) + +def check_expected_due_date_missing_error_message_link_exists(): + wait_for_element_to_appear(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_LINK) + +def click_expected_due_date_missing_error_message_link(): + wait_for_element_to_appear(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(EXPECTED_DUE_DATE_MISSING_ERROR_MESSAGE_LINK, "click") + +def check_assessing_clinician_missing_error_message_text_exists(): + wait_for_element_to_appear(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_TEXT) + +def check_assessing_clinician_missing_error_message_link_exists(): + wait_for_element_to_appear(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_LINK) + +def click_assessing_clinician_missing_error_message_link(): + wait_for_element_to_appear(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(ASSESSING_CLINICIAN_MISSING_ERROR_MESSAGE_LINK, "click") + +def check_legal_mechanism_missing_error_message_text_exists(): + wait_for_element_to_appear(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_TEXT) + +def check_legal_mechanism_missing_error_message_link_exists(): + wait_for_element_to_appear(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_LINK) + +def click_legal_mechanism_missing_error_message_link(): + wait_for_element_to_appear(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(LEGAL_MECHANISM_MISSING_ERROR_MESSAGE_LINK, "click") + +def check_assessment_outcome_missing_error_message_text_exists(): + wait_for_element_to_appear(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_TEXT) + +def check_assessment_outcome_missing_error_message_link_exists(): + wait_for_element_to_appear(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_LINK) + +def click_assessment_outcome_missing_error_message_link(): + wait_for_element_to_appear(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(ASSESSMENT_OUTCOME_MISSING_ERROR_MESSAGE_LINK, "click") def select_eligibility_type(type): if check_eligibility_type_is_visible() == True: @@ -34,81 +114,94 @@ def enter_due_date(due_date): find_element_and_perform_action(DUE_DATE_YEAR, "input_text", year) def click_legal_mechanism(legal_mechanism): - xpath_map = { - "national protocol (np)": "//label[@for='LegalMechanismId-1']", - "patient group directions (pgd)": "//label[@for='LegalMechanismId-2']", - "patient specific directions (psd)": "//label[@for='LegalMechanismId-3']", - } - element = xpath_map.get(legal_mechanism.lower()) + element = ("label", legal_mechanism) if element: find_element_and_perform_action(element, "click") else: print("Invalid vaccine type") def check_eligibility_type_is_visible(): + wait_for_element_to_appear(ELIGIBILITY_TYPE_DROPDOWN_ELEMENT) return check_element_exists(ELIGIBILITY_TYPE_DROPDOWN_ELEMENT) def check_eligibility_type_is_enabled(): + wait_for_element_to_appear(ELIGIBILITY_TYPE_DROPDOWN_ELEMENT) return check_element_enabled(ELIGIBILITY_TYPE_DROPDOWN_ELEMENT) def select_assessment_no_vaccination_reason(reason): + wait_for_element_to_appear(ASSESSMENT_NO_VACCINATION_REASON) find_element_and_perform_action(ASSESSMENT_NO_VACCINATION_REASON, "select_option", reason) def select_staff_role(role): + wait_for_element_to_appear(STAFF_ROLE_DROPDOWN_ELEMENT) find_element_and_perform_action(STAFF_ROLE_DROPDOWN_ELEMENT, "select_option", role) def select_assessing_clinician_with_name_and_council(name_and_council): + wait_for_element_to_appear(ASSESSING_CLINICIAN_DROPDOWN_ELEMENT) find_element_and_perform_action(ASSESSING_CLINICIAN_DROPDOWN_ELEMENT, "select_option", name_and_council) def click_give_vaccine_radiobutton(): + wait_for_element_to_appear(GIVE_VACCINE_RADIOBUTTON) find_element_and_perform_action(GIVE_VACCINE_RADIOBUTTON, "click") def click_vaccine_not_given_radiobutton(): + wait_for_element_to_appear(VACCINE_NOT_GIVEN_RADIOBUTTON) find_element_and_perform_action(VACCINE_NOT_GIVEN_RADIOBUTTON, "click") def click_eligible_yes_radiobutton(): + wait_for_element_to_appear(ELIGIBLE_YES_RADIOBUTTON) find_element_and_perform_action(ELIGIBLE_YES_RADIOBUTTON, "click") def click_eligible_no_radiobutton(): + wait_for_element_to_appear(ELIGIBLE_NO_RADIOBUTTON) find_element_and_perform_action(ELIGIBLE_NO_RADIOBUTTON, "click") def click_back_button_on_assessing_patient_screen(): + wait_for_element_to_appear(BACK_TO_CHOOSE_VACCINE_BUTTON) find_element_and_perform_action(BACK_TO_CHOOSE_VACCINE_BUTTON, "click") def set_assessment_date(date): + wait_for_element_to_appear(ASSESSMENT_DATE_INPUT_ELEMENT) find_element_and_perform_action(ASSESSMENT_DATE_INPUT_ELEMENT, "clear") find_element_and_perform_action(ASSESSMENT_DATE_INPUT_ELEMENT, "type_text", date) def get_assessment_date_value(): + wait_for_element_to_appear(ASSESSMENT_DATE_INPUT_ELEMENT) return find_element_and_perform_action(ASSESSMENT_DATE_INPUT_ELEMENT, "get_text") def check_back_to_choose_vaccine_button_works(): - check_element_exists(BACK_TO_CHOOSE_VACCINE_BUTTON, True) + wait_for_element_to_appear(BACK_TO_CHOOSE_VACCINE_BUTTON) + return check_element_exists(BACK_TO_CHOOSE_VACCINE_BUTTON, True) def check_assessment_outcome_give_vaccine_radiobutton_exists(): + wait_for_element_to_appear(GIVE_VACCINE_RADIOBUTTON) return check_element_exists(GIVE_VACCINE_RADIOBUTTON, True) def check_assessment_date_incorrect_error_message_exists(): + wait_for_element_to_appear(ASSESSMENT_DATE_INCORRECT_ERROR_MESSAGE) return check_element_exists(ASSESSMENT_DATE_INCORRECT_ERROR_MESSAGE, False) def check_assessment_outcome_vaccine_not_given_radiobutton_exists(): + wait_for_element_to_appear(VACCINE_NOT_GIVEN_RADIOBUTTON) return check_element_exists(VACCINE_NOT_GIVEN_RADIOBUTTON, True) def click_assessment_outcome_give_vaccine_radiobutton(): - return check_element_exists(GIVE_VACCINE_RADIOBUTTON, "click") + wait_for_element_to_appear(GIVE_VACCINE_RADIOBUTTON) + find_element_and_perform_action(GIVE_VACCINE_RADIOBUTTON, "click") def click_assessment_outcome_vaccine_not_given_radiobutton(): - return check_element_exists(VACCINE_NOT_GIVEN_RADIOBUTTON, "click") + wait_for_element_to_appear(VACCINE_NOT_GIVEN_RADIOBUTTON) + find_element_and_perform_action(VACCINE_NOT_GIVEN_RADIOBUTTON, "click") def enter_comments_for_assessing_patient(comments): + wait_for_element_to_appear(COMMENTS_INPUT_ELEMENT) find_element_and_perform_action(COMMENTS_INPUT_ELEMENT, "input_text", comments) def click_save_and_return_button_on_assessment_screen(): + wait_for_element_to_appear(SAVE_AND_RETURN_BUTTON) find_element_and_perform_action(SAVE_AND_RETURN_BUTTON, "click") def click_continue_to_record_consent_button(): + wait_for_element_to_appear(CONTINUE_TO_RECORD_CONSENT_BUTTON) find_element_and_perform_action(CONTINUE_TO_RECORD_CONSENT_BUTTON, "click") - if check_assessment_date_incorrect_error_message_exists() == False: - wait_for_element_to_appear(YES_CONSENT_RADIO_BUTTON) - else: - return True + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) diff --git a/pages/check_and_confirm_vaccinated_record_page.py b/pages/check_and_confirm_vaccinated_record_page.py index 40e272cb4..a5bcb5387 100644 --- a/pages/check_and_confirm_vaccinated_record_page.py +++ b/pages/check_and_confirm_vaccinated_record_page.py @@ -2,38 +2,40 @@ from init_helpers import * from pages.patient_details_page import CHOOSE_VACCINE_BUTTON -PATIENT_NAME_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Name']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_DOB_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Date of birth']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ADDRESS_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Address']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_NHS_NUMBER_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='NHS number']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_GENDER_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Gender']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBLE_FOR_VACCINE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Eligible']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBILITY_TYPE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Eligibility type']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBILITY_ASSESSING_CLINICIAN_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Assessing clinician']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBILITY_ASSESSMENT_DATE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Assessment date']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBILITY_ASSESSMENT_OUTCOME_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Assessment outcome']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_ELIGIBILITY_ASSESSMENT_COMMENTS_LABEL_ELEMENT = ("(//div[@class='nhsuk-summary-list__row']/dt[text()='Comments']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") -CHANGE_PATIENT_ASSESSMENT_PAGE_DETAILS_BUTTON = ("//button[text()='Change assess the patient page details']") -PATIENT_CONSENT_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Consent?']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_CONSENT_GIVEN_BY_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Consent given by']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_CONSENT_NAME_OF_PERSON_CONSENTING_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Name of the person consenting']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_CONSENT_PERSON_CONSENTING_RELATIONSHIP_TO_PARENT_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Relationship to the patient']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_CONSENT_RECORDED_BY_CLINICIAN_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Consenting clinician']/following-sibling::dd[@class='nhsuk-summary-list__value']") -CHANGE_RECORD_CONSENT_PAGE_DETAILS_BUTTON = ("//button[text()='Change record consent page details']") -PATIENT_VACCINATED_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccinated?']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINATION_DATE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Date']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINE_LABEL_ELEMENT = ("(//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccine']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") -PATIENT_VACCINE_PRODUCT_LABEL_ELEMENT = ("(//div[@class='nhsuk-summary-list__row']/dt[text()='Product']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") -PATIENT_VACCINE_BATCH_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Batch']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINE_BATCH_EXPIRY_DATE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Expiry date']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINATION_SITE_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Site']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINATION_DOSE_AMOUNT_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Dose amount (ml)']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINATION_VACCINATOR_LABEL_ELEMENT = ("//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccinator']/following-sibling::dd[@class='nhsuk-summary-list__value']") -PATIENT_VACCINATION_COMMENTS_LABEL_ELEMENT = ("(//div[@class='nhsuk-summary-list__row']/dt[text()='Comments']/following-sibling::dd[@class='nhsuk-summary-list__value'])[2]") -CHANGE_VACCINATE_PAGE_DETAILS_BUTTON = ("//button[text()='Change vaccinate page details']") -CONFIRM_DETAILS_AND_SAVE_BUTTON = ("//button[text()='Confirm details and save']") -CANCEL_CONFIRM_DETAILS_BUTTON = ("//button[text()='Cancel']") -BACK_ON_CONFIRM_DETAILS_PAGE_BUTTON = ("//a[contains(@href, '/vaccination/add')]") +PATIENT_NAME_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Name']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_DOB_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Date of birth']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ADDRESS_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Address']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_NHS_NUMBER_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='NHS number']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_GENDER_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Gender']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBLE_FOR_VACCINE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Eligible']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBILITY_TYPE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Eligibility type']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBILITY_ASSESSING_CLINICIAN_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Assessing clinician']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBILITY_ASSESSMENT_DATE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Assessment date']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBILITY_ASSESSMENT_OUTCOME_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Assessment outcome']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_ELIGIBILITY_ASSESSMENT_COMMENTS_LABEL_ELEMENT = "xpath", ("(//div[@class='nhsuk-summary-list__row']/dt[text()='Comments']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") +CHANGE_PATIENT_ASSESSMENT_PAGE_DETAILS_BUTTON = ("xpath", "//button[text()='Change assess the patient page details']") +PATIENT_CONSENT_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Consent?']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_CONSENT_GIVEN_BY_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Consent given by']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_CONSENT_NAME_OF_PERSON_CONSENTING_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Name of the person consenting']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_CONSENT_PERSON_CONSENTING_RELATIONSHIP_TO_PARENT_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Relationship to the patient']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_CONSENT_RECORDED_BY_CLINICIAN_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Consenting clinician']/following-sibling::dd[@class='nhsuk-summary-list__value']") +CHANGE_RECORD_CONSENT_PAGE_DETAILS_BUTTON = ("xpath", "//button[text()='Change record consent page details']") +PATIENT_VACCINATED_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccinated?']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINATION_DATE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Date']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINE_LABEL_ELEMENT = ("xpath", "(//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccine']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") +PATIENT_VACCINE_PRODUCT_LABEL_ELEMENT = ("xpath", "(//div[@class='nhsuk-summary-list__row']/dt[text()='Product']/following-sibling::dd[@class='nhsuk-summary-list__value'])[1]") +PATIENT_VACCINE_BATCH_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Batch']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINE_BATCH_EXPIRY_DATE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Expiry date']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINATION_SITE_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Site']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINATION_DOSE_AMOUNT_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Dose amount (ml)']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINATION_VACCINATOR_LABEL_ELEMENT = ("xpath", "//div[@class='nhsuk-summary-list__row']/dt[text()='Vaccinator']/following-sibling::dd[@class='nhsuk-summary-list__value']") +PATIENT_VACCINATION_COMMENTS_LABEL_ELEMENT = ("xpath", "(//div[@class='nhsuk-summary-list__row']/dt[text()='Comments']/following-sibling::dd[@class='nhsuk-summary-list__value'])[2]") +CHANGE_VACCINATE_PAGE_DETAILS_BUTTON = ("role", "button", "Change vaccinate page details") +CONFIRM_DETAILS_AND_SAVE_BUTTON = ("role", "button", "Confirm details and save") +CANCEL_CONFIRM_DETAILS_BUTTON = ("role", "button", "Cancel") +BACK_ON_CONFIRM_DETAILS_PAGE_BUTTON = ("role", "link", "Back") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") +SEARCH_BUTTON = ("role", "button", "Search") def click_change_assess_patient_page_details_button(): find_element_and_perform_action(CHANGE_PATIENT_ASSESSMENT_PAGE_DETAILS_BUTTON, "click") @@ -46,7 +48,8 @@ def click_change_patient_vaccinate_page_details_button(): def click_confirm_details_and_save_button(): find_element_and_perform_action(CONFIRM_DETAILS_AND_SAVE_BUTTON, "click") - wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) + wait_for_element_to_appear(SEARCH_BUTTON) def check_confirm_details_and_save_button_exists(): return check_element_exists(CONFIRM_DETAILS_AND_SAVE_BUTTON) diff --git a/pages/choose_vaccines_page.py b/pages/choose_vaccines_page.py index d75a06433..815fc5768 100644 --- a/pages/choose_vaccines_page.py +++ b/pages/choose_vaccines_page.py @@ -15,7 +15,7 @@ def click_site_radiobutton(site): element = ("label", site) wait_for_element_to_appear(element) - find_element_and_perform_action(element, "click") + find_element_and_perform_action(element, "check") def click_back_button_choosing_vaccine_for_patient(): wait_for_element_to_appear(BACK_ELEMENT) @@ -30,7 +30,7 @@ def click_delivery_team_radiobutton(deliveryTeam): print("Delivery team not available at organization") def click_vaccine_type_radiobutton(vaccine_type): - element = ("label", vaccine_type) + element = ("label", vaccine_type, None, True) wait_for_element_to_appear(element) if check_element_exists(element, True) == True: find_element_and_perform_action(element, "check") diff --git a/pages/delete_vaccination_page.py b/pages/delete_vaccination_page.py index 7ed0ff756..a4188cf09 100644 --- a/pages/delete_vaccination_page.py +++ b/pages/delete_vaccination_page.py @@ -1,12 +1,17 @@ from init_helpers import * from pages.patient_details_page import CHOOSE_VACCINE_BUTTON -DELETE_VACCINATION_BUTTON=("//button[text()='Delete']") -CANCEL_VACCINATION_DELETE_BUTTON=("//button[text()='Cancel']") +DELETE_VACCINATION_BUTTON=("role", "button", "delete") +CANCEL_VACCINATION_DELETE_BUTTON=("role", "button", "Cancel") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") def click_delete_vaccination_button(): + wait_for_element_to_appear(DELETE_VACCINATION_BUTTON) find_element_and_perform_action(DELETE_VACCINATION_BUTTON, "click") wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def click_cancel_vaccination_delete_button(): - find_element_and_perform_action(CANCEL_VACCINATION_DELETE_BUTTON, "click") \ No newline at end of file + wait_for_element_to_appear(CANCEL_VACCINATION_DELETE_BUTTON) + find_element_and_perform_action(CANCEL_VACCINATION_DELETE_BUTTON, "click") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) diff --git a/pages/find_a_patient_page.py b/pages/find_a_patient_page.py index 2975cf0bb..2947e1de0 100644 --- a/pages/find_a_patient_page.py +++ b/pages/find_a_patient_page.py @@ -12,6 +12,7 @@ CLOSE_RECORD_SAVED_DIALOGUE_BUTTON = ("text", "Close") SUCCESSFULLY_SAVED_MESSAGE = ("text", "You successfully saved") VIEW_RECORD_LINK = ("text", "View record") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") # Shared NHS_NUMBER_INPUT = ("label", "Enter a 10 digit NHS number") @@ -82,7 +83,7 @@ def enter_dob(dob): def select_optional_gender(gender): gender_value = GENDER_MAPPING.get(gender) wait_for_element_to_appear(GENDER_OPTIONAL_SELECT) - find_element_and_perform_action(GENDER_OPTIONAL_SELECT, "select_option", str(gender_value)) + find_element_and_perform_action(GENDER_OPTIONAL_SELECT, "select_option", gender_value) def enter_optional_postcode(postcode): wait_for_element_to_appear(POSTCODE_OPTIONAL_INPUT) @@ -91,7 +92,7 @@ def enter_optional_postcode(postcode): def select_gender(gender): gender_value = GENDER_MAPPING.get(gender) wait_for_element_to_appear(GENDER_SELECT) - find_element_and_perform_action(GENDER_SELECT, "select_option", str(gender_value)) + find_element_and_perform_action(GENDER_SELECT, "select_option", gender_value) def enter_postcode(postcode): wait_for_element_to_appear(POSTCODE_INPUT) @@ -127,6 +128,7 @@ def check_search_for_patient_button_visible(): def click_search_for_patient_button(): wait_for_element_to_appear(SEARCH_BUTTON) find_element_and_perform_action(SEARCH_BUTTON, "click") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def click_create_a_new_patient_button(): wait_for_element_to_appear(CREATE_NEW_PATIENT_BUTTON) @@ -164,11 +166,13 @@ def check_patient_postcode_search_result_exists(postcode, wait): def check_patient_nhs_number_search_result_exists(nhsNumber, wait): element = ("role", "cell", nhsNumber) + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) wait_for_element_to_appear(element) return check_element_exists(element, wait) def check_patient_not_found_for_nhs_number_message_exists(nhsNumber, wait): element = ("role", "heading", f"No result found for {nhsNumber}") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) wait_for_element_to_appear(element) return check_element_exists(element, wait) diff --git a/pages/home_page.py b/pages/home_page.py index dd3104864..18065837c 100644 --- a/pages/home_page.py +++ b/pages/home_page.py @@ -8,14 +8,54 @@ LOGOUT_NAV_ELEMENT = ("role", "link", "Log Out") NAV_BAR_TOGGLER = ("//button[@class='navbar-toggler']") NAV_LINK_BAR_TOGGLER = ("//button[@class='navbar-toggler p-2']") +FEEDBACK_LINK = ("role", "link", "feedback (opens in a new tab)") +REPORT_AN_ISSUE_LINK = ("role", "link", "Report an issue") +CONTACT_US_LINK = ("role", "link", "Contact us") +HELP_AND_GUIDANCE_LINK = ("role", "link", "Help and guidance") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") + +def check_feedback_link_exists(): + wait_for_element_to_appear(FEEDBACK_LINK) + return check_element_exists(FEEDBACK_LINK) + +def click_feedback_link_exists(): + wait_for_element_to_appear(FEEDBACK_LINK) + find_element_and_perform_action(FEEDBACK_LINK, "click") + +def check_report_an_issue_link_exists(): + wait_for_element_to_appear(REPORT_AN_ISSUE_LINK) + return check_element_exists(REPORT_AN_ISSUE_LINK) + +def click_report_an_issue_link_exists(): + wait_for_element_to_appear(REPORT_AN_ISSUE_LINK) + find_element_and_perform_action(REPORT_AN_ISSUE_LINK, "click") + +def check_contact_us_link_exists(): + wait_for_element_to_appear(CONTACT_US_LINK) + return check_element_exists(CONTACT_US_LINK) + +def click_contact_us_link_exists(): + wait_for_element_to_appear(CONTACT_US_LINK) + find_element_and_perform_action(CONTACT_US_LINK, "click") + +def check_help_and_guidance_link_exists(): + wait_for_element_to_appear(HELP_AND_GUIDANCE_LINK) + return check_element_exists(HELP_AND_GUIDANCE_LINK) + +def click_help_and_guidance_link_exists(): + wait_for_element_to_appear(HELP_AND_GUIDANCE_LINK) + find_element_and_perform_action(HELP_AND_GUIDANCE_LINK, "click") def click_logout_button(): + wait_for_element_to_appear(LOGOUT_NAV_ELEMENT) find_element_and_perform_action(LOGOUT_NAV_ELEMENT, "click") def click_navbar_toggler(): + wait_for_element_to_appear(NAV_BAR_TOGGLER) find_element_and_perform_action(NAV_BAR_TOGGLER, "click") def click_nav_link_bar_toggler(): + wait_for_element_to_appear(NAV_LINK_BAR_TOGGLER) find_element_and_perform_action(NAV_LINK_BAR_TOGGLER, "click") def check_logout_button_exists(): @@ -26,12 +66,14 @@ def check_navbar_toggle_exists_without_waiting(): return check_element_exists(NAV_BAR_TOGGLER, False) def check_navbar_toggle_exists(): + wait_for_element_to_appear(NAV_BAR_TOGGLER) return check_element_exists(NAV_BAR_TOGGLER, True) def check_nav_link_bar_toggle_exists_without_waiting(): return check_element_exists(NAV_LINK_BAR_TOGGLER, False) def check_nav_link_bar_toggle_exists(): + wait_for_element_to_appear(NAV_LINK_BAR_TOGGLER) return check_element_exists(NAV_LINK_BAR_TOGGLER, True) def check_logout_button_exists_without_waiting(): @@ -39,16 +81,22 @@ def check_logout_button_exists_without_waiting(): def click_profile_nav_link(email): element = ("role", "link", email) + wait_for_element_to_appear(element) find_element_and_perform_action(element, "click") def click_reports_nav_link(): + wait_for_element_to_appear(REPORTS_NAV_ELEMENT) find_element_and_perform_action(REPORTS_NAV_ELEMENT, "click") def click_vaccines_nav_link(): + wait_for_element_to_appear(VACCINES_NAV_ELEMENT) find_element_and_perform_action(VACCINES_NAV_ELEMENT, "click") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def click_manage_users_nav_link(): + wait_for_element_to_appear(MANAGE_USERS_NAV_ELEMENT) find_element_and_perform_action(MANAGE_USERS_NAV_ELEMENT, "click") def click_find_a_patient_nav_link(): + wait_for_element_to_appear(FIND_A_PATIENT_NAV_ELEMENT) find_element_and_perform_action(FIND_A_PATIENT_NAV_ELEMENT, "click") diff --git a/pages/nhs_signin_page.py b/pages/nhs_signin_page.py index 9b74fd847..da67140b2 100644 --- a/pages/nhs_signin_page.py +++ b/pages/nhs_signin_page.py @@ -45,23 +45,30 @@ def enter_password(password): find_element_and_perform_action(PASSWORD_INPUT_ELEMENT, "input_text", password) def click_keep_me_signedin(): + wait_for_element_to_appear(KEEP_ME_SIGNED_IN_CHECKBOX_ELEMENT) find_element_and_perform_action(KEEP_ME_SIGNED_IN_CHECKBOX_ELEMENT, "click") def check_password_error_alert_exists(): wait_for_page_to_load() + wait_for_element_to_appear(ALERT_TEXT_PASSWORD) return check_element_exists(ALERT_TEXT_PASSWORD, True) def check_emailAddress_error_alert_exists(): + wait_for_element_to_appear(ALERT_TEXT_EMAILADDRESS) return check_element_exists(ALERT_TEXT_EMAILADDRESS, True) def check_found_some_errors_alert_exists(): + wait_for_element_to_appear(FOUND_SOME_ERRORS) return check_element_exists(FOUND_SOME_ERRORS, True) def get_password_missing_error_text(): + wait_for_element_to_appear(ALERT_TEXT_PASSWORD) return find_element_and_perform_action(ALERT_TEXT_PASSWORD, "get_text") def get_emailAddress_missing_error_text(): + wait_for_element_to_appear(ALERT_TEXT_EMAILADDRESS) return find_element_and_perform_action(ALERT_TEXT_EMAILADDRESS, "get_text") def check_unable_to_sign_in_error_exists(): + wait_for_element_to_appear(ERROR_UNABLE_TO_SIGN_IN) return check_element_exists(ERROR_UNABLE_TO_SIGN_IN, True) diff --git a/pages/patient_details_page.py b/pages/patient_details_page.py index 9e3d17034..78df06fa2 100644 --- a/pages/patient_details_page.py +++ b/pages/patient_details_page.py @@ -12,39 +12,44 @@ EXPANDED_PERTUSSIS_BUTTON = ("(//button[@class='accordion-button'])[4]") COLLAPSED_PERTUSSIS_BUTTON = ("(//button[@class='accordion-button collapsed'])[4]") CHECK_IN_AND_RETURN_BUTTON=("//button[text()='Check in and return']") -CHOOSE_VACCINE_BUTTON=("//button[text()='Choose Vaccine']") +CHOOSE_VACCINE_BUTTON=("role", "button", "Choose Vaccine") PATIENT_DID_NOT_SHOW_BUTTON=("//button[text()='Patient did not show']") -BACK_BUTTON = ("//a[@href='/appointment']") -VACCINATION_HISTORY_LABEL = ("//h3[text()='Vaccination History']") +BACK_BUTTON_ON_PATIENT_DETAILS_PAGE = ("link", "Back") SHOW_ALL_BUTTON_COVID_RECORDS = ("(//button[contains(text(), 'Show all')])[1]") SHOW_ALL_BUTTON_FLU_RECORDS = ("(//button[contains(text(), 'Show all')])[2]") -EDIT_HISTORY_BUTTON = ("//span[text()='Edit']") -DELETE_HISTORY_BUTTON = ("//span[text()='Delete']") -VACCINE_SUMMARY_LIST_ROWS_ELEMENTS = ("//dl[@class='nhsuk-summary-list mb-1']") -COVID_HISTORY_ELEMENT = "(//dt[text()='Vaccine programme']/following-sibling::dd/div[text()='COVID-19'])" -FLU_HISTORY_ELEMENT = "(//dt[text()='Vaccine programme']/following-sibling::dd/div[text()='Flu'])" -RSV_HISTORY_ELEMENT = "(//dt[text()='Vaccine programme']/following-sibling::dd/div[text()='Respiratory syncytial virus (RSV)'])" -PERTUSSIS_HISTORY_ELEMENT = "(//dt[text()='Vaccine programme']/following-sibling::dd/div[text()='Pertussis'])" +EDIT_HISTORY_BUTTON = ("xpath", "//span[text()='Edit']") +DELETE_HISTORY_BUTTON = ("xpath", "//span[text()='Delete']") +VACCINE_SUMMARY_LIST_ROWS_ELEMENTS = ("xpath", "//dl[@class='nhsuk-summary-list mb-1']") +COVID_HISTORY_ELEMENT = ("text", "COVID-19") +FLU_HISTORY_ELEMENT = ("text", "Flu") +RSV_HISTORY_ELEMENT = ("text", "Respiratory syncytial virus (RSV)") +PERTUSSIS_HISTORY_ELEMENT = ("text", "Pertussis") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") def check_covid_history_element_exists(): + wait_for_element_to_appear(COVID_HISTORY_ELEMENT) return check_element_exists(COVID_HISTORY_ELEMENT) def check_flu_history_element_exists(): + wait_for_element_to_appear(FLU_HISTORY_ELEMENT) return check_element_exists(FLU_HISTORY_ELEMENT) def check_rsv_history_element_exists(): + wait_for_element_to_appear(RSV_HISTORY_ELEMENT) return check_element_exists(RSV_HISTORY_ELEMENT) def check_pertussis_history_element_exists(): + wait_for_element_to_appear(PERTUSSIS_HISTORY_ELEMENT) return check_element_exists(PERTUSSIS_HISTORY_ELEMENT) def get_count_of_immunisation_history_records(chosen_vaccine): - count = 0 - + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) + time.sleep(2) wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) - element = (f"//h3[contains(text(), '{chosen_vaccine}')]/following-sibling::div/p[contains(text(), 'Displaying')]") + element = ("xpath", f"//h3[contains(text(), '{chosen_vaccine}')]/following-sibling::div/p[contains(text(), 'Displaying')]") + wait_for_element_to_appear(element) if check_element_exists(element, True): display_text = find_element_and_perform_action(element, "get_text") @@ -57,12 +62,16 @@ def get_count_of_immunisation_history_records(chosen_vaccine): return 0 def get_immunisation_history_details_of_vaccine(index): + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) element_selector = f"(//dl[@class='nhsuk-summary-list mb-1'])[{index}]" + element = ("xpath", element_selector) + wait_for_element_to_appear(element) vaccine_summary_list_rows_elements = find_elements(element_selector) return vaccine_summary_list_rows_elements def get_vaccine_program_details(history_index): + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) vaccine_summary_list_rows_elements = get_immunisation_history_details_of_vaccine(history_index) if vaccine_summary_list_rows_elements: vaccine_program = vaccine_summary_list_rows_elements[0].query_selector('.nhsuk-summary-list__row:nth-child(1) .nhsuk-summary-list__value').inner_text() @@ -105,8 +114,6 @@ def get_vaccine_data_source_details(history_index): return data_source else: return None -def check_vaccination_history_label_exists(): - return check_element_exists(VACCINATION_HISTORY_LABEL, True) def click_show_all_covid_history_button(): find_element_and_perform_action(SHOW_ALL_BUTTON_COVID_RECORDS, "click") @@ -171,13 +178,17 @@ def click_check_in_and_return_button(): find_element_and_perform_action(CHECK_IN_AND_RETURN_BUTTON, "click") def click_choose_vaccine_button(): + wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) find_element_and_perform_action(CHOOSE_VACCINE_BUTTON, "click") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def click_patient_did_not_show_button(): find_element_and_perform_action(PATIENT_DID_NOT_SHOW_BUTTON, "click") -def click_back_button(): - find_element_and_perform_action(BACK_BUTTON, "click") +def click_back_button_on_patient_details_page(): + wait_for_element_to_appear(BACK_BUTTON_ON_PATIENT_DETAILS_PAGE) + find_element_and_perform_action(BACK_BUTTON_ON_PATIENT_DETAILS_PAGE, "click") def check_choose_vaccine_button_exists(): + wait_for_element_to_appear(CHOOSE_VACCINE_BUTTON) return check_element_exists(CHOOSE_VACCINE_BUTTON, True) diff --git a/pages/record_consent_page.py b/pages/record_consent_page.py index c8b8ff0c7..bb406722d 100644 --- a/pages/record_consent_page.py +++ b/pages/record_consent_page.py @@ -1,56 +1,100 @@ import time from init_helpers import * -YES_CONSENT_RADIO_BUTTON=("#ConsentedYes") -NO_CONSENT_RADIO_BUTTON=("#ConsentedNo") -CONSENT_TYPE_DROPDOWN_ELEMENT = ("//select[@name='ConsentTypeId']") -CONSENT_CLINICIAN_DROPDOWN_ELEMENT = ("#ConsentClinicianId") -SAVE_AND_RETURN_BUTTON=("//button[text()='Save and return']") -CONTINUE_TO_VACCINATE_BUTTON=("//button[text()='Continue']") +YES_CONSENT_RADIO_BUTTON=("label", "Yes, they consent") +NO_CONSENT_RADIO_BUTTON=("label", "No") +CONSENT_GIVEN_BY_DROPDOWN_ELEMENT = ("label", "Consent given by") +CONSENT_CLINICIAN_DROPDOWN_ELEMENT = ("label", "Consenting clinician") +SAVE_AND_RETURN_BUTTON=("role", "button", "Save and return") +CONTINUE_TO_VACCINATE_BUTTON=("role", "button", "Continue") REQUIRED_ALERT_BUTTON = ("//span[text()='Required']") -NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT = ("#NameOfPersonConsenting") -RELATION_TO_PATIENT_INPUT_ELEMENT = ("#RelationshipToPatient") -RESPONSIBLE_CLINICIAN_INPUT_ELEMENT = ("#ConsentResponsibleClinicianId") -NO_CONSENT_REASON_DROPDOWN_ELEMENT = ("#NoConsentReasonId") -CONSENT_GIVEN_BY_DROPDOWN_ELEMENT = ("#ConsentTypeId") +NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT = ("label", "Name of the person consenting") +RELATION_TO_PATIENT_INPUT_ELEMENT = ("label", "Relationship to the patient") +NO_CONSENT_REASON_DROPDOWN_ELEMENT = ("label", "No consent reason") +CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_LINK = ("Select the person giving consent") +CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_TEXT = ("Error: Select the person giving consent") +CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_LINK = ("Select the consenting clinician") +CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_TEXT = ("Error: Select the consenting clinician") +NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_LINK = ("Select a no consent reason") +NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_TEXT = ("Error: Select a no consent reason") + +def check_consent_given_by_missing_detail_error_message_text_exists(): + wait_for_element_to_appear(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_TEXT) + return check_element_exists(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_TEXT) + +def check_consent_given_by_missing_detail_error_message_link_exists(): + wait_for_element_to_appear(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_LINK) + return check_element_exists(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_LINK) + +def click_consent_given_by_missing_detail_error_message_link(): + wait_for_element_to_appear(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_LINK) + find_element_and_perform_action(CONSENT_GIVEN_BY_MISSING_DETAIL_ERROR_MESSAGE_LINK, "click") + +def check_consent_clinician_by_missing_detail_error_message_text_exists(): + wait_for_element_to_appear(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_TEXT) + return check_element_exists(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_TEXT) + +def check_consent_clinician_missing_detail_error_message_link_exists(): + wait_for_element_to_appear(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_LINK) + return check_element_exists(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_LINK) + +def click_consent_clinician_missing_detail_error_message_link(): + wait_for_element_to_appear(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_LINK) + find_element_and_perform_action(CONSENT_CLINICIAN_MISSING_DETAIL_ERROR_MESSAGE_LINK, "click") + +def check_no_consent_reason_missing_detail_error_message_text_exists(): + wait_for_element_to_appear(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_TEXT) + return check_element_exists(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_TEXT) + +def check_no_consent_reason_missing_detail_error_message_link_exists(): + wait_for_element_to_appear(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_LINK) + return check_element_exists(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_LINK) + +def click_no_consent_reason_missing_detail_error_message_link(): + wait_for_element_to_appear(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_LINK) + find_element_and_perform_action(NO_CONSENT_REASON_MISSING_ERROR_MESSAGE_LINK, "click") def check_yes_to_consent_radiobutton_exists(): + wait_for_element_to_appear(YES_CONSENT_RADIO_BUTTON) return check_element_exists(YES_CONSENT_RADIO_BUTTON, True) def check_no_to_consent_radiobutton_exists(): + wait_for_element_to_appear(NO_CONSENT_RADIO_BUTTON) return check_element_exists(NO_CONSENT_RADIO_BUTTON, True) def click_yes_to_consent(): - find_element_and_perform_action(YES_CONSENT_RADIO_BUTTON, "click") + wait_for_element_to_appear(YES_CONSENT_RADIO_BUTTON) + find_element_and_perform_action(YES_CONSENT_RADIO_BUTTON, "check") def click_no_to_consent(): - find_element_and_perform_action(NO_CONSENT_RADIO_BUTTON, "click") + wait_for_element_to_appear(NO_CONSENT_RADIO_BUTTON) + find_element_and_perform_action(NO_CONSENT_RADIO_BUTTON, "check") def select_consent_clinician_with_name_and_council(nameandcouncil): + wait_for_element_to_appear(CONSENT_CLINICIAN_DROPDOWN_ELEMENT) if check_element_enabled(CONSENT_CLINICIAN_DROPDOWN_ELEMENT): find_element_and_perform_action(CONSENT_CLINICIAN_DROPDOWN_ELEMENT, "select_option", nameandcouncil) def select_reason_for_no_consent(reason): + wait_for_element_to_appear(NO_CONSENT_REASON_DROPDOWN_ELEMENT) find_element_and_perform_action(NO_CONSENT_REASON_DROPDOWN_ELEMENT, "select_option", reason) def select_consent_given_by_from_dropdown(givenBy): + wait_for_element_to_appear(CONSENT_GIVEN_BY_DROPDOWN_ELEMENT) find_element_and_perform_action(CONSENT_GIVEN_BY_DROPDOWN_ELEMENT, "select_option", givenBy) -def select_consentType(consentType): - find_element_and_perform_action(CONSENT_TYPE_DROPDOWN_ELEMENT, "select_option", consentType) - def click_save_and_return_button_on_record_consent_page(): + wait_for_element_to_appear(SAVE_AND_RETURN_BUTTON) find_element_and_perform_action(SAVE_AND_RETURN_BUTTON, "click") def click_continue_to_vaccinate_button(): + wait_for_element_to_appear(CONTINUE_TO_VACCINATE_BUTTON) find_element_and_perform_action(CONTINUE_TO_VACCINATE_BUTTON, "click") def check_continue_to_vaccinate_patient_button_exists(): + wait_for_element_to_appear(CONTINUE_TO_VACCINATE_BUTTON) return check_element_exists(CONTINUE_TO_VACCINATE_BUTTON) -def check_required_alert_exists(wait): - return check_element_exists(REQUIRED_ALERT_BUTTON, wait) - def check_name_of_person_consenting_input_element_exists(wait): return check_element_exists(NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT, wait) @@ -58,13 +102,16 @@ def check_relation_to_parent_input_element_exists(wait): return check_element_exists(RELATION_TO_PATIENT_INPUT_ELEMENT, wait) def check_clinician_details_input_element_exists(wait): - return check_element_exists(RESPONSIBLE_CLINICIAN_INPUT_ELEMENT, wait) + wait_for_element_to_appear(CONSENT_CLINICIAN_DROPDOWN_ELEMENT) + return check_element_exists(CONSENT_CLINICIAN_DROPDOWN_ELEMENT, wait) def enter_person_consenting_details(person): + wait_for_element_to_appear(NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT) find_element_and_perform_action(NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT, "input_text", person) def enter_relationship_to_patient(relationship): + wait_for_element_to_appear(RELATION_TO_PATIENT_INPUT_ELEMENT) find_element_and_perform_action(RELATION_TO_PATIENT_INPUT_ELEMENT, "input_text", relationship) def enter_clinician_details(clinician): - find_element_and_perform_action(RESPONSIBLE_CLINICIAN_INPUT_ELEMENT, "input_text", clinician) + find_element_and_perform_action(CONSENT_CLINICIAN_DROPDOWN_ELEMENT, "select_option", clinician) diff --git a/pages/record_vaccinated_page.py b/pages/record_vaccinated_page.py index 05f14228d..986947fcc 100644 --- a/pages/record_vaccinated_page.py +++ b/pages/record_vaccinated_page.py @@ -1,25 +1,43 @@ +import time from init_helpers import * from test_data.get_values_from_models import get_covid_vaccine_xpath, get_flu_vaccine_xpath -YES_VACCINATED_RADIO_BUTTON=("#VaccinatedYes") -NO_VACCINATED_RADIO_BUTTON=("#VaccinatedNo") -CONSENT_TYPE_DROPDOWN_ELEMENT = ("//select[@name='ConsentTypeId']") -VACCINATOR_DROPDOWN_ELEMENT = ("#VaccinatingClinicianId") -SAVE_AND_RETURN_BUTTON=("//button[text()='Save and return']") -CONTINUE_TO_CHECK_AND_CONFIRM_BUTTON=("//button[text()='Continue']") -REQUIRED_ALERT_BUTTON = ("//span[text()='Required']") -NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT = ("#NameOfPersonConsenting") -RELATION_TO_PATIENT_INPUT_ELEMENT = ("#RelationshipToPatient") -RESPONSIBLE_CLINICIAN_INPUT_ELEMENT = ("#ConsentResponsibleClinicianId") -NO_VACCINATION_REASON_DROPDOWN_ELEMENT = ("#NoVaccinationReasonId") -CONSENT_GIVEN_BY_DROPDOWN_ELEMENT = ("#ConsentTypeId") -VACCINATION_DATE_INPUT_ELEMENT = ("#VaccinationDate") -VACCINATION_COMMENTS_ELEMENT = ("#VaccinationComments") -VACCINATION_SITE_DROPDOWN_ELEMENT = ("#VaccinationSiteId") -BATCH_NUMBER_DROPDOWN_ELEMENT = ("#BatchNumber") -BATCH_EXPIRY_DATE_READONLY_ELEMENT = ("#BatchExpiryDate") -DOSE_AMOUNT_READONLY_ELEMENT = ("#DoseAmount") -VACCINATION_DATE_INCORRECT_ERROR = ("#VaccinationDateError") +YES_VACCINATED_RADIO_BUTTON=("label", "Yes") +NO_VACCINATED_RADIO_BUTTON=("label", "No") +VACCINATOR_DROPDOWN_ELEMENT = ("label","Vaccinator") +SAVE_AND_RETURN_BUTTON=("role", "button", "Save and return") +CONTINUE_TO_CHECK_AND_CONFIRM_BUTTON=("role", "button", "Continue") +NO_VACCINATION_REASON_DROPDOWN_ELEMENT = ("label", "No vaccination reason") +VACCINATION_DATE_INPUT_ELEMENT = ("label", "Vaccination Date") +VACCINATION_COMMENTS_ELEMENT = ("label", "Comments (Optional)") +VACCINATION_SITE_DROPDOWN_ELEMENT = ("label", "Vaccination site") +BATCH_NUMBER_DROPDOWN_ELEMENT = ("label", "Batch number") +BATCH_EXPIRY_DATE_READONLY_ELEMENT = ("label", "Batch expiry date") +DOSE_AMOUNT_READONLY_ELEMENT = ("label", "Dose amount (ml)") +VACCINATION_DATE_INCORRECT_ERROR_MESSAGE_TEXT = ("text", "Error: Date cannot be older than a year") +VACCINATION_DATE_INCORRECT_ERROR_MESSAGE_LINK = ("text", "Date cannot be older than a year") +VACCINATED_YES_OR_NO_SELECTION_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select 'Yes' if you have vaccinated the patient, or 'No' if you haven't") +VACCINATED_YES_OR_NO_SELECTION_MISSING_ERROR_MESSAGE_LINK = ("text", "Select 'Yes' if you have vaccinated the patient, or 'No' if you haven't") +VACCINATION_DATE_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select a vaccination date") +VACCINATION_DATE_MISSING_ERROR_MESSAGE_LINK = ("text", "Select a vaccination date") +VACCINATOR_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select the vaccinator") +VACCINATOR_MISSING_ERROR_MESSAGE_LINK = ("text", "Select the vaccinator") +VACCINATION_LOCATION_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select where the vaccination is taking place") +VACCINATION_LOCATION_MISSING_ERROR_MESSAGE_LINK = ("text", "Select where the vaccination is taking place") +VACCINE_IS_REQUIRED_ERROR_MESSAGE_TEXT = ("text", "Error: Vaccine is required") +VACCINE_IS_REQUIRED_ERROR_MESSAGE_LINK = ("text", "Vaccine is required") +VACCINATION_SITE_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select a vaccination site") +VACCINATION_SITE_MISSING_ERROR_MESSAGE_LINK = ("text", "Select a vaccination site") +BATCH_NUMBER_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Select a batch number") +BATCH_NUMBER_MISSING_ERROR_MESSAGE_LINK = ("text", "Select a batch number") +BATCH_NUMBER_EXPIRY_DATE_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Enter a batch expiry date") +BATCH_NUMBER_EXPIRY_DATE_MISSING_ERROR_MESSAGE_LINK = ("text", "Enter a batch expiry date") +BATCH_DOSE_AMOUNT_MISSING_ERROR_MESSAGE_TEXT = ("text", "Error: Dose amount (ml) is required") +BATCH_DOSE_AMOUNT_MISSING_ERROR_MESSAGE_LINK = ("text", "Dose amount (ml) is required") +YELLOW_CARD_MESSAGE_LINK = ("role", "link", "Yellow Card Report (opens a") +POST_VACCINATION_MESSAGE_LINK = ("role", "link", "COVID-19 vaccinations on NHS.") +CAREHOME_NAME_INPUT_ELEMENT = ("#CareHomeName") +PAGE_LOADING_ELEMENT = ("text", "Loading...Loading...") def get_batch_expiry_date_value(): return find_element_and_perform_action(BATCH_EXPIRY_DATE_READONLY_ELEMENT, "get_text") @@ -53,88 +71,60 @@ def select_vaccinator_name_and_council(nameandcouncil): if check_element_enabled(VACCINATOR_DROPDOWN_ELEMENT): find_element_and_perform_action(VACCINATOR_DROPDOWN_ELEMENT, "select_option", nameandcouncil) +def select_vaccination_location(location): + element = ("label", location) + find_element_and_perform_action(element, "check") + def select_vaccination_site(site): find_element_and_perform_action(VACCINATION_SITE_DROPDOWN_ELEMENT, "select_option", site) def select_batch_number(batchNumber): - #find_element_and_perform_action(BATCH_NUMBER_DROPDOWN_ELEMENT, "click") find_element_and_perform_action(BATCH_NUMBER_DROPDOWN_ELEMENT, "select_option", batchNumber) -def select_consent_given_by_from_dropdown(givenBy): - find_element_and_perform_action(CONSENT_GIVEN_BY_DROPDOWN_ELEMENT, "select_option", givenBy) - -def select_consentType(consentType): - find_element_and_perform_action(CONSENT_TYPE_DROPDOWN_ELEMENT, "select_option", consentType) - def select_reason_for_no_vaccination(reason): find_element_and_perform_action(NO_VACCINATION_REASON_DROPDOWN_ELEMENT, "select_option", reason) def click_save_and_return_button_on_record_vaccinated_page(): find_element_and_perform_action(SAVE_AND_RETURN_BUTTON, "click") + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def click_continue_to_check_and_confirm_screen_button(): + wait_for_element_to_appear(CONTINUE_TO_CHECK_AND_CONFIRM_BUTTON) + time.sleep(2) find_element_and_perform_action(CONTINUE_TO_CHECK_AND_CONFIRM_BUTTON, "click") - if check_vaccination_date_incorrect_error_exists() == True: + if check_vaccination_date_incorrect_error_message_exists() == True: return True + else: + wait_for_element_to_disappear(PAGE_LOADING_ELEMENT) def check_continue_to_check_and_confirm_screen_button_exists(): return check_element_exists(CONTINUE_TO_CHECK_AND_CONFIRM_BUTTON) -def check_required_alert_exists(wait): - return check_element_exists(REQUIRED_ALERT_BUTTON, wait) - -def check_name_of_person_consenting_input_element_exists(wait): - return check_element_exists(NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT, wait) +def check_vaccination_date_incorrect_error_message_exists(): + return check_element_exists(VACCINATION_DATE_INCORRECT_ERROR_MESSAGE_TEXT, False) -def check_vaccination_date_incorrect_error_exists(): - return check_element_exists(VACCINATION_DATE_INCORRECT_ERROR, False) +def check_vaccination_date_incorrect_error_message_link_exists(): + return check_element_exists(VACCINATION_DATE_INCORRECT_ERROR_MESSAGE_LINK, False) -def check_relation_to_parent_input_element_exists(wait): - return check_element_exists(RELATION_TO_PATIENT_INPUT_ELEMENT, wait) - -def check_clinician_details_input_element_exists(wait): - return check_element_exists(RESPONSIBLE_CLINICIAN_INPUT_ELEMENT, wait) - -def enter_person_consenting_details(person): - find_element_and_perform_action(NAME_OF_PERSON_CONSENTING_INPUT_ELEMENT, "input_text", person) - -def enter_relationship_to_patient(relationship): - find_element_and_perform_action(RELATION_TO_PATIENT_INPUT_ELEMENT, "input_text", relationship) - -def enter_clinician_details(clinician): - find_element_and_perform_action(RESPONSIBLE_CLINICIAN_INPUT_ELEMENT, "input_text", clinician) +def click_vaccination_date_incorrect_error_message_link(): + return find_element_and_perform_action(VACCINATION_DATE_INCORRECT_ERROR_MESSAGE_LINK, "click") def click_care_model_option(care_model): - element = (f'//input[@name="CareModelId"]/following-sibling::label[text()="{care_model}"]') + element = ("label", care_model) if check_element_exists(element, False): find_element_and_perform_action(element, "click") else: - print("Invalid vaccine type") - -def click_covid_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccinetype): - element = get_covid_vaccine_xpath(vaccinetype.lower()) - if element: - find_element_and_perform_action(element, "click") - else: - print("Invalid vaccine type") + print("Invalid care model") -def click_flu_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccinetype): - element = f"//input[@name='VaccineId']/following-sibling::label[text()='{vaccinetype}']" - if element: +def click_vaccine_type(vaccine_type): + element = ("label", vaccine_type, None, True) + if check_element_exists(element) == True: find_element_and_perform_action(element, "click") else: print("Invalid vaccine type") -def click_rsv_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccinetype): - element = f"//input[@name='VaccineId']/following-sibling::label[text()='{vaccinetype}']" - if element: - find_element_and_perform_action(element, "click") - else: - print("Invalid vaccine type") +def enter_care_home_details(name): + find_element_and_perform_action(CAREHOME_NAME_INPUT_ELEMENT, "input_text", name) + element = ("text", name) + find_element_and_perform_action(element, "click") -def click_pertussis_vaccine_type_radiobutton_choose_vaccine_for_patient_on_vaccinated_page(vaccinetype): - element = f"//input[@name='VaccineId']/following-sibling::label[text()='{vaccinetype}']" - if element: - find_element_and_perform_action(element, "click") - else: - print("Invalid vaccine type") diff --git a/pages/site_vaccine_batches_confirm_page.py b/pages/site_vaccine_batches_confirm_page.py index fa92e38e8..4da84ed32 100644 --- a/pages/site_vaccine_batches_confirm_page.py +++ b/pages/site_vaccine_batches_confirm_page.py @@ -1,37 +1,35 @@ from init_helpers import * -CONFIRM_BUTTON = "//button[text()='Confirm']" -ERROR_BATCH_ALREADY_EXISTS = ("#CovidBatchNumberAlreadyExistsIdError") - - -def check_site_name_is_displayed(sitename): - element = f"//div[text()='{sitename}']" +CONFIRM_ADD_VACCINE_AND_BATCH_BUTTON = ("role", "button", "Confirm") +CHANGE_SITE_BUTTON = ("role", "link", "Change site") +CHANGE_VACCINE_BUTTON = ("role", "link", "Change vaccine") +EDIT_BATCH_BUTTON = ("role", "link", "Edit batch") + +def check_site_name_is_displayed(site): + element = ("text", site) + wait_for_element_to_appear(element) return check_element_exists(element, True) - def check_vaccine_is_displayed(vaccine): - element = f"//b[text()='{vaccine}']" + element = ("text", vaccine.upper()) + wait_for_element_to_appear(element) return check_element_exists(element, True) - def check_vaccinetype_is_displayed(vaccineType): - element = f"//div[text()='{vaccineType}']" + element = ("text", vaccineType) + wait_for_element_to_appear(element) return check_element_exists(element, True) - -def check_batchNumber_is_displayed(batchnumber): - element = f"//div[text()='{batchnumber}']" +def check_batchNumber_is_displayed(batch_number): + element = ("text", batch_number) + wait_for_element_to_appear(element) return check_element_exists(element, True) - def check_date_is_displayed(date): - element = f"//div[text()='{date}']" + element = ("text", date) + wait_for_element_to_appear(element) return check_element_exists(element, True) - -def check_batch_already_exists_error_is_displayed(): - return check_element_exists(ERROR_BATCH_ALREADY_EXISTS, False) - - -def click_confirm_button(): - find_element_and_perform_action(CONFIRM_BUTTON, "click") +def click_confirm_add_vaccine_and_batch_button(): + wait_for_element_to_appear(CONFIRM_ADD_VACCINE_AND_BATCH_BUTTON) + find_element_and_perform_action(CONFIRM_ADD_VACCINE_AND_BATCH_BUTTON, "click") diff --git a/pages/site_vaccine_batches_page.py b/pages/site_vaccine_batches_page.py index e1f2532d2..fcfad82f1 100644 --- a/pages/site_vaccine_batches_page.py +++ b/pages/site_vaccine_batches_page.py @@ -26,7 +26,8 @@ def click_reactivate_batch_confirmation_button(): find_element_and_perform_action(REACTIVATE_BATCH_CONFIRMATION_BUTTON, "click") def get_first_active_batch_number_value(): - xpath = "(//tbody[@class='nhsuk-table__body']//tr[td[@role='cell'][3]//strong[text()=' Active']][1]//td[@role='cell'])[1]" + xpath = "(//tbody[@class='nhsuk-table__body']//tr[td[@role='cell'][3]//strong[text()='Active']][1]//td[@role='cell'])[1]" + wait_for_element_to_appear(("xpath", xpath)) full_text = find_element_and_perform_action(("xpath", xpath), "get_text") batch_number = full_text.replace('Batch number', '').strip() return batch_number diff --git a/pages/site_vaccines_add_batch_page.py b/pages/site_vaccines_add_batch_page.py index 397e19ab9..a9df6eb30 100644 --- a/pages/site_vaccines_add_batch_page.py +++ b/pages/site_vaccines_add_batch_page.py @@ -6,7 +6,6 @@ EXPIRY_DAY_INPUT = ("#ExpiryDate_1") EXPIRY_MONTH_INPUT = ("#ExpiryDate_2") EXPIRY_YEAR_INPUT = ("#ExpiryDate_3") -CONTINUE_BUTTON = ("//button[text()='Continue']") ADD_BATCH_TITLE = ("role", "heading", "Add batch") CONTINUE_TO_CONFIRM_BATCH_BUTTON = ("role", "button", "Continue") ERROR_MESSAGE_BATCH_ALREADY_EXISTS = ("text", "Error: Batch number already exists") @@ -17,30 +16,39 @@ ERROR_MESSAGE_LINK_ENTER_THE_BATCH_EXPIRY_DATE = ("role", "link", "Enter the expiry date") def check_batch_already_exists_error_message_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_BATCH_ALREADY_EXISTS) return check_element_exists(ERROR_MESSAGE_BATCH_ALREADY_EXISTS, False) def check_batch_already_exists_error_message_link_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_LINK_BATCH_ALREADY_EXISTS) return check_element_exists(ERROR_MESSAGE_LINK_BATCH_ALREADY_EXISTS, True) def check_enter_batch_number_error_message_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_ENTER_THE_BATCH_NUMBER) return check_element_exists(ERROR_MESSAGE_ENTER_THE_BATCH_NUMBER, True) def check_enter_batch_number_error_message_link_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_LINK_ENTER_THE_BATCH_NUMBER) return check_element_exists(ERROR_MESSAGE_LINK_ENTER_THE_BATCH_NUMBER, True) def check_enter_batch_expiry_date_error_message_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_ENTER_THE_BATCH_EXPIRY_DATE) return check_element_exists(ERROR_MESSAGE_ENTER_THE_BATCH_EXPIRY_DATE, False) def check_enter_batch_expiry_date_error_message_link_is_displayed(): + wait_for_element_to_appear(ERROR_MESSAGE_LINK_ENTER_THE_BATCH_EXPIRY_DATE) return check_element_exists(ERROR_MESSAGE_LINK_ENTER_THE_BATCH_EXPIRY_DATE, True) def click_continue_to_confirm_batch_details_button(): + wait_for_element_to_appear(CONTINUE_TO_CONFIRM_BATCH_BUTTON) find_element_and_perform_action(CONTINUE_TO_CONFIRM_BATCH_BUTTON, "click") def check_add_batch_title_exists(wait): + wait_for_element_to_appear(ADD_BATCH_TITLE) return check_element_exists(ADD_BATCH_TITLE, wait) def enter_batch_number(batch_number): + wait_for_element_to_appear(VACCINE_BATCH_NUMBER_INPUT) if check_element_exists(VACCINE_BATCH_NUMBER_INPUT, False): find_element_and_perform_action(VACCINE_BATCH_NUMBER_INPUT, "input_text", batch_number) else: @@ -49,17 +57,19 @@ def enter_batch_number(batch_number): find_element_and_perform_action(BATCH_NUMBER_SUFFIX_INPUT, "input_text", suffix) def enter_vaccine_batch_number(batch_number): + wait_for_element_to_appear(VACCINE_BATCH_NUMBER_INPUT) find_element_and_perform_action(VACCINE_BATCH_NUMBER_INPUT, "input_text", batch_number) def enter_expiry_date(expiry_date): try: day, month, year = expiry_date.split('/') + wait_for_element_to_appear(EXPIRY_DAY_INPUT) find_element_and_perform_action(EXPIRY_DAY_INPUT, "input_text", day) find_element_and_perform_action(EXPIRY_MONTH_INPUT, "input_text", month) find_element_and_perform_action(EXPIRY_YEAR_INPUT, "input_text", year) except ValueError: raise ValueError("Invalid expiry date format. Please use the format 'dd/MM/yyyy'.") -def click_continue_button(): - find_element_and_perform_action(CONTINUE_BUTTON, "click") +def click_continue_To_confirm_vaccine_details_button(): + find_element_and_perform_action(CONTINUE_TO_CONFIRM_BATCH_BUTTON, "click") diff --git a/pages/vaccinator_location_page.py b/pages/vaccinator_location_page.py index 5186a6003..a6388688b 100644 --- a/pages/vaccinator_location_page.py +++ b/pages/vaccinator_location_page.py @@ -1,41 +1,41 @@ -from init_helpers import * - -VACCINATOR_ORGANISATION_DROPDOWN_ELEMENT = ("#VaccinatorOrganisationId") -SITE_DROPDOWN_ELEMENT = ("//select[@name='SiteId']") -CARE_MODEL_DROPDOWN_ELEMENT = ("//select[@name='CareModelId']") -CONTINUE_BUTTON_ELEMENT = ("//button[@type='submit']") -CAREHOME_NAME_INPUT_ELEMENT = ("#CareHomeName") -CAREHOME_ODS_CODE_INPUT_ELEMENT = ("#CareHomeOdsCode") -CAREHOME_ADDRESS_INPUT_ELEMENT = ("#CareHomeAddress") -CAREHOME_POSTCODE_INPUT_ELEMENT = ("#CareHomePostcode") -CAREHOME_ENTER_DETAILS_MANUALLLY_CHECKBOX_ELEMENT = ("#DetailsEnteredManually") - -def select_vaccinator_organisation(vaccinatorOrganisation): - find_element_and_perform_action(VACCINATOR_ORGANISATION_DROPDOWN_ELEMENT, "select_option", vaccinatorOrganisation) - -def select_site(site): - find_element_and_perform_action(SITE_DROPDOWN_ELEMENT, "select_option", site) - attach_screenshot("user_has_selected_site") - -def select_care_model(careModel): - find_element_and_perform_action(CARE_MODEL_DROPDOWN_ELEMENT,"select_option", careModel) - attach_screenshot("user_has_selected_care_model") - -def enter_carehome_name(name): - find_element_and_perform_action(CAREHOME_NAME_INPUT_ELEMENT, "input_text", name) - # element_to_click = (f"//li[text()[contains(., '{name}')]]") - element_to_click = (f"//strong[text()='{name}']") - find_element_and_perform_action(element_to_click, "click") - attach_screenshot("user_has_entered_care_home_details") - -def enter_carehome_ods_code(odscode): - find_element_and_perform_action(CAREHOME_ODS_CODE_INPUT_ELEMENT, "input_text", odscode) - -def enter_carehome_address(address): - find_element_and_perform_action(CAREHOME_ADDRESS_INPUT_ELEMENT, "input_text", address) - -def enter_carehome_postcode(postcode): - find_element_and_perform_action(CAREHOME_POSTCODE_INPUT_ELEMENT, "input_text", postcode) - -def click_continue_to_record_a_vaccination_homepage(): - find_element_and_perform_action(CONTINUE_BUTTON_ELEMENT, "click") +# from init_helpers import * + +# VACCINATOR_ORGANISATION_DROPDOWN_ELEMENT = ("#VaccinatorOrganisationId") +# SITE_DROPDOWN_ELEMENT = ("//select[@name='SiteId']") +# CARE_MODEL_DROPDOWN_ELEMENT = ("//select[@name='CareModelId']") +# CONTINUE_BUTTON_ELEMENT = ("//button[@type='submit']") +# CAREHOME_NAME_INPUT_ELEMENT = ("#CareHomeName") +# CAREHOME_ODS_CODE_INPUT_ELEMENT = ("#CareHomeOdsCode") +# CAREHOME_ADDRESS_INPUT_ELEMENT = ("#CareHomeAddress") +# CAREHOME_POSTCODE_INPUT_ELEMENT = ("#CareHomePostcode") +# CAREHOME_ENTER_DETAILS_MANUALLLY_CHECKBOX_ELEMENT = ("#DetailsEnteredManually") + +# def select_vaccinator_organisation(vaccinatorOrganisation): +# find_element_and_perform_action(VACCINATOR_ORGANISATION_DROPDOWN_ELEMENT, "select_option", vaccinatorOrganisation) + +# def select_site(site): +# find_element_and_perform_action(SITE_DROPDOWN_ELEMENT, "select_option", site) +# attach_screenshot("user_has_selected_site") + +# def select_care_model(careModel): +# find_element_and_perform_action(CARE_MODEL_DROPDOWN_ELEMENT,"select_option", careModel) +# attach_screenshot("user_has_selected_care_model") + +# def enter_carehome_name(name): +# find_element_and_perform_action(CAREHOME_NAME_INPUT_ELEMENT, "input_text", name) +# # element_to_click = (f"//li[text()[contains(., '{name}')]]") +# element_to_click = (f"//strong[text()='{name}']") +# find_element_and_perform_action(element_to_click, "click") +# attach_screenshot("user_has_entered_care_home_details") + +# def enter_carehome_ods_code(odscode): +# find_element_and_perform_action(CAREHOME_ODS_CODE_INPUT_ELEMENT, "input_text", odscode) + +# def enter_carehome_address(address): +# find_element_and_perform_action(CAREHOME_ADDRESS_INPUT_ELEMENT, "input_text", address) + +# def enter_carehome_postcode(postcode): +# find_element_and_perform_action(CAREHOME_POSTCODE_INPUT_ELEMENT, "input_text", postcode) + +# def click_continue_to_record_a_vaccination_homepage(): +# find_element_and_perform_action(CONTINUE_BUTTON_ELEMENT, "click") diff --git a/pages/vaccines_choose_site_page.py b/pages/vaccines_choose_site_page.py index fa63c7c8b..708ce020e 100644 --- a/pages/vaccines_choose_site_page.py +++ b/pages/vaccines_choose_site_page.py @@ -1,20 +1,24 @@ from init_helpers import * -SITE_SEARCH = ("#Site") -CONTINUE_BUTTON = ("//button[text()='Continue']") +SITE_SEARCH = ("placeholder", "Enter 3 or more characters to search") +CONTINUE_TO_ADD_VACCINE_BUTTON = ("role", "button", "Continue") SITE_LIST = (".siteRows") -ERROR_BATCH_ALREADY_EXISTS = "//p[text()='Error! One or more vaccine batches already exist at a site.']" -CHOOSE_SITE_TITLE = ("//h1[text()='Choose site']") +# ERROR_BATCH_ALREADY_EXISTS = "//p[text()='Error! One or more vaccine batches already exist at a site.']" +CHOOSE_SITE_TITLE = ("role", "heading", "Choose site") def enter_site_name(site): + wait_for_element_to_appear(SITE_SEARCH) find_element_and_perform_action(SITE_SEARCH, "input_text", site) def select_site_from_list(site): - element = (f"//div[@class='siteRows' and contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '{site.lower()}')]") - find_element_and_perform_action(SITE_LIST, "click") + # element = (f"//div[@class='siteRows' and contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '{site.lower()}')]") + element = ("text", site) + wait_for_element_to_appear(element) + find_element_and_perform_action(element, "click") -def click_continue_button(): - find_element_and_perform_action(CONTINUE_BUTTON, "click") +def click_continue_to_add_vaccine_button(): + wait_for_element_to_appear(CONTINUE_TO_ADD_VACCINE_BUTTON) + find_element_and_perform_action(CONTINUE_TO_ADD_VACCINE_BUTTON, "click") def check_choose_site_title_exists(wait): wait_for_element_to_appear(CHOOSE_SITE_TITLE) diff --git a/pages/vaccines_choose_vaccine_page.py b/pages/vaccines_choose_vaccine_page.py index fc091fd48..9f1e59b42 100644 --- a/pages/vaccines_choose_vaccine_page.py +++ b/pages/vaccines_choose_vaccine_page.py @@ -1,14 +1,14 @@ from init_helpers import * -CONTINUE_BUTTON=("//button[text()='Continue']") +CONTINUE_TO_ENTER_BATCH_DETAILS_BUTTON=("role", "button", "Continue") -# def click_continue_button(): -# find_element_and_perform_action(CONTINUE_BUTTON, "click") +def click_continue_to_add_batch_button(): + find_element_and_perform_action(CONTINUE_TO_ENTER_BATCH_DETAILS_BUTTON, "click") -# def click_vaccine_radiobutton(vaccine): -# element = (f"//label[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '{vaccine.lower()}')]/preceding-sibling::input[@name='VaccineProgramId']") -# find_element_and_perform_action(element, "click") +def click_vaccine_radiobutton_on_add_vaccine_screen(vaccine): + element = ("label", vaccine.upper()) + find_element_and_perform_action(element, "click") -# def click_vaccine_type_radiobutton(vaccine_type): -# element = (f"//label[contains(text(), '{vaccine_type}')]/preceding-sibling::input[@name='VaccineId']") -# find_element_and_perform_action(element, "click") +def click_vaccine_type_radiobutton_on_add_vaccine_screen(vaccine_type): + element = ("label", vaccine_type, None, True) + find_element_and_perform_action(element, "click") diff --git a/pages/vaccines_view_products_page.py b/pages/vaccines_view_products_page.py index c568e3157..f6d4800f8 100644 --- a/pages/vaccines_view_products_page.py +++ b/pages/vaccines_view_products_page.py @@ -1,3 +1,4 @@ +from datetime import datetime from init_helpers import * import re @@ -6,12 +7,17 @@ def click_add_batch_link(): find_element_and_perform_action(ADD_BATCH_LINK, "click") -def check_batch_number_exists(batch_number, wait): - element = (f"//td[translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '{batch_number.lower()}']") +def check_batch_number_and_expiry_date_exists(batch_number, expiry_date, wait): + formatted_expiry_date = date_format_with_name_of_month_shortened(expiry_date) + element = (f"//tr[td[translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '{batch_number.lower()}']" + f" and td[normalize-space(text()) = '{formatted_expiry_date}']]") return check_element_exists(element, wait) -def check_batch_number_is_active(batch_number, wait): - element = (f"//td[translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '{batch_number.lower()}']/following-sibling::td/strong[not(contains(.,'Inactive'))]") +def check_batch_number_is_active_with_date(batch_number, expiry_date, wait): + formatted_expiry_date = date_format_with_name_of_month_shortened(expiry_date) + element = (f"//td[translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '{batch_number.lower()}']" + f"/following-sibling::td['{formatted_expiry_date}']" + f"/following-sibling::td/strong[not(contains(., 'Inactive'))]") return check_element_exists(element, wait) def click_reactivate_batch_link(batch_number): diff --git a/test_data/models/assessing_clinicians.py b/test_data/models/assessing_clinicians.py index 75230a369..2bdac3741 100644 --- a/test_data/models/assessing_clinicians.py +++ b/test_data/models/assessing_clinicians.py @@ -1,8 +1,5 @@ assessing_clinicians = [ "Mark Chapman - mark.chapman1@nhs.net", "Test Clinicians - test@nhs.net", - "Test Clinicians - test@nhs.net", - "Test Clinicians - test@nhs.net", "Paul Parker - paul.parker13@nhs.net", - "Richard Williams - rich.williams1@nhs.net" ] diff --git a/test_data/models/legal_mechanism.py b/test_data/models/legal_mechanism.py index 1349d428f..f782430e0 100644 --- a/test_data/models/legal_mechanism.py +++ b/test_data/models/legal_mechanism.py @@ -1,5 +1,6 @@ legal_mechanism = [ "National Protocol (NP)", - "Patient Group Directions (PGD)", - "Patient Specific Directions (PSD)" + "Patient Group Direction (PGD)", + "Patient Specific Direction (PSD)", + "Written Instruction (WI)" ] diff --git a/test_data/models/vaccine_type_dose_amounts.py b/test_data/models/vaccine_type_dose_amounts.py index 00ab9ab54..f31e761b4 100644 --- a/test_data/models/vaccine_type_dose_amounts.py +++ b/test_data/models/vaccine_type_dose_amounts.py @@ -6,6 +6,9 @@ "Comirnaty 10 JN.1": 0.3, "Spikevax XBB.1.5": 0.5, "Spikevax JN.1": 0.5, + "Comirnaty 30 JN.1": 0.3, + "Comirnaty 10 JN.1": 0.3, + "Comirnaty 3 JN.1": 0.3, "Quadrivalent Influenza vaccine - QIVe": 0.5, "Flucelvax Tetra - QIVc": 0.5, "Supemtek - QIVr": 0.5, @@ -14,6 +17,11 @@ "Fluenz LAIV – Astra Zeneca": 0.2, "Influvac sub-unit Tetra (QIVe surface antigen) - Viatri": 0.5, "Quadrivalent Influenza Vaccine (Split Virion, Inactivated) High-Dose – QIV-HD - Sanofi": 0.5, + "Cell-based Quadrivalent Influenza Vaccine": 0.5, + "Quadrivalent Influenza Vaccine": 0.5, + "Influenza Tetra MYL": 0.5, + "Quadrivalent Influenza Vaccine – High Dose": 0.7, + "Adjuvanted Quadrivalent Influenza Vaccine": 0.5, "Adacel vaccine suspension": 0.5, "Boostrix-IPV suspension": 0.5, "Repevax vaccine suspension": 0.5, diff --git a/tests/test_add_vaccine_batches_steps.py b/tests/test_add_vaccine_batches_steps.py index 821c10085..76aeb9597 100644 --- a/tests/test_add_vaccine_batches_steps.py +++ b/tests/test_add_vaccine_batches_steps.py @@ -2,7 +2,6 @@ from pytest_bdd import given, when, then, scenarios, scenario from pytest_bdd.parsers import parse, cfparse from pages.vaccinator_location_page import * -from pages.add_vaccines_page import * from pages.settings_page import * from pages.vaccines_page import * from pages.site_vaccine_batches_page import * diff --git a/tests/test_add_vaccine_steps.py b/tests/test_add_vaccine_steps.py index 46b94f58a..63bcc4c5f 100644 --- a/tests/test_add_vaccine_steps.py +++ b/tests/test_add_vaccine_steps.py @@ -2,7 +2,6 @@ from pytest_bdd import given, when, then, scenarios, scenario from pytest_bdd.parsers import parse, cfparse from pages.vaccinator_location_page import * -from pages.add_vaccines_page import * from pages.settings_page import * from pages.vaccines_page import * import logging @@ -55,11 +54,6 @@ def i_select_site_vaccine_and_vaccinetype(site, vaccine, vaccine_type, shared_da shared_data['site'] = site shared_data['vaccineType'] = vaccine_type -@then("the vaccine is already added to site warning should appear") -def vaccine_already_added_warning_should_exist(shared_data): - attach_screenshot("vaccine_already_added_warning_message_exists") - assert check_vaccine_already_added_warning_message_exists(shared_data['site'], shared_data['vaccineType']) == True - @then("the choose site page should be launched") def the_choose_site_page_is_launched(): attach_screenshot("choose_site_page_should_launch") diff --git a/tests/test_age_based_warnings_steps.py b/tests/test_age_based_warnings_steps.py index f0c99b9b1..766554cbb 100644 --- a/tests/test_age_based_warnings_steps.py +++ b/tests/test_age_based_warnings_steps.py @@ -83,12 +83,12 @@ def step_warning_messages_should_be_displayed(expected_warning_count, shared_dat shared_data['eligibility_assessment_outcome'] = get_assessment_outcome(0) shared_data['eligibility_assessment_no_vaccine_given_reason'] = get_assess_vaccine_not_given_reason(shared_data["index"]) shared_data['assessment_comments'] = "Assessment comments " + assess_date - assess_patient_with_details_and_click_continue_to_consent("yes", shared_data['eligibility_type'], shared_data["healthcare_worker"], shared_data['eligibility_assessing_clinician'], None ,assess_date, shared_data['legal_mechanism'], shared_data['eligibility_assessment_outcome'], shared_data['assessment_comments'],shared_data['eligibility_assessment_no_vaccine_given_reason']) + assess_patient_with_details_and_click_continue_to_consent("yes", shared_data['eligibility_type'], shared_data["healthcare_worker"], shared_data['eligibility_assessing_clinician'], None ,assess_date, shared_data['legal_mechanism'], shared_data['eligibility_assessment_outcome'], shared_data['assessment_comments'], shared_data['eligibility_assessment_no_vaccine_given_reason']) shared_data['consent_decision'] = "yes" shared_data['consent_given_by'] = get_consent_given_by(shared_data["index"]) name_of_person_consenting = "Automation tester" relationship_to_patient = "RAVS tester" - if shared_data['legal_mechanism'] == "Patient Group Directions (PGD)": + if shared_data['legal_mechanism'] == "Patient Group Direction (PGD)": shared_data['consent_clinician_details'] = shared_data['eligibility_assessing_clinician'] else: shared_data['consent_clinician_details'] = get_consenting_clinician(shared_data["index"]) @@ -99,7 +99,7 @@ def step_warning_messages_should_be_displayed(expected_warning_count, shared_dat chosen_vaccine = shared_data["chosen_vaccine"] shared_data["vaccination_site"] = get_vaccination_site(shared_data["index"]) shared_data["dose_amount"] = str(get_vaccine_dose_amount(shared_data["chosen_vaccine"])) - if shared_data['legal_mechanism'] == "Patient Group Directions (PGD)": + if shared_data['legal_mechanism'] == "Patient Group Direction (PGD)": shared_data['vaccinator'] = shared_data['eligibility_assessing_clinician'] else: shared_data["vaccinator"] = get_vaccinator(shared_data["index"]) diff --git a/tests/test_find_a_patient_steps.py b/tests/test_find_a_patient_steps.py index 1951ec484..9c5d8f394 100644 --- a/tests/test_find_a_patient_steps.py +++ b/tests/test_find_a_patient_steps.py @@ -38,7 +38,6 @@ def test_find_a_patient_page_should_launch(navigate_and_login): @given('I am on the find a patient by pds details page') def given_im_on_the_find_a_patient_by_pds_details_page(navigate_and_login): - click_continue_to_record_a_vaccination_homepage() if config["browser"] == "mobile": if check_nav_link_bar_toggle_exists(): click_nav_link_bar_toggler() @@ -46,7 +45,6 @@ def given_im_on_the_find_a_patient_by_pds_details_page(navigate_and_login): click_search_by_demographics_link() def step_select_site_and_care_model(site, care_model): - click_continue_to_record_a_vaccination_homepage() if config["browser"] == "mobile": if check_nav_link_bar_toggle_exists(): click_nav_link_bar_toggler() diff --git a/tests/test_record_a_vaccine_for_patient_with_nhs_number_steps.py b/tests/test_record_a_vaccine_for_patient_with_nhs_number_steps.py index 996a90ff9..26b594ed3 100644 --- a/tests/test_record_a_vaccine_for_patient_with_nhs_number_steps.py +++ b/tests/test_record_a_vaccine_for_patient_with_nhs_number_steps.py @@ -4,7 +4,6 @@ from pytest_bdd import given, when, then, scenarios, scenario from pytest_bdd.parsers import parse, cfparse from pages.vaccinator_location_page import * -from pages.add_vaccines_page import * from pages.settings_page import * from pages.vaccines_page import * from pages.site_vaccine_batches_page import * @@ -90,14 +89,14 @@ def step_assess_eligibility_and_click_continue_record_consent_screen(shared_data shared_data['assessment_comments'] = "Assessment comments " + assess_date + shared_data["patient_name"] assess_patient_with_details_and_click_continue_to_consent(eligibility, shared_data['eligibility_type'], shared_data["healthcare_worker"], shared_data['eligibility_assessing_clinician'], None, assess_date, shared_data['legal_mechanism'], shared_data['eligibility_assessment_outcome'], shared_data['assessment_comments'],shared_data['eligibility_assessment_no_vaccine_given_reason']) -@when(parse("I assess the pregnant patient's {eligibility} with the details and date as {assess_date} and click continue to record consent screen button")) -def step_assess_eligibility_and_click_continue_record_consent_screen(shared_data, eligibility, assess_date): +@when(parse("I assess the pregnant patient's {eligibility} with the details of due date as {due_date} and assessment date as {assess_date} and click continue to record consent screen button")) +def step_assess_eligibility_and_click_continue_record_consent_screen(shared_data, eligibility, due_date, assess_date): shared_data['eligible_decision'] = eligibility shared_data['legal_mechanism'] = get_legal_mechanism(shared_data["index"]) shared_data['eligibility_type'] = "Pregnancy" shared_data["healthcare_worker"] = get_staff_role(shared_data["index"]) shared_data['eligibility_assessing_clinician'] = get_random_assessing_clinician() - due_date = format_date(str(get_date_value(assess_date)), config["browser"]) + due_date = format_date(str(get_date_value(due_date)), config["browser"]) shared_data['eligibility_due_date'] = due_date assess_date = format_date(str(get_date_value(assess_date)), config["browser"]) shared_data['eligibility_assessment_date'] = assess_date @@ -113,12 +112,12 @@ def step_record_consent_and_click_continue_to_vaccinate_screen(shared_data, cons shared_data['consent_given_by'] = get_consent_given_by(shared_data["index"]) name_of_person_consenting = "Automation tester" relationship_to_patient = "RAVS tester" - if shared_data['legal_mechanism'] == "Patient Group Directions (PGD)": + if shared_data['legal_mechanism'] == "Patient Group Direction (PGD)": shared_data['consent_clinician_details'] = shared_data['eligibility_assessing_clinician'] else: shared_data['consent_clinician_details'] = get_consenting_clinician(shared_data["index"]) shared_data["no_consent_reason"] = get_no_consent_reason(shared_data["index"]) - record_consent_details_and_click_continue_to_vaccinate(shared_data['consent_decision'],shared_data['consent_given_by'], name_of_person_consenting, relationship_to_patient, shared_data['consent_clinician_details'], shared_data["no_consent_reason"]) + record_consent_details_and_click_continue_to_vaccinate(shared_data['consent_decision'],shared_data['consent_given_by'], name_of_person_consenting, relationship_to_patient, shared_data['consent_clinician_details'], shared_data['legal_mechanism'], shared_data["no_consent_reason"]) @when(parse("I record {vaccination} details and date as {vaccination_date} and click Continue to Check and confirm screen")) def step_enter_vaccination_details_and_continue_to_check_and_confirm_screen(shared_data, vaccination, vaccination_date): @@ -129,13 +128,13 @@ def step_enter_vaccination_details_and_continue_to_check_and_confirm_screen(shar chosen_vaccine = shared_data["chosen_vaccine"] shared_data["vaccination_site"] = get_vaccination_site(shared_data["index"]) shared_data["dose_amount"] = str(get_vaccine_dose_amount(shared_data["chosen_vaccine_type"])) - if shared_data['legal_mechanism'] == "Patient Group Directions (PGD)": + if shared_data['legal_mechanism'] == "Patient Group Direction (PGD)": shared_data['vaccinator'] = shared_data['eligibility_assessing_clinician'] else: shared_data["vaccinator"] = get_vaccinator(shared_data["index"]) shared_data["vaccination_comments"] = shared_data["chosen_vaccine_type"] + "vaccination given on " + shared_data["vaccination_date"] + " for " + shared_data["patient_name"] shared_data["no_vaccination_reason"] = get_vaccination_not_given_reason(shared_data["index"]) - enter_vaccine_details_and_click_continue_to_check_and_confirm(shared_data["vaccinated_decision"], shared_data["care_model"], shared_data["vaccination_date"], chosen_vaccine, shared_data["chosen_vaccine_type"], shared_data["vaccination_site"], shared_data["batch_number"], shared_data["batch_expiry_date"], shared_data["dose_amount"], shared_data["vaccinator"], shared_data["vaccination_comments"], shared_data["no_vaccination_reason"]) + enter_vaccine_details_and_click_continue_to_check_and_confirm(shared_data["vaccinated_decision"], shared_data["care_model"], shared_data["vaccination_date"], chosen_vaccine, shared_data["chosen_vaccine_type"], shared_data["vaccination_site"], shared_data["batch_number"], shared_data["batch_expiry_date"], shared_data["dose_amount"], shared_data["vaccinator"], shared_data["vaccination_comments"], shared_data["legal_mechanism"], shared_data["no_vaccination_reason"]) attach_screenshot("entered_vaccination_details") @then(parse("I need to be able to see the patient {name}, {dob}, {address} and vaccination details on the check and confirm screen")) @@ -176,7 +175,6 @@ def click_confirm_and_save_button_immunisation_history_should_be_updated(shared_ attach_screenshot("patient_details_screen_with_immunisation_history") if shared_data["vaccinated_decision"].lower() == "yes" and shared_data["consent_decision"].lower() == "yes" and shared_data["eligibility_assessment_outcome"].lower() == "give vaccine": click_confirm_details_and_save_button() - immunisation_history_records_count_after_vaccination = get_count_of_immunisation_history_records(shared_data["chosen_vaccine"]) assert int(immunisation_history_records_count_after_vaccination) >= int(shared_data["immunisation_history_records_count_before_vaccination"]) + 1 # assert get_vaccine_program_details(index) == shared_data["chosen_vaccine"] @@ -190,4 +188,3 @@ def click_confirm_and_save_button_immunisation_history_should_be_updated(shared_ immunisation_history_records_count_after_vaccination = get_count_of_immunisation_history_records(shared_data["chosen_vaccine"]) assert int(immunisation_history_records_count_after_vaccination) == int(shared_data["immunisation_history_records_count_before_vaccination"]) shared_data.clear() -