def descargar_archivo_dropbox(self, webdriver_test_ux: WebDriver, json_eval, nombre_archivo_con_ext): extension_del_archivo = path.splitext(nombre_archivo_con_ext)[1] nombre_del_archivo_sin_extension = Path(nombre_archivo_con_ext).stem tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() 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, 3, constantes_evaluaciones_claro_drive. MSG_DESCARGA_ARCHIVO_FALLIDA_POR_CARGA_ARCHIVO_FALLIDA) return json_eval try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) search_bar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, class_name='search__input') HtmlActions.enviar_data_keys(search_bar, nombre_archivo_con_ext, class_name='search__input') #time.sleep(1) HtmlActions.enviar_data_keys(search_bar, Keys.RETURN, class_name='search__input') archivo_por_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, xpath='//tr[@data-filename="{}"]'.format( nombre_archivo_con_ext)) checkbox = HtmlActions.webdriver_wait_element_to_be_clickable( archivo_por_descargar, 10, class_name='brws-checkbox-cell') HtmlActions.click_html_element(checkbox, class_name='brws-checkbox-cell') btn_mas_acciones = HtmlActions.webdriver_wait_element_to_be_clickable( archivo_por_descargar, 20, xpath='//button[@data-testid="action-bar-overflow"]') HtmlActions.click_html_element( btn_mas_acciones, xpath='//button[@data-testid="action-bar-overflow"]') btn_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, xpath='//div[@class="dig-Menu-row-title"][text()="Descargar"]') HtmlActions.click_html_element( btn_descargar, xpath='//div[@class="dig-Menu-row-title"][text()="Descargar"]') UtilsEvaluaciones.verificar_descarga_en_ejecucion( nombre_del_archivo_sin_extension, extension_del_archivo) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_DESCARGA_ARCHIVO_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 3, tiempo_step_inicio, fecha_inicio) return json_eval
def descarga_archivo_claro_drive(webdriver_test_ux: WebDriver, nombre_archivo_sin_ext: str, json_eval, 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, 3, const_claro_drive. MSG_OUTPUT_DESCARGA_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, 3, const_claro_drive. MSG_OUTPUT_DESCARGA_ARCHIVO_MSG_ERROR_CARGA_ARCHIVO) return json_eval try: # 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) # busqueda del input o barra de busqueda input_busqueda = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) # se ingresa cada caracter a la barra de busqueda con un lapso de tiempo for character in nombre_completo_de_la_imagen: HtmlActions.enviar_data_keys( input_busqueda, character, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) time.sleep(.25) # se envia una tecla Enter, para que realice la busqueda del archivo HtmlActions.enviar_data_keys( input_busqueda, Keys.RETURN, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) # se establece un sleep de 5 segundos para que refresque la pantalla y muestre los # archivos localizados time.sleep(5) # localiza el archivo a descargar 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) boton_sub_menu_actions = HtmlActions.webdriver_wait_presence_of_element_located( archivo_localizado_por_descargar, 20, class_name='open-menu') HtmlActions.click_html_element(boton_sub_menu_actions, class_name='open-menu') boton_descargar = HtmlActions.webdriver_wait_presence_of_element_located( boton_sub_menu_actions, 20, xpath='//li[@class="download action"]') HtmlActions.click_html_element( boton_descargar, xpath='//li[@class="download action"]') HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) tiempo_step_inicio = Temporizador.obtener_tiempo_timer() UtilsEvaluaciones.verificar_descarga_en_ejecucion( nombre_archivo_sin_ext, ext_archivo) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, True, const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_EXITOSO) except NoSuchElementException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except TimeoutException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementNotInteractableException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 3, tiempo_step_inicio, fecha_inicio) return json_eval
def descarga_archivo_claro_drive(webdriver_test_ux: WebDriver, nombre_archivo_sin_ext: str, json_eval, 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, 3, const_claro_drive. MSG_OUTPUT_DESCARGA_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, 3, const_claro_drive. MSG_OUTPUT_DESCARGA_ARCHIVO_MSG_ERROR_CARGA_ARCHIVO) return json_eval try: HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) UtilsEvaluaciones.establecer_vista_de_archivos_como_lista( webdriver_test_ux) # establece el action para mover el mouse a un elemento html action = ActionChains(webdriver_test_ux) input_busqueda = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) HtmlActions.enviar_data_keys( input_busqueda, nombre_completo_de_la_imagen, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) HtmlActions.enviar_data_keys( input_busqueda, Keys.RETURN, id=const_claro_drive.DESCARGA_ARCHIVO_ID_SEARCH_BOX) HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 20, class_name=const_claro_drive.DESCARGA_ARCHIVO_CLASS_NAME_RESULT ) archivo_localizado_por_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, xpath=const_claro_drive. DESCARGA_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.DESCARGA_ARCHIVO_CLASS_NAME_FILENAME) if len(lista_de_divs_de_archivos) != 0: HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) for div in lista_de_divs_de_archivos: nombre_archivo_sin_extension_obtenido = div.find_element_by_class_name( const_claro_drive. DESCARGA_ARCHIVO_CLASS_NAME_NAME_WITHOUT_EXT ).get_attribute( const_claro_drive.DESCARGA_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.DESCARGA_ARCHIVO_EXT).get_attribute( const_claro_drive.DESCARGA_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. DESCARGA_ARCHIVO_CLASS_NAME_ACTION) if len(lista_botones) > 0: HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) boton_descarga = lista_botones[-1] HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) HtmlActions.click_en_elemento_html_con_intentos( boton_descarga, 5, class_name=const_claro_drive. DESCARGA_ARCHIVO_CLASS_NAME_ACTION) # HtmlActions.click_html_element( # boton_descarga, class_name=const_claro_drive.DESCARGA_ARCHIVO_CLASS_NAME_ACTION) UtilsEvaluaciones.esperar_aparicion_modal_de_exito( webdriver_test_ux) UtilsEvaluaciones.esperar_desaparicion_modal_exito( webdriver_test_ux) break tiempo_step_inicio = Temporizador.obtener_tiempo_timer() UtilsEvaluaciones.verificar_descarga_en_ejecucion( nombre_archivo_sin_ext, ext_archivo) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, True, const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_EXITOSO) except NoSuchElementException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except TimeoutException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementNotInteractableException as e: msg_output = const_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 3, tiempo_step_inicio, fecha_inicio) return json_eval
def descargar_archivo_dropbox(webdriver_test_ux: WebDriver, json_eval, nombre_archivo_con_ext): extension_del_archivo = path.splitext(nombre_archivo_con_ext)[1] nombre_del_archivo_sin_extension = Path(nombre_archivo_con_ext).stem tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) search_bar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, class_name='search__input') HtmlActions.enviar_data_keys(search_bar, nombre_archivo_con_ext, class_name='search__input') HtmlActions.enviar_data_keys(search_bar, Keys.RETURN, class_name='search__input') archivo_por_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, xpath='//tr[@data-filename="{}"]'.format( nombre_archivo_con_ext)) btn_mas_acciones = HtmlActions.webdriver_wait_element_to_be_clickable( archivo_por_descargar, 20, class_name='browse-overflow-menu') HtmlActions.click_html_element(btn_mas_acciones, class_name='browse-overflow-menu') btn_descargar = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 20, class_name='action-download') HtmlActions.click_html_element(btn_descargar, class_name='action-download') tiempo_step_inicio = Temporizador.obtener_tiempo_timer() UtilsEvaluaciones.verificar_descarga_en_ejecucion( nombre_del_archivo_sin_extension, extension_del_archivo) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_DESCARGA_ARCHIVO_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_DESCARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 3, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 3, tiempo_step_inicio, fecha_inicio) return json_eval