def localizar_boton_perfil_usuario(driver: WebDriver, timeout: int = 7):
        tiempo_limite = Temporizador.obtener_tiempo_timer() + timeout

        while Temporizador.obtener_tiempo_timer() < tiempo_limite:

            # verifica si encontro folder en caso de estar en plataforma OWA 2013
            if ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver, constantes_webdriver_actions.
                    CERRAR_SESION_BTN_PERFIL_USUARIO_OWA_2013):

                return driver.find_element_by_xpath(
                    constantes_webdriver_actions.
                    CERRAR_SESION_BTN_PERFIL_USUARIO_OWA_2013)

            # verifica si encontro folder en caso de estar en plataforma OWA 2016
            elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver, constantes_webdriver_actions.
                    CERRAR_SESION_BTN_PERFIL_USUARIO_OWA_2016):

                return driver.find_element_by_xpath(
                    constantes_webdriver_actions.
                    CERRAR_SESION_BTN_PERFIL_USUARIO_OWA_2016)

        raise SelExcept.TimeoutException(
            msg=
            'No fue posible localizar el boton de perfil del usuario dentro de la '
            'plataforma')
Ejemplo n.º 2
0
    def obtener_carpetas_en_sesion(driver: WebDriver):

        lista_de_carpetas_localizadas = []
        lista_nombres_de_carpetas_formateadas = []
        tiempo_de_inicio = Temporizador.obtener_tiempo_timer()
        tiempo_de_finalizacion = 0
        se_encontraron_carpetas = False

        while tiempo_de_finalizacion < 60:
            time.sleep(10)

            if ValidacionesHTML.verificar_elemento_encontrado_por_clase_js(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_CSS_CARPETA_OWA_2016):
                AccionesHtml.owa_descubierto = 2016
                se_encontraron_carpetas = True
            elif ValidacionesHTML.verificar_elemento_encontrado_por_clase_js(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_CSS_CARPETA_OWA_2013):
                AccionesHtml.owa_descubierto = 2013
                se_encontraron_carpetas = True
            elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_XPATH_CARPETA_OWA_2010):
                AccionesHtml.owa_descubierto = 2010
                se_encontraron_carpetas = True

            tiempo_de_finalizacion = Temporizador.obtener_tiempo_timer() - tiempo_de_inicio

            if tiempo_de_finalizacion % 20 == 0:
                AccionesHtml.navegar_a_portal_principal_owa(AccionesHtml.url_owa_exchange)
                driver.refresh()

        if not se_encontraron_carpetas:
            tiempo_de_finalizacion = Temporizador.obtener_tiempo_timer() - tiempo_de_inicio
        else:
            time.sleep(4)

            if AccionesHtml.owa_descubierto == 2010:
                lista_de_carpetas_localizadas = driver.find_elements_by_xpath(
                    constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_XPATH_CARPETA_OWA_2010)
            elif AccionesHtml.owa_descubierto == 2013:
                lista_de_carpetas_localizadas = driver.execute_script(constantes_webdriver_actions.
                                                                      OBTENER_CARPETAS_EN_SESION_JS_OBTENER_CARPETA_2013)
            elif AccionesHtml.owa_descubierto == 2016:
                lista_de_carpetas_localizadas = driver.execute_script(constantes_webdriver_actions.
                                                                      OBTENER_CARPETAS_EN_SESION_JS_OBTENER_CARPETA_2016)

        for carpeta in lista_de_carpetas_localizadas:

            if AccionesHtml.owa_descubierto == 2010:
                nombre_de_carpeta = carpeta.text
            else:
                nombre_de_carpeta = FormatUtils.remover_backspaces(carpeta.get_attribute('innerHTML'))

            lista_nombres_de_carpetas_formateadas.append(nombre_de_carpeta)

        return lista_nombres_de_carpetas_formateadas
    def localizar_enlace_cierre_sesion_owa_2010(driver: WebDriver,
                                                timeout: int = 7):
        tiempo_limite = Temporizador.obtener_tiempo_timer() + timeout

        while Temporizador.obtener_tiempo_timer() < tiempo_limite:

            # verifica si encontro folder en caso de estar en plataforma OWA 2013
            if ValidacionesHTML.verificar_elemento_encontrado_por_id(
                    driver, constantes_webdriver_actions.
                    CERRAR_SESION_CIERRE_SESION_ID_BTN_CIERRE_SESION_OWA_2010):
                return driver.find_element_by_id(
                    constantes_webdriver_actions.
                    CERRAR_SESION_CIERRE_SESION_ID_BTN_CIERRE_SESION_OWA_2010)

        raise SelExcept.TimeoutException(
            msg=
            'No fue posible localizar el boton de cierre de sesion dentro de la '
            'plataforma')
    def obtener_carpeta_con_timeout(driver: WebDriver,
                                    nombre_de_la_carpeta: str,
                                    timeout: int = 7):
        tiempo_limite = Temporizador.obtener_tiempo_timer() + timeout

        while Temporizador.obtener_tiempo_timer() < tiempo_limite:

            # verifica si encontro folder en caso de estar en plataforma OWA 2010
            if ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver,
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2010.format(
                        nombre_de_la_carpeta)):

                return driver.find_element_by_xpath(
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2010.format(
                        nombre_de_la_carpeta))

            elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver,
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2013.format(
                        nombre_de_la_carpeta)):

                return driver.find_element_by_xpath(
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2013.format(
                        nombre_de_la_carpeta))

            elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver,
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2016.format(
                        nombre_de_la_carpeta)):

                return driver.find_element_by_xpath(
                    constantes_webdriver_actions.
                    NAVEGACION_CARPETAS_SEG_XPATH_CARPETA_OWA_2016.format(
                        nombre_de_la_carpeta))

        raise SelExcept.TimeoutException(
            msg='No fue posible localizar la carpeta dentro de la plataforma')
    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 navegacion_de_carpetas_por_segundos(correo: Correo,
                                            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(
        )
        lista_carpetas = BusquedaElementosHtml.obtener_carpetas_en_sesion(
            driver)

        total_contadores_errores = 0
        contador_errores_staleelementreferenceexception = 0
        contador_errores_elementclickinterceptedexception = 0
        contador_errores_nosuchelementexception = 0
        contador_errores_timeoutexception = 0
        contador_errores_webdriverexception = 0
        intento_de_clicks_en_carpeta = 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

            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

            return result_list

        while Temporizador.obtener_tiempo_timer() < tiempo_por_verificar:
            for carpeta in lista_carpetas:
                try:
                    elemento_html_carpeta = BusquedaElementosHtml.obtener_carpeta_con_timeout(
                        driver, carpeta, 7)
                    elemento_html_carpeta.click()

                except sel_excep.StaleElementReferenceException:
                    contador_errores_staleelementreferenceexception += 1

                except sel_excep.ElementClickInterceptedException:
                    contador_errores_elementclickinterceptedexception += 1

                except sel_excep.NoSuchElementException:
                    contador_errores_nosuchelementexception += 1

                except sel_excep.TimeoutException:
                    contador_errores_timeoutexception += 1

                except sel_excep.WebDriverException:
                    contador_errores_webdriverexception += 1

                time.sleep(8)
                intento_de_clicks_en_carpeta += 1

        result_navegacion_carpetas.finalizar_tiempo_de_ejecucion()
        result_navegacion_carpetas.establecer_tiempo_de_ejecucion()

        total_contadores_errores = contador_errores_staleelementreferenceexception + \
                                   contador_errores_elementclickinterceptedexception + \
                                   contador_errores_nosuchelementexception + \
                                   contador_errores_timeoutexception + \
                                   contador_errores_webdriverexception

        # 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)
        elif total_contadores_errores == intento_de_clicks_en_carpeta:
            result_navegacion_carpetas.validacion_correcta = False
            result_navegacion_carpetas.mensaje_error = constantes_webdriver_actions.\
                NAVEGACION_CARPETAS_SEG_MSG_ERROR_INTENTOS_CLICK.format(intento_de_clicks_en_carpeta)
        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
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
 def establecer_fecha_tiempo_de_inicio(objeto_json):
     objeto_json['start'] = Temporizador.obtener_fecha_tiempo_actual()
     return objeto_json
    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
Ejemplo n.º 10
0
    def obtener_carpetas_en_sesion(driver: WebDriver):

        lista_de_carpetas_localizadas = []
        lista_nombres_de_carpetas_formateadas = []
        tiempo_de_inicio = Temporizador.obtener_tiempo_timer()
        tiempo_de_finalizacion = 0
        se_encontraron_carpetas = False

        while tiempo_de_finalizacion < 60:
            time.sleep(10)

            if ValidacionesHTML.verificar_elemento_encontrado_por_clase_js(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_CSS_CARPETA_OWA_2016):
                AccionesHtml.owa_descubierto = 2016
                se_encontraron_carpetas = True
            elif ValidacionesHTML.verificar_elemento_encontrado_por_clase_js(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_CSS_CARPETA_OWA_2013):
                AccionesHtml.owa_descubierto = 2013
                se_encontraron_carpetas = True
            elif ValidacionesHTML.verificar_elemento_encontrado_por_xpath(
                    driver, constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_XPATH_CARPETA_OWA_2010):
                AccionesHtml.owa_descubierto = 2010
                se_encontraron_carpetas = True

            tiempo_de_finalizacion = Temporizador.obtener_tiempo_timer() - tiempo_de_inicio

            if tiempo_de_finalizacion % 20 == 0:
                AccionesHtml.navegar_a_portal_principal_owa(AccionesHtml.url_owa_exchange)
                driver.refresh()

            if se_encontraron_carpetas:
                AccionesHtml.log.info(constantes_webdriver_actions.
                    OBTENER_CARPETAS_EN_SESION_LOG_INFO_LOCALIZACION_EXITOSA_CARPETAS.format(
                    FormatUtils.
                        truncar_float_cadena(tiempo_de_finalizacion)))
                break
            else:
                AccionesHtml.log.error(constantes_webdriver_actions.
                                       OBTENER_CARPETAS_EN_SESION_LOG_ERROR_LOCALIZACION_SIN_EXITO_CARPETAS)

                AccionesHtml.log.info(constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_MOSTRAR_TITLE_AND_URL
                                      .format(driver.title, driver.current_url))

        if not se_encontraron_carpetas:

            tiempo_de_finalizacion = Temporizador.obtener_tiempo_timer() - tiempo_de_inicio

            AccionesHtml.log.error(constantes_webdriver_actions.
                OBTENER_CARPETAS_EN_SESION_LOG_ERROR_LOCALIZACION_SIN_EXITO_CARPETAS_EXCESO_TIEMPO.format(
                FormatUtils.truncar_float_cadena(tiempo_de_finalizacion)))

            AccionesHtml.log.info(constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_MOSTRAR_TITLE_AND_URL
                                  .format(driver.title, driver.current_url))

        else:
            AccionesHtml.log.info(constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_OWA_LOCALIZADO.format(
                AccionesHtml.owa_descubierto))

            time.sleep(4)

            if AccionesHtml.owa_descubierto == 2010:
                lista_de_carpetas_localizadas = driver.find_elements_by_xpath(
                    constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_XPATH_CARPETA_OWA_2010)
            elif AccionesHtml.owa_descubierto == 2013:
                lista_de_carpetas_localizadas = driver.execute_script(constantes_webdriver_actions.
                                                                      OBTENER_CARPETAS_EN_SESION_JS_OBTENER_CARPETA_2013)
            elif AccionesHtml.owa_descubierto == 2016:
                lista_de_carpetas_localizadas = driver.execute_script(constantes_webdriver_actions.
                                                                      OBTENER_CARPETAS_EN_SESION_JS_OBTENER_CARPETA_2016)

        for carpeta in lista_de_carpetas_localizadas:

            if AccionesHtml.owa_descubierto == 2010:
                nombre_de_carpeta = carpeta.text
            else:
                nombre_de_carpeta = FormatUtils.remover_backspaces(carpeta.get_attribute('innerHTML'))

            AccionesHtml.log.info(constantes_webdriver_actions.OBTENER_CARPETAS_EN_SESION_OWA_CARPETA_OBTENIDA.
                                  format(nombre_de_carpeta))

            lista_nombres_de_carpetas_formateadas.append(nombre_de_carpeta)

        return lista_nombres_de_carpetas_formateadas
    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
Ejemplo n.º 12
0
 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()
Ejemplo n.º 13
0
 def inicializar_tiempo_de_ejecucion(self):
     self.datetime_inicial = Temporizador.obtener_fecha_tiempo_actual()
     self.tiempo_inicio_de_ejecucion = Temporizador.obtener_tiempo_timer()