def confirm_calculated_value(context, obs_type, value_to_check, expected_value): """ Gets and verifies a value (clinical risk or score) displayed in the submission confirmation popup Expected Data examples: .. code-block:: gherkin Then the Full Score submitted is 12 :param context: behave driver :param obs_type: specifies using regex or locators to match against the value_to_check parameter :param value_to_check: The value 'name' to look for. Refers to a specific locator in the page, by text :param expected_value: the value expected. :return: boolean """ popup_options = ModalPage(context.driver) modals = popup_options.get_open_modals() submit_modal = modals[0] if obs_type == 'Partial': displayed_value = popup_options.get_modal_content(submit_modal) modal_regex = get_string_regex(value_to_check) regex_match = modal_regex.search(displayed_value) assert regex_match.groups()[0] == expected_value, \ "Expected clinical risk '{}' not displayed.".format(expected_value) else: form_page = DataEntryPage(context.driver) displayed_value = form_page.get_clinical_risk_in_popup(value_to_check) assert expected_value in displayed_value, \ "Expected clinical risk '{}' not displayed.".format(expected_value)
def confirm_submit_scored_ob(self): """ Confirm the 'Submit Score of X for Y, Z' modal that pops up after first pressing the submit button for scored observations. """ modal_page = ModalPage(self.driver) modals = modal_page.get_open_modals() scored_modal = modals[0] modal_page.click_modal_option(scored_modal, 'Submit')
def submit_cancellation_reason(self, cancel_reason): """ Select the specified cancellation reason and submit the modal to cancel the task :param cancel_reason: Name of reason to select """ modal_page = ModalPage(self.driver) modals = modal_page.get_open_modals() cancel_modal = modals[0] modal_page.select_reason_in_modal(cancel_modal, cancel_reason) modal_page.click_modal_option(cancel_modal, 'Submit')
def select_partial_reason_in_popup(context, reason): """ Selects specified reason in the drop-down and submits the selection in the reason for partial obs popup :param context: behave context :param reason: reason to be selected in the drop-down """ popup_options = ModalPage(context.driver) modals = popup_options.get_open_modals() submit_modal = modals[0] popup_options.select_reason_in_modal(submit_modal, reason) popup_options.click_modal_option(submit_modal, 'Submit')
def take_escalation_task(self): """ Take the escalation task presented to the user once an observation that has escalation tasks is submitted """ modal_page = ModalPage(self.driver) modals = modal_page.get_open_modals() escalation_modal = modals[0] escalation_modal_options = \ modal_page.get_modal_options(escalation_modal) if len(escalation_modal_options) > 1: modal_page.click_modal_option(escalation_modal, 'Confirm') else: modal_page.click_modal_option(escalation_modal, 'Go to My Tasks')
def confirm_reason_popup_displayed(context, modal_title): """ Checks that the title (text) of the expected popup matches that of the one displayed :param context: behave context :param modal_title: String. The title expected in the popup :return: boolean """ modals_page = ModalPage(context.driver) modals = modals_page.get_open_modals() submit_modal = modals[0] assert modal_title in modals_page.get_modal_title(submit_modal), \ "Expected title '{}' not presented".format(modal_title)
def confirm_observation_submission(context, obs_name): """ Verifies the correct message and observation name is displayed upon confirming the submission of an observation form :param context: behave context :param obs_name: name of the observation expected :return: boolean """ form_page = DataEntryPage(context.driver) form_page.confirm_submit_scored_ob() modal_page = ModalPage(context.driver) modals = modal_page.get_open_modals() submit_modal = modals[0] expected_modal_title = 'Successfully Submitted {} Observation'.format( obs_name) actual_modal_title = modal_page.get_modal_title(submit_modal) assert expected_modal_title == actual_modal_title, \ "The expected modal title is '{}' but the actual modal title is {}"\ .format(expected_modal_title, actual_modal_title)