def make_valid_session(self, condition, session_type, scenario_code): session_info.reset_session_info() session_info.info_dict['scenario_code'] = scenario_code interactions.press(self, elements.product) interactions.wait(3) if interactions.is_element_displayed(self, elements.presentations_activity): interactions.press(self, elements.product) valid_session_conditional_helper(self, condition, session_type) interactions.wait(1) interactions.press(self, elements.home_btn) interactions.wait(1)
def valid_session_conditional_helper(self, condition, session_type): interactions.wait(1) session_start_time = reporting.set_time_marker() session_info.info_dict['start_time'] = str(session_start_time) interactions.swipe_some_slides(self, 2, "left", 7) if condition == "swiping": pass elif condition == "locked": lock_duration = rules.lock_and_calculate_duration(self, 60) rules.dock_duration(lock_duration, 0) elif condition == "in_background": background_duration = rules.send_to_background_and_calculate_duration( self, 60) rules.dock_duration(0, background_duration) elif condition == "locked_and_in_background": lock_duration = rules.lock_and_calculate_duration(self, 60) interactions.swipe_some_slides(self, 2, "left", 7) background_duration = rules.send_to_background_and_calculate_duration( self, 60) rules.dock_duration(lock_duration, background_duration) elif condition == "thumbnails": rules.open_thumbnails_and_calculate_duration(self, 60, choice=None) interactions.wait(2) interactions.swipe_rest_of_slides(self, 3, "left", 7) interactions.wait(2) session_end_time = reporting.set_time_marker() session_info.info_dict['end_time'] = str(session_end_time) raw_duration_in_seconds = reporting.get_duration_in_seconds( session_start_time, session_end_time) session_info.info_dict['raw_duration_in_seconds'] = str( raw_duration_in_seconds) session_info.info_dict['duration_in_seconds'] = str( raw_duration_in_seconds) reporting.report_session(session_info.info_dict, session_type, session_start_time)
def assign(self, assignation_type): interactions.wait(1) interactions.press(self, elements.detail_btn) interactions.wait(1) if assignation_type == "as_study": interactions.press(self, elements.study_session_btn) elif assignation_type == "to_doctor": interactions.press(self, elements.assign_detail_btn) interactions.wait(1) doctors_list = interactions.get_elements_list(self, elements.doctors_list) doctors_list[2].click() interactions.press(self, elements.workplace) interactions.press(self, elements.submit_detail_btn) interactions.press(self, elements.close_detail_btn)
def open_thumbnails_and_calculate_duration(self, duration, choice): thumbnails_start_time = reporting.set_time_marker() interactions.press(self, elements.thumbnails_btn) interactions.wait(duration) if duration > 300: answer_inactivity_prompt(self, duration, choice) interactions.wait(1) else: interactions.press(self, elements.thumbnails_btn) interactions.wait(1) thumbnails_end_time = reporting.set_time_marker() thumbnails_duration_in_seconds = reporting.get_duration_in_seconds(thumbnails_start_time, thumbnails_end_time) session_info.info_dict['thumbnails_duration_in_seconds'] = str(thumbnails_duration_in_seconds)
def swipe_rest_of_slides_and_press_home_btn(self, current_slide): interactions.swipe_rest_of_slides(self, current_slide, "left", 7) interactions.wait(1) interactions.press(self, elements.home_btn) interactions.wait(1)
def swipe_and_answer_inactivity_prompt(self, inactivity_duration, prompt_choice): interactions.wait(2) interactions.swipe_rest_of_slides(self, 3, "left", 7) interactions.wait(inactivity_duration) rules.answer_inactivity_prompt(self, inactivity_duration, prompt_choice)
def valid_inactive_session_conditional_helper(self, condition, session_type, inactivity_duration, prompt_choice): interactions.wait(1) session_start_time = reporting.set_time_marker() session_info.info_dict['start_time'] = str(session_start_time) interactions.swipe_some_slides(self, 2, "left", 7) if condition == "swiping": swipe_and_answer_inactivity_prompt(self, inactivity_duration, prompt_choice) elif condition == "locked": interactions.swipe_rest_of_slides(self, 3, "left", 7) lock_duration = rules.lock_and_calculate_duration( self, inactivity_duration) rules.dock_duration(lock_duration, 0) rules.answer_inactivity_prompt(self, inactivity_duration, prompt_choice) elif condition == "in_background": interactions.swipe_rest_of_slides(self, 3, "left", 7) background_duration = rules.send_to_background_and_calculate_duration( self, inactivity_duration) rules.dock_duration(0, background_duration) rules.answer_inactivity_prompt(self, inactivity_duration, prompt_choice) elif condition == "locked_and_in_background": lock_duration = rules.lock_and_calculate_duration( self, inactivity_duration) rules.answer_inactivity_prompt(self, inactivity_duration, "cancel") interactions.swipe_some_slides(self, 2, "left", 7) background_duration = rules.send_to_background_and_calculate_duration( self, inactivity_duration) rules.dock_duration(lock_duration, background_duration) rules.answer_inactivity_prompt(self, inactivity_duration, prompt_choice) if prompt_choice == "cancel": interactions.swipe_rest_of_slides(self, 5, "left", 7) elif condition == "thumbnails": rules.open_thumbnails_and_calculate_duration(self, inactivity_duration, prompt_choice) if prompt_choice == "cancel": interactions.wait(2) interactions.swipe_rest_of_slides(self, 3, "left", 7) elif condition == "crashed": interactions.swipe_rest_of_slides(self, 3, "left", 7) interactions.terminate_app(self) session_end_time = reporting.set_time_marker() session_info.info_dict['end_time'] = str(session_end_time) raw_duration_in_seconds = reporting.get_duration_in_seconds( session_start_time, session_end_time) session_info.info_dict['raw_duration_in_seconds'] = str( raw_duration_in_seconds) session_info.info_dict['duration_in_seconds'] = str( raw_duration_in_seconds) reporting.report_session(session_info.info_dict, session_type, session_start_time)