def carga_archivo_claro_drive(webdriver_test_ux: webdriver, path_archivo_carga: str, nombre_archivo_sin_ext: str, jsonEval): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: carpeta_folder = WebDriverWait(webdriver_test_ux, 20).until( EC.element_to_be_clickable((By.XPATH, '//span[text()="Folder "][@class="name-without-extension"]'))) carpeta_folder.click() WebDriverWait(webdriver_test_ux, 10).until( EC.element_to_be_clickable((By.XPATH, '//span[text()=" Folder "][@class="last"]'))) input_file = WebDriverWait(webdriver_test_ux, 10).until( EC.presence_of_element_located((By.ID, 'file_upload_start'))) input_file.send_keys(path_archivo_carga) ValidacionesHtml.verificar_ventana_archivo_duplicado(webdriver_test_ux) WebDriverWait(webdriver_test_ux, 720).until(EC.presence_of_element_located( (By.XPATH, '//span[@class="name-without-extension"][text()="{} "]'.format(nombre_archivo_sin_ext)))) jsonEval["steps"][1]["output"][0]["status"] = jsonConst.SUCCESS jsonEval["steps"][1]["status"] = jsonConst.SUCCESS jsonEval["steps"][1]["output"][0]["output"] = 'Se realiza correctamente la carga del archivo' except NoSuchElementException: jsonEval["steps"][1]["output"][0]["status"] = jsonConst.FAILED jsonEval["steps"][1]["status"] = jsonConst.FAILED jsonEval["steps"][1]["output"][0]["output"] = 'No fue posible realizar la carga del archivo' except ElementClickInterceptedException: jsonEval["steps"][1]["output"][0]["status"] = jsonConst.FAILED jsonEval["steps"][1]["status"] = jsonConst.FAILED jsonEval["steps"][1]["output"][0]["output"] = 'No fue posible realizar la carga del archivo' except TimeoutException: jsonEval["steps"][1]["output"][0]["status"] = jsonConst.FAILED jsonEval["steps"][1]["status"] = jsonConst.FAILED jsonEval["steps"][1]["output"][0]["output"] = 'No fue posible realizar la carga del archivo' tiempo_step_final = Temporizador.obtener_tiempo_timer() - tiempo_step_inicio fecha_fin = Temporizador.obtener_fecha_tiempo_actual() jsonEval["steps"][1]["time"] = FormatUtils.truncar_float_cadena(tiempo_step_final) jsonEval["steps"][1]["start"] = fecha_inicio jsonEval["steps"][1]["end"] = fecha_fin return jsonEval
def inicio_sesion_dropbox(self, webdriver_test_ux: WebDriver, json_eval, json_args, url_login): intentos_ingreso_password_gmail = 0 tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() if not UtilsEvaluaciones.se_ingreso_correctamente_a_la_pagina_principal( json_eval): json_eval = UtilsEvaluaciones.generar_json_inicio_de_sesion_incorrecta( json_eval, tiempo_step_inicio, fecha_inicio, 1, constantes_evaluaciones_claro_drive. MSG_INICIO_SESION_FALLIDA_POR_INGRESO_DE_PAGINA) return json_eval try: btn_inicio_sesion = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, xpath='//button[@class="auth-google button-primary"]') HtmlActions.click_html_element( btn_inicio_sesion, xpath='//button[@class="auth-google button-primary"]') if ValidacionesHtml.se_encuentran_mas_ventanas_en_sesion( webdriver_test_ux, 6): ventana_padre = webdriver_test_ux.window_handles[0] ventana_hija = webdriver_test_ux.window_handles[1] webdriver_test_ux.switch_to.window(ventana_hija) modo_no_grafico = FormatUtils.lector_archivo_ini().getboolean( 'Driver', 'headless') # input_user = HtmlActions.webdriver_wait_element_to_be_clickable(webdriver_test_ux, 6, id='identifierId') # # HtmlActions.enviar_data_keys(input_user, json_args['user']) # # btn_siguiente = HtmlActions.webdriver_wait_element_to_be_clickable(webdriver_test_ux, 6, id='identifierNext') # # HtmlActions.click_html_element(btn_siguiente, id='identifierNext') # # time.sleep(10) btn_usuario = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, xpath='//div[@data-email="{}"]'.format(json_args['user'])) time.sleep(2) HtmlActions.click_html_element( btn_usuario, xpath='//div[@data-email="{}"]'.format(json_args['user'])) tiempo_step_inicio = Temporizador.obtener_tiempo_timer() webdriver_test_ux.switch_to.window(ventana_padre) HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 18, class_name='maestro-portal') json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_INICIO_SESION_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 1, tiempo_step_inicio, fecha_inicio) return json_eval
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 ingreso_pagina_principal_dropbox(self, webdriver_test_ux: WebDriver, json_eval, url_login): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() webdriver_test_ux.get(url_login) try: time.sleep(4) # verifica que no estemos loggeados desde un inicio, en caso contrario, cerramos sesion if ValidacionesHtml.verificar_elemento_html_por_id( 'maestro-portal', webdriver_test_ux): boton_imagen_perfil = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 12, class_name='account-menu-v2__avatar') HtmlActions.click_html_element( boton_imagen_perfil, class_name='account-menu-v2__avatar') boton_salir_sesion = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 12, xpath='//div[@class="dig-Menu-row-title"][text()="Salir"]') HtmlActions.click_html_element( boton_salir_sesion, xpath='//div[@class="dig-Menu-row-title"][text()="Salir') else: webdriver_test_ux.get(url_login) HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, name='login_email') HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, name='login_password') json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, False, msg_output) except WebDriverException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 0, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 0, tiempo_step_inicio, fecha_inicio) return json_eval
def cargar_archivo_dropbox(self, webdriver_test_ux: WebDriver, json_eval, json_args, nombre_archivo_sin_ext, nombre_archivo_con_ext): 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, 2, constantes_evaluaciones_claro_drive. MSG_CARGA_ARCHIVO_FALLIDA_POR_INICIO_DE_SESION) return json_eval try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) ValidacionesHtml.verificar_archivo_ya_existente_en_portal( webdriver_test_ux, nombre_archivo_sin_ext) # seingresa a la pagina principal del portal webdriver_test_ux.get('https://www.dropbox.com/h?role=personal') # se obtienen los input de tipo file para la carga del archivo, si sobrepasa mas de 20 segundos, # se sigue el flujo del script while True: segundos = 0 lista_inputs_type_file = webdriver_test_ux.find_elements_by_xpath( '//input[@type="file"]') if len(lista_inputs_type_file) > 0: break elif segundos > 20: break else: segundos += 1 time.sleep(1) # se intentara realizar la carga de archivo en un lapso de 10 seg, si sobrepasa el tiempo sin exito, # se continua el flujo del script while True: segundos = 0 if len(lista_inputs_type_file) > 0: HtmlActions.enviar_data_keys( lista_inputs_type_file[0], json_args['pathImage'], xpath='//input[@type="file"][0]') # for input_file in lista_inputs_type_file: # HtmlActions.enviar_data_keys( # input_file, json_args['pathImage'], xpath='//input[@type="file"][0]') if ValidacionesHtml.verificar_elemento_html_por_class_name( 'dig-Modal-footer', webdriver_test_ux): break time.sleep(1) segundos += 1 if segundos > 10: break footer = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 5, class_name='dig-Modal-footer') btn_carga = HtmlActions.webdriver_wait_element_to_be_clickable( footer, 5, class_name='dig-Button--primary') HtmlActions.click_html_element(btn_carga, class_name='dig-Button--primary') HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 720, xpath= '//span[@class="dig-Snackbar-message "][text()="Se carg\u00F3 {}."]' .format(nombre_archivo_con_ext)) btn_cerrar_progreso_carga = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, xpath='//span[@class="dig-Button-content"][text()="Cerrar"]') HtmlActions.click_html_element( btn_cerrar_progreso_carga, xpath='//span[@class="dig-Button-content"][text()="Cerrar"]') json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_CARGA_ARCHIVO_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 2, tiempo_step_inicio, fecha_inicio) return json_eval
def carga_archivo_claro_drive(webdriver_test_ux: WebDriver, path_archivo_carga: str, json_eval): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() 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, 2, const_claro_drive. MSG_OUTPUT_CARGA_ARCHIVO_MSG_ERROR_INICIO_SESION) return json_eval try: boton_crear = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 10, class_name=const_claro_drive. CARGA_ARCHIVO_CLASS_NAME_BTN_CREATE_RESOURCE) HtmlActions.click_html_element( boton_crear, class_name=const_claro_drive. CARGA_ARCHIVO_CLASS_NAME_BTN_CREATE_RESOURCE) HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 20, class_name=const_claro_drive. CARGA_ARCHIVO_CLASS_NAME_FILE_NAME_READER) input_file = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 20, id=const_claro_drive.CARGA_ARCHIVO_ID_INPUT_FILE_START) HtmlActions.enviar_data_keys( input_file, path_archivo_carga, id=const_claro_drive.CARGA_ARCHIVO_ID_INPUT_FILE_START) ValidacionesHtml.verificar_ventana_archivo_duplicado( webdriver_test_ux) UtilsEvaluaciones.esperar_carga_total_de_archivo(webdriver_test_ux) HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) btn_cerrar_div_progreso_carga_archivo = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, class_name=const_claro_drive.CARGA_ARCHIVO_CLASS_NAME_UP_CLOSE) HtmlActions.verificar_display_flex_modal_mensaje_de_exito( webdriver_test_ux) HtmlActions.click_html_element( btn_cerrar_div_progreso_carga_archivo, class_name=const_claro_drive.CARGA_ARCHIVO_CLASS_NAME_UP_CLOSE) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, True, const_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_EXITOSO) except NoSuchElementException as e: msg_output = const_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = const_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except TimeoutException as e: msg_output = const_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except StaleElementReferenceException as e: msg_output = const_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 2, tiempo_step_inicio, fecha_inicio) return json_eval
def inicio_sesion_dropbox(webdriver_test_ux: WebDriver, json_eval, json_args): tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() ventana_padre = None try: btn_inicio_sesion = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, xpath='//button[@class="auth-google button-primary"]') HtmlActions.click_html_element( btn_inicio_sesion, xpath='//button[@class="auth-google button-primary"]') if ValidacionesHtml.se_encuentran_mas_ventanas_en_sesion( webdriver_test_ux, 6): ventana_padre = webdriver_test_ux.window_handles[0] ventana_hija = webdriver_test_ux.window_handles[1] webdriver_test_ux.switch_to.window(ventana_hija) modo_no_grafico = FormatUtils.lector_archivo_ini().getboolean( 'Driver', 'headless') if modo_no_grafico: input_correo_gmail = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, id='Email') HtmlActions.enviar_data_keys(input_correo_gmail, json_args['user'], id='Email') btn_next_gmail_sec_email = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, id='next') HtmlActions.click_html_element(btn_next_gmail_sec_email, id='next') input_pass_gmail = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 6, id='password') HtmlActions.enviar_data_keys(input_pass_gmail, json_args['password'], id='password') btn_next_gmail_sec_password = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 6, id='submit') HtmlActions.click_html_element(btn_next_gmail_sec_password, id='submit') else: input_correo_gmail = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, id='identifierId') HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 10, id='identifierId') HtmlActions.click_html_element(input_correo_gmail, id='identifierId') HtmlActions.enviar_data_keys(input_correo_gmail, json_args['user'], id='identifierId') btn_next_gmail_sec_email = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, id='identifierNext') HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 10, id='identifierNext') HtmlActions.click_html_element(btn_next_gmail_sec_email, id='identifierNext') div_form = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, id='password') HtmlActions.webdriver_wait_presence_of_element_located( div_form, 10, name='password') HtmlActions.webdriver_wait_presence_of_element_located( div_form, 10, name='password') HtmlActions.webdriver_wait_presence_of_element_located( div_form, 10, name='password') input_pass_gmail = HtmlActions.webdriver_wait_presence_of_element_located( div_form, 10, name='password') HtmlActions.enviar_data_keys(input_pass_gmail, json_args['password'], name='password') btn_next_gmail_sec_password = HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 10, id='passwordNext') HtmlActions.click_html_element(btn_next_gmail_sec_password, id='passwordNext') tiempo_step_inicio = Temporizador.obtener_tiempo_timer() webdriver_test_ux.switch_to.window(ventana_padre) HtmlActions.webdriver_wait_element_to_be_clickable( webdriver_test_ux, 10, class_name='maestro-nav__contents') json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_INICIO_SESION_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_INICIO_SESION_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 1, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 1, 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
def cargar_archivo_dropbox(webdriver_test_ux: WebDriver, json_eval, json_args, nombre_archivo_sin_ext, nombre_archivo_con_ext): tiempo_step_inicio = None fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) ValidacionesHtml.verificar_archivo_ya_existente_en_portal( webdriver_test_ux, nombre_archivo_sin_ext) input_carga_de_archivo = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, xpath='//body/div/div/input[1]') HtmlActions.enviar_data_keys(input_carga_de_archivo, data_key=json_args['pathImage'], xpath='//body/div/div/input[1]') HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 12, xpath= '//div[@class="ReactModal__Content ReactModal__Content--after-open ' 'dig-Modal folder-picker-modal"]') btn_cargar = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 12, xpath= '//button[@class="dig-Button dig-Button--primary dig-Button--standard"]' ) HtmlActions.webdriver_wait_until_not_presence_of_element_located( webdriver_test_ux, 12, class_name='folder-picker__empty-message') WebDriverWait(webdriver_test_ux, 12).until( EC.presence_of_element_located( (By.CLASS_NAME, 'folder-picker__empty-message'))) HtmlActions.click_html_element( btn_cargar, xpath='//button[@class="dig-Button dig-Button--primary ' 'dig-Button--standard"]') tiempo_step_inicio = Temporizador.obtener_tiempo_timer() HtmlActions.webdriver_wait_visibility_of_element_located( webdriver_test_ux, 720, xpath= '//span[@class="dig-Snackbar-message "][text()="Se carg\u00F3 {}."]' .format(nombre_archivo_con_ext)) btn_cerrar_progreso_carga = HtmlActions.webdriver_wait_presence_of_element_located( webdriver_test_ux, 10, xpath='//span[@class="dig-Button-content"][text()="Cerrar"]') HtmlActions.click_html_element( btn_cerrar_progreso_carga, xpath='//span[@class="mc-button-content"][text()="Cerrar"]') json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, True, constantes_evaluaciones_claro_drive. MSG_OUTPUT_CARGA_ARCHIVO_EXITOSO) except ElementNotInteractableException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except NoSuchElementException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except TimeoutException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) except ElementClickInterceptedException as e: msg_output = constantes_evaluaciones_claro_drive.MSG_OUTPUT_CARGA_ARCHIVO_SIN_EXITO.format( e.msg) json_eval = UtilsEvaluaciones.establecer_output_status_step( json_eval, 2, 0, False, msg_output) json_eval = UtilsEvaluaciones.finalizar_tiempos_en_step( json_eval, 2, tiempo_step_inicio, fecha_inicio) return json_eval
def inicio_sesion_dropbox(webdriver_test_ux: WebDriver, json_eval, json_args, url_login): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: webdriver_test_ux.get(url_login) btn_inicio_sesion = WebDriverWait(webdriver_test_ux, 6).until( EC.element_to_be_clickable( (By.XPATH, '//button[@class="auth-google button-primary"]'))) btn_inicio_sesion.click() if ValidacionesHtml.se_encuentran_mas_ventanas_en_sesion( webdriver_test_ux, 6): ventana_padre = webdriver_test_ux.window_handles[0] ventana_hija = webdriver_test_ux.window_handles[1] webdriver_test_ux.switch_to.window(ventana_hija) input_correo_gmail = WebDriverWait(webdriver_test_ux, 6).until( EC.element_to_be_clickable((By.ID, 'Email'))) input_correo_gmail.send_keys(json_args['user']) btn_next_gmail_sec_email = WebDriverWait(webdriver_test_ux, 6).until( EC.element_to_be_clickable((By.ID, 'next'))) btn_next_gmail_sec_email.click() input_pass_gmail = WebDriverWait(webdriver_test_ux, 60).until( EC.presence_of_element_located((By.ID, 'password'))) input_pass_gmail.send_keys(json_args['password']) btn_next_gmail_sec_password = WebDriverWait( webdriver_test_ux, 6).until(EC.element_to_be_clickable((By.ID, 'submit'))) btn_next_gmail_sec_password.click() # input_correo_gmail = WebDriverWait(webdriver_test_ux, 6).until( # EC.element_to_be_clickable((By.ID, 'identifierId'))) # input_correo_gmail.send_keys(json_args['user']) # # btn_next_gmail_sec_email = WebDriverWait(webdriver_test_ux, 6).until( # EC.element_to_be_clickable((By.ID, 'identifierNext'))) # btn_next_gmail_sec_email.click() # # input_pass_gmail = WebDriverWait(webdriver_test_ux, 60).until( # EC.presence_of_element_located((By.NAME, 'password'))) # input_pass_gmail.send_keys(json_args['password']) # # btn_next_gmail_sec_password = WebDriverWait(webdriver_test_ux, 6).until( # EC.element_to_be_clickable((By.ID, 'passwordNext'))) # btn_next_gmail_sec_password.click() webdriver_test_ux.switch_to.window(ventana_padre) WebDriverWait(webdriver_test_ux, 10).until( EC.element_to_be_clickable( (By.CLASS_NAME, 'maestro-nav__contents'))) json_eval["steps"][0]["output"][0]["status"] = jsonConst.SUCCESS json_eval["steps"][0]["status"] = jsonConst.SUCCESS json_eval["steps"][0]["output"][0][ "output"] = 'Se ingresa correctamente al portal Drop Box' except ElementNotInteractableException as e: json_eval["steps"][0]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["output"][0][ "output"] = 'fue imposible ingresar al portal Drop Box: {}'.format( e.msg) except NoSuchElementException as e: json_eval["steps"][0]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["output"][0][ "output"] = 'fue imposible ingresar al portal Drop Box: {}'.format( e.msg) except TimeoutException as e: json_eval["steps"][0]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["output"][0][ "output"] = 'fue imposible ingresar al portal Drop Box: {}'.format( e.msg) except ElementClickInterceptedException as e: json_eval["steps"][0]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["status"] = jsonConst.FAILED json_eval["steps"][0]["output"][0][ "output"] = 'fue imposible ingresar al portal Drop Box: {}'.format( e.msg) tiempo_step_final = Temporizador.obtener_tiempo_timer( ) - tiempo_step_inicio fecha_fin = Temporizador.obtener_fecha_tiempo_actual() json_eval["steps"][0]["time"] = FormatUtils.truncar_float_cadena( tiempo_step_final) json_eval["steps"][0]["start"] = fecha_inicio json_eval["steps"][0]["end"] = fecha_fin return json_eval
def descargar_archivo_dropbox(webdriver_test_ux: WebDriver, json_eval, nombre_archivo_con_ext): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) search_bar = WebDriverWait(webdriver_test_ux, 20).until( EC.element_to_be_clickable((By.CLASS_NAME, 'search__input'))) search_bar.send_keys(nombre_archivo_con_ext) time.sleep(1) search_bar.send_keys(Keys.RETURN) archivo_por_descargar = WebDriverWait(webdriver_test_ux, 20).until( EC.element_to_be_clickable( (By.XPATH, '//tr[@data-filename="{}"]'.format(nombre_archivo_con_ext)))) btn_mas_acciones = WebDriverWait(archivo_por_descargar, 20).until( EC.element_to_be_clickable( (By.CLASS_NAME, 'browse-overflow-menu'))) btn_mas_acciones.click() btn_descargar = WebDriverWait(webdriver_test_ux, 20).until( EC.element_to_be_clickable((By.CLASS_NAME, 'action-download'))) btn_descargar.click() json_eval["steps"][2]["output"][0]["status"] = jsonConst.SUCCESS json_eval["steps"][2]["status"] = jsonConst.SUCCESS json_eval["steps"][2]["output"][0][ "output"] = 'Se descarga correctamente el archivo dentro del portal Drop Box' except ElementNotInteractableException as e: json_eval["steps"][2]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][2]["status"] = jsonConst.FAILED json_eval["steps"][2]["output"][0][ "output"] = 'fue imposible descargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except NoSuchElementException as e: json_eval["steps"][2]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][2]["status"] = jsonConst.FAILED json_eval["steps"][2]["output"][0][ "output"] = 'fue imposible descargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except TimeoutException as e: json_eval["steps"][2]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][2]["status"] = jsonConst.FAILED json_eval["steps"][2]["output"][0][ "output"] = 'fue imposible descargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except ElementClickInterceptedException as e: json_eval["steps"][2]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][2]["status"] = jsonConst.FAILED json_eval["steps"][2]["output"][0][ "output"] = 'fue imposible descargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except StaleElementReferenceException as e: json_eval["steps"][2]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][2]["status"] = jsonConst.FAILED json_eval["steps"][2]["output"][0][ "output"] = 'fue imposible descargar el archivo dentro del portal Drop Box: {}'.format( e.msg) tiempo_step_final = Temporizador.obtener_tiempo_timer( ) - tiempo_step_inicio fecha_fin = Temporizador.obtener_fecha_tiempo_actual() json_eval["steps"][2]["time"] = FormatUtils.truncar_float_cadena( tiempo_step_final) json_eval["steps"][2]["start"] = fecha_inicio json_eval["steps"][2]["end"] = fecha_fin return json_eval
def cargar_archivo_dropbox(webdriver_test_ux: WebDriver, json_eval, json_args, nombre_archivo_sin_ext, nombre_archivo_con_ext): tiempo_step_inicio = Temporizador.obtener_tiempo_timer() fecha_inicio = Temporizador.obtener_fecha_tiempo_actual() try: ValidacionesHtml.verificar_remover_ventana_configuracion( webdriver_test_ux) ValidacionesHtml.verificar_archivo_ya_existente_en_portal( webdriver_test_ux, nombre_archivo_sin_ext) input_carga_de_archivo = WebDriverWait(webdriver_test_ux, 10).until( EC.presence_of_element_located( (By.XPATH, '//body/div/div/input[1]'))) input_carga_de_archivo.send_keys(json_args['pathImage']) WebDriverWait(webdriver_test_ux, 12).until( EC.presence_of_element_located( (By.XPATH, '//div[@class="mc-util-modal-header"][text()="Cargar a…"]'))) WebDriverWait(webdriver_test_ux, 12).until( EC.presence_of_element_located( (By.XPATH, '//tbody[@class="mc-table-body folder-picker-view"]'))) btn_cargar = WebDriverWait(webdriver_test_ux, 12).until( EC.element_to_be_clickable( (By.XPATH, '//span[@class="mc-button-content"][text()="Cargar"]'))) btn_cargar.click() WebDriverWait(webdriver_test_ux, 720).until( EC.presence_of_element_located( (By.XPATH, '//p[@class="mc-snackbar-title"][text()="Se carg\u00F3 {}."]'. format(nombre_archivo_con_ext)))) btn_cerrar_progreso_carga = WebDriverWait(webdriver_test_ux, 10).until( EC.presence_of_element_located( (By.XPATH, '//span[@class="mc-button-content"][text()="Cerrar"]'))) btn_cerrar_progreso_carga.click() webdriver_test_ux.refresh() json_eval["steps"][1]["output"][0]["status"] = jsonConst.SUCCESS json_eval["steps"][1]["status"] = jsonConst.SUCCESS json_eval["steps"][1]["output"][0][ "output"] = 'Se carga el archivo correctamente dentro del portal Drop Box' except ElementNotInteractableException as e: json_eval["steps"][1]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][1]["status"] = jsonConst.FAILED json_eval["steps"][1]["output"][0][ "output"] = 'fue imposible cargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except NoSuchElementException as e: json_eval["steps"][1]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][1]["status"] = jsonConst.FAILED json_eval["steps"][1]["output"][0][ "output"] = 'fue imposible cargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except TimeoutException as e: json_eval["steps"][1]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][1]["status"] = jsonConst.FAILED json_eval["steps"][1]["output"][0][ "output"] = 'fue imposible cargar el archivo dentro del portal Drop Box: {}'.format( e.msg) except ElementClickInterceptedException as e: json_eval["steps"][1]["output"][0]["status"] = jsonConst.FAILED json_eval["steps"][1]["status"] = jsonConst.FAILED json_eval["steps"][1]["output"][0][ "output"] = 'fue imposible cargar el archivo dentro del portal Drop Box: {}'.format( e.msg) tiempo_step_final = Temporizador.obtener_tiempo_timer( ) - tiempo_step_inicio fecha_fin = Temporizador.obtener_fecha_tiempo_actual() json_eval["steps"][1]["time"] = FormatUtils.truncar_float_cadena( tiempo_step_final) json_eval["steps"][1]["start"] = fecha_inicio json_eval["steps"][1]["end"] = fecha_fin return json_eval