Пример #1
0
    def navegar_a_portal_principal_owa(driver: WebDriver, url: str, result_list: ValidacionResultList):
        resultado = ResultStep()
        resultado.tiempo_inicio_de_ejecucion = 0
        resultado.inicializar_tiempo_de_ejecucion()

        try:
            driver.set_page_load_timeout(100)
            driver.get(url)

            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_INGRESO_SITIO_CON_EXITO. \
                format(url)

            resultado.validacion_correcta = True

        except selExcep.TimeoutException as e:

            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_TIMEOUT_EXCEP_MSG_ERROR. \
                format(url, FormatUtils.formatear_excepcion(e))

            resultado.validacion_correcta = False

        except selExcep.WebDriverException as e:

            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_WEBDRIVER_EXCEP_MSG_ERROR. \
                format(FormatUtils.formatear_excepcion(e))

            resultado.validacion_correcta = False

        resultado.finalizar_tiempo_de_ejecucion()
        resultado.establecer_tiempo_de_ejecucion()
        result_list.result_validacion_ingreso_url = resultado

        return result_list
Пример #2
0
    def validacion_json_inicio_sesion(result_url,
                                      result_sesion,
                                      objeto_json):
        result_final = ResultStep()

        # valida el estatus de ambos steps
        if not result_url.validacion_correcta:
            result_final.mensaje_error = result_url.mensaje_error
            result_final.validacion_correcta = False
        elif not result_sesion.validacion_correcta:
            result_final.mensaje_error = result_sesion.mensaje_error
            result_final.validacion_correcta = False
        else:
            result_final.mensaje_error = result_sesion.mensaje_error
            result_final.validacion_correcta = True

        # establece el datetime de inicio
        result_final.datetime_inicial = result_url.datetime_inicial

        # establece el datetime final
        result_final.datetime_final = result_sesion.datetime_final

        # establece el tiempo total de la ejecucion de ambos steps
        result_final.tiempo_inicio_de_ejecucion = result_url.tiempo_inicio_de_ejecucion
        result_final.tiempo_fin_de_ejecucion = result_sesion.tiempo_fin_de_ejecucion

        # establece el tiempo total de ejecucion
        result_final.establecer_tiempo_de_ejecucion()

        objeto_json['steps'][0]['status'] = constantes_json.STATUS_CORRECTO if \
            result_final.validacion_correcta else constantes_json.STATUS_FALLIDO

        objeto_json['steps'][0]['output'][0]['output'] = result_final.mensaje_error

        objeto_json['steps'][0]['output'][0]['status'] = constantes_json.STATUS_CORRECTO if \
            result_final.validacion_correcta else constantes_json.STATUS_FALLIDO

        objeto_json['steps'][0]['start'] = result_final.datetime_inicial
        objeto_json['steps'][0]['end'] = result_final.datetime_final
        objeto_json['steps'][0]['time'] = result_final.tiempo_total_de_la_ejecucion

        return objeto_json
    def navegar_a_portal_principal_owa(web_driver: WebDriver, url: str,
                                       result_list: ValidacionResultList):

        resultado = ResultStep()
        resultado.tiempo_inicio_de_ejecucion = 0
        resultado.inicializar_tiempo_de_ejecucion()
        segundos_por_esperar_elemento_html = 10

        try:
            web_driver.get(url)
            ValidacionesHTML.verificar_ingreso_exitoso_pagina_principal(
                web_driver, constantes_webdriver_actions.
                INICIAR_SESION_EN_OWA_ID_INPUT_PASSWORD,
                segundos_por_esperar_elemento_html)

            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_INGRESO_SITIO_CON_EXITO. \
                format(url)

            resultado.validacion_correcta = True

        except sel_excep.TimeoutException as e:
            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_TIMEOUT_EXCEP_MSG_ERROR.format(
                segundos_por_esperar_elemento_html, url,
                FormatUtils.formatear_excepcion(e))

            resultado.validacion_correcta = False

        except sel_excep.WebDriverException as e:
            resultado.mensaje_error = constantes_webdriver_actions.NAVEGAR_SITIO_MSG_WEBDRIVER_EXCEP_MSG_ERROR. \
                format(FormatUtils.formatear_excepcion(e))

            resultado.validacion_correcta = False

        resultado.finalizar_tiempo_de_ejecucion()
        resultado.establecer_tiempo_de_ejecucion()
        result_list.result_validacion_ingreso_url = resultado

        return result_list
    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