def iniciar_sesion_en_owa(webdriver: WebDriver, correo: Correo, result_list: ValidacionResultList): EvaluacionesHtml.cuenta_sin_dominio = FormatUtils.formatear_correo( correo.correo) EvaluacionesHtml.url_owa_exchange = correo.url resultado = ResultStep() resultado.tiempo_inicio_de_ejecucion = Temporizador.obtener_tiempo_timer( ) resultado.datetime_inicial = Temporizador.obtener_fecha_tiempo_actual() # verifica que haya ingresado correctamente a la url if not result_list.result_validacion_ingreso_url.validacion_correcta: resultado.validacion_correcta = False resultado.mensaje_error = 'No fue posible el inicio de sesion dentro de la plataforma Exchange. ' \ 'No se ingreso correctamente a la pagina principal de la plataforma' resultado.finalizar_tiempo_de_ejecucion() resultado.establecer_tiempo_de_ejecucion() result_list.result_validacion_acceso_portal_owa = resultado return result_list try: input_usuario = BusquedaElementosHtml.buscar_elemento_por_id_timeout( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_ID_INPUT_USER, 7) input_usuario.send_keys(correo.correo) input_password = BusquedaElementosHtml.buscar_elemento_por_id_timeout( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_ID_INPUT_PASSWORD, 7) input_password.send_keys(correo.password) boton_ingreso_correo = None if ValidacionesHTML.verificar_elemento_encontrado_por_id( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_ID_CHECKBOX_PORTAL_LIGHTWEIGHT_OWA_2010 ): check_casilla_owa_2010_version_ligera = BusquedaElementosHtml.buscar_elemento_por_id_timeout( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_ID_CHECKBOX_PORTAL_LIGHTWEIGHT_OWA_2010, 7) check_casilla_owa_2010_version_ligera.click() constantes_utils.owa_descubierto = 2010 if ValidacionesHTML.verificar_elemento_encontrado_por_xpath( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_XPATH_BTN_OWA_2010): boton_ingreso_correo = BusquedaElementosHtml.buscar_elemento_por_xpath_timeout( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_XPATH_BTN_OWA_2010, 7) constantes_utils.owa_descubierto = 2010 elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_XPATH_BTN_OWA_2013_2016): boton_ingreso_correo = BusquedaElementosHtml.buscar_elemento_por_xpath_timeout( webdriver, constantes_webdriver_actions. INICIAR_SESION_EN_OWA_XPATH_BTN_OWA_2013_2016, 7) constantes_utils.owa_descubierto = 2016 boton_ingreso_correo.click() except sel_excep.NoSuchElementException as e: resultado.mensaje_error = constantes_webdriver_actions.INICIAR_SESION_MSG_NOSUCHELEM_EXCEP_MSG_ERROR. \ format(FormatUtils.formatear_excepcion(e)) resultado.validacion_correcta = False except sel_excep.TimeoutException as e: resultado.mensaje_error = constantes_webdriver_actions.INICIAR_SESION_MSG_NOSUCHELEM_EXCEP_MSG_ERROR. \ format(FormatUtils.formatear_excepcion(e)) resultado.validacion_correcta = False except sel_excep.WebDriverException as e: resultado.mensaje_error = constantes_webdriver_actions.INICIAR_SESION_MSG_WEBDRIVER_EXCEP_MSG_ERROR. \ format(FormatUtils.formatear_excepcion(e)) resultado.validacion_correcta = False if not resultado.validacion_correcta: try: if constantes_utils.owa_descubierto == 2010: mensaje_error_de_credenciales = webdriver.find_element_by_xpath( constantes_webdriver_actions. INICIAR_SESION_EN_OWA_XPATH_ERROR_CREDENCIALES_OWA_2010 ) texto_mensaje_error = mensaje_error_de_credenciales.get_attribute( 'innerHTML') resultado.msg_error_de_credenciales = texto_mensaje_error resultado.mensaje_error = constantes_webdriver_actions. \ INICIAR_SESION_LOG_MSG_ERROR_CREDENCIALES_OWA.format(texto_mensaje_error) resultado.validacion_correcta = False resultado.error_inicio_de_sesion_credenciales_erroneas = True elif constantes_utils.owa_descubierto == 2016 or constantes_utils.owa_descubierto == 2013: mensaje_error_de_credenciales = webdriver.execute_script( constantes_webdriver_actions. INICIAR_SESION_JS_LOCATE_ID_MSG_ERROR_CREDENCIALES_OWA_2016_2013 ) resultado.mensaje_error = constantes_webdriver_actions. \ INICIAR_SESION_LOG_MSG_ERROR_CREDENCIALES_OWA.format(mensaje_error_de_credenciales) resultado.msg_error_de_credenciales = mensaje_error_de_credenciales resultado.validacion_correcta = False resultado.error_inicio_de_sesion_credenciales_erroneas = True except sel_excep.NoSuchElementException: resultado.mensaje_error = constantes_json.OUTPUT_EXITOSO_1_1 resultado.validacion_correcta = True except sel_excep.InvalidSessionIdException as e: resultado.mensaje_error = constantes_webdriver_actions. \ INICIAR_SESION_CREDENCIALES_INVALIDSESION_ID_EXCEP_MSG_ERROR.format(e) resultado.validacion_correcta = False except sel_excep.JavascriptException: # Se ingresa correctamente, debido a que no se encontro el mensaje de error de credenciales incorrectas resultado.mensaje_error = constantes_json.OUTPUT_EXITOSO_1_1 resultado.validacion_correcta = True except sel_excep.WebDriverException: # Se ingresa correctamente, debido a que no se encontro el mensaje de error de credenciales incorrectas resultado.mensaje_error = constantes_json.OUTPUT_EXITOSO_1_1 resultado.validacion_correcta = True # realiza la validacion de ingreso correcto de sesion se verifica que no haya algun error que se presente en la # plataforma en caso contrario se obtiene el mensaje del error y se establecer en el objeto resultado if ValidacionesHTML.verificar_error_plataforma(webdriver): msg_error = ValidacionesHTML.obtener_mensaje_error_plataforma( webdriver) resultado.mensaje_error = constantes_webdriver_actions.INICIAR_SESION_MSG_ERROR_EN_PLATAFORMA. \ format(msg_error) resultado.validacion_correcta = False resultado.error_plataforma_inicio_de_sesion = True resultado.finalizar_tiempo_de_ejecucion() resultado.establecer_tiempo_de_ejecucion() result_list.result_validacion_acceso_portal_owa = resultado return result_list
def establecer_tiempo_de_finalizacion(objeto_json): objeto_json['time'] = Temporizador.obtener_tiempo_timer() # objeto_json['status'] = constantes_json.STATUS_CORRECTO objeto_json['end'] = Temporizador.obtener_fecha_tiempo_actual() return objeto_json
def establecer_fecha_tiempo_de_inicio(objeto_json): objeto_json['start'] = Temporizador.obtener_fecha_tiempo_actual() return objeto_json
def establecer_tiempo_de_finalizacion(objeto_json): objeto_json['time'] = Temporizador.obtener_tiempo_timer() objeto_json['end'] = Temporizador.obtener_fecha_tiempo_actual() return objeto_json
def finalizar_tiempo_de_ejecucion(self): self.datetime_final = Temporizador.obtener_fecha_tiempo_actual() self.tiempo_fin_de_ejecucion = Temporizador.obtener_tiempo_timer() self.establecer_tiempo_de_ejecucion()
def inicializar_tiempo_de_ejecucion(self): self.datetime_inicial = Temporizador.obtener_fecha_tiempo_actual() self.tiempo_inicio_de_ejecucion = Temporizador.obtener_tiempo_timer()