def borrar_archivo_claro_drive(webdriver_test_ux: WebDriver, json_eval, nombre_archivo_sin_ext: str, ext_archivo: str): nombre_completo_de_la_imagen = '{}{}'.format(nombre_archivo_sin_ext, ext_archivo) tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() # verifica que se haya iniciado sesion correctamente if not UtilsEvaluaciones.se_ingreso_correctamente_a_la_sesion( json_eval): json_eval = UtilsEvaluaciones.generar_json_inicio_de_sesion_incorrecta( json_eval, tiempo_step_inicio, fecha_inicio, 4, const_claro_drive. MSG_OUTPUT_BORRADO_ARCHIVO_MSG_ERROR_INICIO_SESION) return json_eval # verifica que se haya iniciado sesion correctamente if not UtilsEvaluaciones.se_cargo_correctamente_el_fichero(json_eval): json_eval = UtilsEvaluaciones.generar_json_inicio_de_sesion_incorrecta( json_eval, tiempo_step_inicio, fecha_inicio, 4, const_claro_drive. MSG_OUTPUT_BORRADO_ARCHIVO_MSG_ERROR_CARGA_ARCHIVO) return json_eval try: action = ActionChains(webdriver_test_ux) HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) UtilsEvaluaciones.esperar_aparicion_modal_de_exito( webdriver_test_ux) UtilsEvaluaciones.esperar_desaparicion_modal_exito( webdriver_test_ux) archivo_localizado_por_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, xpath=const_claro_drive. BORRAR_ARCHIVO_XPATH_ARCHIVO_POR_DESCARGAR.format( nombre_archivo_sin_ext)) action.move_to_element(archivo_localizado_por_descargar) action.perform() lista_de_divs_de_archivos = webdriver_test_ux.find_elements_by_class_name( const_claro_drive.BORRAR_ARCHIVO_CLASS_NAME_FILENAME) if len(lista_de_divs_de_archivos) != 0: for div in lista_de_divs_de_archivos: nombre_archivo_sin_extension_obtenido = div.find_element_by_class_name( const_claro_drive. BORRAR_ARCHIVO_CLASS_NAME_NAME_WITHOUT_EXT ).get_attribute( const_claro_drive.BORRAR_ARCHIVO_ATTR_INNER_TEXT) nombre_archivo_sin_extension_obtenido = nombre_archivo_sin_extension_obtenido.strip( ) extension_del_archivo_obtenido = webdriver_test_ux.find_element_by_class_name( const_claro_drive.BORRAR_ARCHIVO_EXT).get_attribute( const_claro_drive.BORRAR_ARCHIVO_ATTR_INNER_TEXT) extension_del_archivo_obtenido = extension_del_archivo_obtenido.strip( ) nombre_archivo_formateado = '{}{}'.format( nombre_archivo_sin_extension_obtenido, extension_del_archivo_obtenido) if nombre_archivo_formateado == nombre_completo_de_la_imagen: lista_botones = div.find_elements_by_class_name( const_claro_drive.BORRAR_ARCHIVO_CLASS_NAME_ACTION) HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) if len(lista_botones) > 0: boton_borrar_archivo = lista_botones[-7] HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) tiempo_step_inicio = Temporizador.obtener_tiempo_timer( ) HtmlActions.click_en_elemento_html_con_intentos( boton_borrar_archivo, 5, class_name=const_claro_drive. BORRAR_ARCHIVO_CLASS_NAME_ACTION) # HtmlActions.click_html_element( # boton_borrar_archivo, class_name=const_claro_drive.BORRAR_ARCHIVO_CLASS_NAME_ACTION) HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) UtilsEvaluaciones.esperar_aparicion_modal_de_exito( webdriver_test_ux) UtilsEvaluaciones.esperar_desaparicion_modal_exito( webdriver_test_ux) break json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, True, const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_EXITOSO) except NoSuchElementException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except TimeoutException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except ElementNotInteractableException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 4, tiempo_step_inicio, fecha_inicio) return json_eval
def borrar_archivo_claro_drive(webdriver_test_ux: WebDriver, json_eval, nombre_archivo_sin_ext: str, ext_archivo: str): nombre_completo_de_la_imagen = '{}{}'.format(nombre_archivo_sin_ext, ext_archivo) tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() # verifica que se haya iniciado sesion correctamente if not UtilsEvaluaciones.se_ingreso_correctamente_a_la_sesion( json_eval): json_eval = UtilsEvaluaciones.generar_json_inicio_de_sesion_incorrecta( json_eval, tiempo_step_inicio, fecha_inicio, 4, const_claro_drive. MSG_OUTPUT_BORRADO_ARCHIVO_MSG_ERROR_INICIO_SESION) return json_eval # verifica que se haya iniciado sesion correctamente if not UtilsEvaluaciones.se_cargo_correctamente_el_fichero(json_eval): json_eval = UtilsEvaluaciones.generar_json_inicio_de_sesion_incorrecta( json_eval, tiempo_step_inicio, fecha_inicio, 4, const_claro_drive. MSG_OUTPUT_BORRADO_ARCHIVO_MSG_ERROR_CARGA_ARCHIVO) return json_eval try: HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) # localiza el archivo a eliminar en el portal archivo_localizado_por_descargar = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 20, class_name='filename') # verifica que ya no se presente una modal de exito, para no interrumpir los clics en el portal HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) # se localiza el boton de sub menu del archivo a borrar boton_sub_menu_actions = HtmlActions.webdriver_wait_presence_of_element_located( archivo_localizado_por_descargar, 20, class_name='open-menu') # se realiza un clic en el boton del submenu (en caso de fallar, se hacen dos intentos mas) HtmlActions.click_en_elemento_html_con_intentos( boton_sub_menu_actions, numero_de_intentos=3, class_name='open-menu') #HtmlActions.click_html_element(boton_sub_menu_actions, class_name='open-menu') # se busca el boton de eliminar, el cual contiene el submenu boton_eliminar = HtmlActions.webdriver_wait_presence_of_element_located( boton_sub_menu_actions, 20, xpath='//li[@class="delete action"]') # se verifica que no este presente la modal de algun mensaje, para que no # intervenga en el clic al boton de eliminar HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) # se realiza un clic al boton de eliminar HtmlActions.click_html_element( boton_eliminar, xpath='//li[@class="delete action"]') # se empieza a tomar el tiempo de duracion de la eliminacion del archivo tiempo_step_inicio = Temporizador.obtener_tiempo_timer() UtilsEvaluaciones.esperar_aparicion_modal_de_exito( webdriver_test_ux) # se establecen los resultados exitosos en el json json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, True, const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_EXITOSO) except NoSuchElementException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except TimeoutException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) except ElementNotInteractableException as e: msg_output = const_claro_drive.MSG_OUTPUT_BORRADO_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 4, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 4, tiempo_step_inicio, fecha_inicio) return json_eval