def cerrar_sesion(webdriver: WebDriver, result_list: ValidacionResultList, correo: Correo):

        timeout_cierre_sesion = 10
        resultado_cierre_sesion = ResultStep()
        resultado_cierre_sesion.inicializar_tiempo_de_ejecucion()
        cierre_sesion_exitosa = False

        # verifica si se tiene error de credenciales, por lo cual si se tiene este error, se establece el mensaje
        # de error y envia el result como finalizado, esto debido a que no puede localizar el boton de cierre de
        # sesion sin antes haberse loggeado dentro de la plataforma
        if result_list.result_validacion_acceso_portal_owa.error_inicio_de_sesion_credenciales_erroneas:
            resultado_cierre_sesion.finalizar_tiempo_de_ejecucion()
            resultado_cierre_sesion.establecer_tiempo_de_ejecucion()
            resultado_cierre_sesion.validacion_correcta = False

            resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions.\
                CERRAR_SESION_MSG_ERROR_CREDENCIALES_OWA.format(result_list.result_validacion_acceso_portal_owa.
                                                                msg_error_de_credenciales)

            result_list.result_validacion_cierre_sesion = resultado_cierre_sesion

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_MSG_ERROR_CREDENCIALES_OWA.format(
                result_list.result_validacion_acceso_portal_owa.msg_error_de_credenciales))

            webdriver.close()
            webdriver.quit()

            return result_list

        # verifica si hay error en plataforma, en caso de ser asi, intenta realizar n intentos para volver a loggearse
        # y verificar si ingreso correctamente al buzon de entrada para navegar entre las carpetas
        if ValidacionesHTML.verificar_error_plataforma(webdriver):
            resultado_cierre_sesion = ValidacionesHTML.intento_ingreso_nuevamente_al_portal(
                resultado_cierre_sesion, correo, webdriver, step_evaluacion='cierre de sesion')

        try:
            webdriver.refresh()
            time.sleep(5)

            # verifica que no haya algun dialogo que impida el cierre de sesion
            ValidacionesHTML.verificar_dialogo_de_interrupcion(
                webdriver, resultado_cierre_sesion)

            # intenta salir de la sesion ejecutando un script js el cual simula un clic en el boton de cierre de sesion

            if AccionesHtml.owa_descubierto == 2010:
                time.sleep(4)
                elemento_html_btn_cerrar_sesion = webdriver.find_element_by_id(
                    constantes_webdriver_actions.CERRAR_SESION_CIERRE_SESION_ID_BTN_CIERRE_SESION_OWA_2010)
                time.sleep(4)
                elemento_html_btn_cerrar_sesion.click()
                time.sleep(4)
            elif AccionesHtml.owa_descubierto == 2016:
                time.sleep(4)

                boton_cierre_sesion_owa_2016 = webdriver.execute_script(
                    constantes_webdriver_actions.JS_LOCATE_DIV_CONTENT_BTN_CIERRE_SESION_OWA_2016)

                time.sleep(4)
                boton_cierre_sesion_owa_2016.click()
                time.sleep(8)

                boton_cierre_sesion_owa_2016 = webdriver.execute_script(
                    constantes_webdriver_actions.JS_LOCATE_BTN_CIERRE_SESION_OWA_2016)

                boton_cierre_sesion_owa_2016.click()

            elif AccionesHtml.owa_descubierto == 2013:

                boton_cierre_sesion_owa_2013 = webdriver.execute_script(
                    constantes_webdriver_actions.JS_LOCATE_DIV_CONTENT_BTN_CIERRE_SESION_OWA_2013)

                boton_cierre_sesion_owa_2013.click()
                time.sleep(8)

                boton_cierre_sesion_owa_2013 = webdriver.execute_script(
                    constantes_webdriver_actions.JS_LOCATE_BTN_CIERRE_SESION_OWA_2013_SPANISH)

                if boton_cierre_sesion_owa_2013 is None:
                    AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_BTN_CIERRE_SIGN_OUT)

                    boton_cierre_sesion_owa_2013 = webdriver.execute_script(
                        constantes_webdriver_actions.JS_LOCATE_BTN_CIERRE_SESION_OWA_2013_ENGLISH)

                boton_cierre_sesion_owa_2013.click()

            # obtiene la url actual como una cadena
            time.sleep(2)

            AccionesHtml.log.info(constantes_webdriver_actions.CERRAR_SESION_LOG_INFO_CIERRE_SESION_TITLE_URL
                                  .format(webdriver.title, webdriver.current_url))

            webdriver.refresh()

            time.sleep(2)

            # verifica que nos encontremos en la pagina de cierre de sesion del OWA verifica que el title de la pagina
            # contenfa Outlook
            condicion_contenido_en_title = EC.title_contains(constantes_webdriver_actions.
                                                             CERRAR_SESION_TITLE_CIERRE_SESION)

            WebDriverWait(webdriver, timeout_cierre_sesion).until(condicion_contenido_en_title)

            cierre_sesion_exitosa = True

        except selExcep.NoSuchElementException as e:

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_NO_SUCH_ELEM_EXCEP.format(
                FormatUtils.formatear_excepcion(e)))

            resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions. \
                CERRAR_SESION_LOG_ERROR_NO_SUCH_ELEM_EXCEP.format(FormatUtils.formatear_excepcion(e))

            resultado_cierre_sesion.validacion_correcta = False

        except selExcep.ElementClickInterceptedException as e:

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_ELEM_INTERCEP_EXCEP.format(
                FormatUtils.formatear_excepcion(e)))

            webdriver.refresh()

            time.sleep(2)

            AccionesHtml.cerrar_sesion(webdriver, result_list, correo)

        except selExcep.TimeoutException as e:

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_TIMEOUT_EXCEP.format(
                FormatUtils.formatear_excepcion(e)))

            resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions. \
                CERRAR_SESION_LOG_ERROR_TIMEOUT_EXCEP.format(FormatUtils.formatear_excepcion(e))

            resultado_cierre_sesion.validacion_correcta = False

        except selExcep.WebDriverException as e:

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_WEBDRIVER_EXCEP
                                   .format(FormatUtils.formatear_excepcion(e)))

            resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions. \
                CERRAR_SESION_LOG_ERROR_WEBDRIVER_EXCEP.format(FormatUtils.formatear_excepcion(e))

            resultado_cierre_sesion.validacion_correcta = False

        except AttributeError:

            AccionesHtml.log.error(constantes_webdriver_actions.CERRAR_SESION_LOG_ERROR_ATRIBUTE_ERROR_EXCEP)
            resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions. \
                CERRAR_SESION_LOG_ERROR_ATRIBUTE_ERROR_EXCEP
            resultado_cierre_sesion.validacion_correcta = False

        finally:

            # verifica que no haya algun mensaje de error en la plataforma, en caso contrario se muestra el mensaje de
            # error que aparace en la plataforma dentro del result
            if ValidacionesHTML.verificar_error_plataforma(webdriver):
                resultado_cierre_sesion.validacion_correcta = False
                msg_error = ValidacionesHTML.obtener_mensaje_error_plataforma(webdriver)

                resultado_cierre_sesion.mensaje_error = constantes_webdriver_actions.CERRAR_SESION_ERROR_PLATAFORMA. \
                    format(msg_error)

                cierre_sesion_exitosa = False

            AccionesHtml.log.info(constantes_webdriver_actions.CERRAR_SESION_LOG_INFO_CIERRE_WEB_DRIVER)

            webdriver.close()
            webdriver.quit()

        if cierre_sesion_exitosa:
            AccionesHtml.log.info(constantes_webdriver_actions.CERRAR_SESION_LOG_INFO_CIERRE_SESION_EXITOSA)
            resultado_cierre_sesion.mensaje_error = constantes_json.OUTPUT_EXITOSO_3_1
            resultado_cierre_sesion.validacion_correcta = True

        resultado_cierre_sesion.finalizar_tiempo_de_ejecucion()
        resultado_cierre_sesion.establecer_tiempo_de_ejecucion()
        result_list.result_validacion_cierre_sesion = resultado_cierre_sesion

        return result_list
    def navegacion_de_carpetas_por_segundos(correo: Correo, lista_carpetas: list, driver: WebDriver,
                                            result_list: ValidacionResultList, numero_de_segundos: int = 120):

        result_navegacion_carpetas = ResultStep()
        result_navegacion_carpetas.inicializar_tiempo_de_ejecucion()
        tiempo_por_verificar = numero_de_segundos + Temporizador.obtener_tiempo_timer()
        tiempo_de_inicio = Temporizador.obtener_tiempo_timer()
        segundos = 0

        # verifica si se tiene error de credenciales, por lo cual si se tiene este error, se establece el mensaje
        # de error y envia el result como finalizado, esto debido a que no se podra navegar entre carpetas por no
        # estar loggeado y sin tener acceso al buzon de la plataforma
        if result_list.result_validacion_acceso_portal_owa.error_inicio_de_sesion_credenciales_erroneas:
            result_navegacion_carpetas.finalizar_tiempo_de_ejecucion()
            result_navegacion_carpetas.establecer_tiempo_de_ejecucion()
            result_navegacion_carpetas.validacion_correcta = False

            result_navegacion_carpetas.mensaje_error = constantes_webdriver_actions.\
                NAVEGACION_CARPETAS_SEG_MSG_ERROR_CREDENCIALES_OWA.format(
                result_list.result_validacion_acceso_portal_owa.msg_error_de_credenciales)

            result_list.result_validacion_navegacion_carpetas = result_navegacion_carpetas

            AccionesHtml.log.error(constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_MSG_ERROR_CREDENCIALES_OWA.
                                   format(result_list.result_validacion_acceso_portal_owa.msg_error_de_credenciales))

            return result_list

        # verifica si hay error en plataforma, en caso de ser asi, intenta realizar n intentos para volver a loggearse
        # y verificar si ingreso correctamente al buzon de entrada para navegar entre las carpetas
        if ValidacionesHTML.verificar_error_plataforma(driver):
            result_navegacion_carpetas = ValidacionesHTML.intento_ingreso_nuevamente_al_portal(
                result_navegacion_carpetas, correo, driver, step_evaluacion='Navegacion carpetas y buzon de entrada')

        # verifica si aun se sigue mostrando el mensaje de error en la plataforma, en caso contrario la prueba falla
        # y notificaria al cliente de presentar un error de plataforma

        if ValidacionesHTML.verificar_error_plataforma(driver):

            result_navegacion_carpetas.finalizar_tiempo_de_ejecucion()
            result_navegacion_carpetas.establecer_tiempo_de_ejecucion()
            result_navegacion_carpetas.validacion_correcta = False
            msg_error = ValidacionesHTML.obtener_mensaje_error_plataforma(driver)
            result_navegacion_carpetas.mensaje_error = constantes_webdriver_actions. \
                NAVEGACION_CARPETAS_SEG_MSG_ERROR_PLATAFORMA_OWA.format(msg_error)

            result_list.result_validacion_navegacion_carpetas = result_navegacion_carpetas

            return result_list

        elif len(lista_carpetas) == 0:

            result_navegacion_carpetas.finalizar_tiempo_de_ejecucion()
            result_navegacion_carpetas.establecer_tiempo_de_ejecucion()
            result_navegacion_carpetas.validacion_correcta = False
            result_navegacion_carpetas.mensaje_error = constantes_webdriver_actions. \
                NAVEGACION_CARPETAS_SEG_LOG_ERROR_LISTA_CARPETAS_VACIA

            result_list.result_validacion_navegacion_carpetas = result_navegacion_carpetas

            AccionesHtml.log.error(constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_ERROR_LISTA_CARPETAS_VACIA)

            return result_list

        while Temporizador.obtener_tiempo_timer() <= tiempo_por_verificar:
            for carpeta in lista_carpetas:
                segundos = Temporizador.obtener_tiempo_timer() - tiempo_de_inicio

                if segundos > numero_de_segundos:
                    AccionesHtml.log.info(constantes_webdriver_actions.
                                          NAVEGACION_CARPETAS_SEG_LOG_INFO_NAVEGACION_CARPETAS_FINALIZADA)
                    break

                AccionesHtml.log.info(constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_INFO_INGRESO_CARPETA.
                                      format(carpeta))

                try:

                    if AccionesHtml.owa_descubierto == 2016:
                        elemento_html_carpeta = driver.execute_script(constantes_webdriver_actions.
                            NAVEGACION_CARPETAS_SEG_JS_LOCALIZAR_CARPETA_OWA_2016.format(
                            carpeta))

                        elemento_html_carpeta.click()
                        time.sleep(6)
                    elif AccionesHtml.owa_descubierto == 2010:
                        elemento_html_carpeta = driver.find_element_by_xpath(constantes_webdriver_actions.
                            NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2010.format(
                            carpeta))

                        time.sleep(3)
                        ValidacionesHTML.verificar_dialogo_de_interrupcion(driver, result_navegacion_carpetas)
                        time.sleep(3)
                        elemento_html_carpeta.click()
                    elif AccionesHtml.owa_descubierto == 2013:
                        elemento_html_carpeta = driver.execute_script(constantes_webdriver_actions.
                            NAVEGACION_CARPETAS_SEG_JS_LOCALIZAR_CARPETA_OWA_2013.format(
                            carpeta))

                        elemento_html_carpeta.click()
                        time.sleep(6)

                except selExcep.StaleElementReferenceException as e:

                    AccionesHtml.log.error(
                        constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_ERROR_STA_ELEM_REF_EXCEP
                            .format(FormatUtils.formatear_excepcion(e)))

                    driver.refresh()
                    time.sleep(3)
                except selExcep.ElementClickInterceptedException as e:

                    AccionesHtml.log.error(constantes_webdriver_actions.
                        NAVEGACION_CARPETAS_SEG_LOG_ERROR_ELEM_CLICK_INTERCEP_EXCEP.format(
                        FormatUtils.formatear_excepcion(e)))

                    driver.refresh()
                    time.sleep(3)
                except selExcep.NoSuchElementException as e:

                    AccionesHtml.log.error(
                        constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_ERROR_NO_SUCH_ELEM_EXCEP.format(
                            FormatUtils.formatear_excepcion(e)))

                    driver.refresh()
                    time.sleep(3)
                except selExcep.TimeoutException as e:

                    AccionesHtml.log.error(constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_ERROR_TIMEOUT_EXCEP.
                                           format(FormatUtils.formatear_excepcion(e)))

                    driver.refresh()
                    time.sleep(3)
                except selExcep.WebDriverException as e:

                    AccionesHtml.log.error(
                        constantes_webdriver_actions.NAVEGACION_CARPETAS_SEG_LOG_ERROR_WEBDRIVER_EXCEP.format(
                            FormatUtils.formatear_excepcion(e)))

                    time.sleep(3)

        result_navegacion_carpetas.finalizar_tiempo_de_ejecucion()
        result_navegacion_carpetas.establecer_tiempo_de_ejecucion()

        # verifica que no haya algun mensaje de error en la plataforma, en caso contrario se muestra el mensaje de
        # error que aparace en la plataforma dentro del result
        if ValidacionesHTML.verificar_error_plataforma(driver):
            msg_error = ValidacionesHTML.obtener_mensaje_error_plataforma(driver)
            result_navegacion_carpetas.validacion_correcta = False
            result_navegacion_carpetas.mensaje_error = constantes_webdriver_actions. \
                NAVEGACION_CARPETAS_SEG_MSG_ERROR_PLATAFORMA_OWA.format(msg_error)
        else:
            result_navegacion_carpetas.validacion_correcta = True
            result_navegacion_carpetas.mensaje_error = constantes_json.OUTPUT_EXITOSO_2_1

        result_list.result_validacion_navegacion_carpetas = result_navegacion_carpetas

        return result_list