Esempio n. 1
0
def verificacion_script_argumento_json(argumento_script_json):
    """

    :param argumento_script_json:
    :return:
    """
    if not FormatUtils.cadena_a_json_valido(argumento_script_json):
        return False

    json_argumento_formateado = json.loads(argumento_script_json)

    if not FormatUtils.verificar_keys_json(json_argumento_formateado):
        return False

    elif not path.exists(json_argumento_formateado['pathImage']):
        print('La imagen/archivo por cargar dentro de la plataforma Claro Drive no fue localizado dentro del server, '
              'favor de verificar nuevamente el path de la imagen/archivo.')
        return False

    elif not path.isfile(json_argumento_formateado['pathImage']):
        print('El path de la imagen/archivo establecida, no corresponde a un archivo o imagen valida, favor de '
              'verificar nuevamente el path del archivo.')
        return False

    return True
Esempio n. 2
0
def main():
    """

    """
    # verificacion del archivo de configuracion (config.ini)
    archivo_config = FormatUtils.lector_archivo_ini()

    if not verificacion_archivo_config(archivo_config):
        sys.exit()

    param_archivo_config_path_web_driver = archivo_config.get('Driver', 'ruta')
    param_archivo_config_web_driver_por_usar = archivo_config.get(
        'Driver', 'driverPorUtilizar')
    param_archivo_config_directorio_descargas = archivo_config.get(
        'Driver', 'folder_descargas')

    # verificacion de argumentos dentro de la ejecucion del script
    if not verificacion_script_argumentos():
        sys.exit()

    argumentos_script = sys.argv[1:]
    argumento_script_json = argumentos_script[0]

    # verifica el formato del argumento JSON y obtiene cada uno de los parametros
    if not verificacion_script_argumento_json(argumento_script_json):
        sys.exit()

    argumento_script_json = json.loads(argumento_script_json)

    # establece la carpeta de descarga dinamica (donde se descargara la imagen desde el portal de claro drive)
    config_constantes.PATH_CARPETA_DESCARGA = UtilsMain.generar_carpeta_descarga_dinamica(
        argumento_script_json['pathImage'])

    UtilsMain.crear_directorio(config_constantes.PATH_CARPETA_DESCARGA)

    # se establece la configuracion del webdriver
    webdriver_config = ConfiguracionWebDriver(
        param_archivo_config_path_web_driver,
        param_archivo_config_web_driver_por_usar,
        param_archivo_config_directorio_descargas)

    # se establece y obtiene el webdriver/navegar para la ejecucion de las pruebas UX en claro drive
    webdriver_ux_test = webdriver_config.configurar_obtencion_web_driver()

    # webdriver_ux_test.set_window_position(0, 0)
    # webdriver_ux_test.set_window_size(1366, 768)

    # inicia depuracion de descargas antiguas
    UtilsMain.depurar_carpeta_de_descargas(
        param_archivo_config_directorio_descargas)

    resultado_json_evaluacines_ux_claro_drive = ejecucion_validaciones_claro_drive(
        webdriver_ux_test, argumento_script_json)

    UtilsMain.eliminar_directorio_con_contenido(
        config_constantes.PATH_CARPETA_DESCARGA)

    print(json.dumps(resultado_json_evaluacines_ux_claro_drive))
    def inicializar_webdriver_chrome(self):

        archivo_config_ini = FormatUtils.lector_archivo_ini()
        modo_headless = archivo_config_ini.getboolean('Driver', 'headless')
        mandar_log_a_dev_null = archivo_config_ini.getboolean(
            'Driver', 'log_path_dev_null')

        opciones_chrome = webdriver.ChromeOptions()

        # ignora las certificaciones de seguridad, esto solamente se realiza para la experiencia de usuario
        opciones_chrome.add_argument('--ignore-certificate-errors')
        opciones_chrome.add_argument('--allow-running-insecure-content')
        opciones_chrome.add_argument("--enable-javascript")
        opciones_chrome.add_argument('window-size=1920x1080')
        opciones_chrome.add_argument('--no-sandbox')
        opciones_chrome.add_argument('--disable-dev-shm-usage')

        # establece el modo headless, esto dependiendo de la opcion que se tenga en el archivo config.ini
        if modo_headless:
            opciones_chrome.add_argument("--headless")

        opciones_chrome.add_experimental_option('excludeSwitches',
                                                ['enable-logging'])

        opciones_chrome.add_experimental_option('prefs', {
            'download.default_directory':
            config_constantes.PATH_CARPETA_DESCARGA
        })

        chrome_capabilities = webdriver.DesiredCapabilities().CHROME.copy()
        chrome_capabilities['acceptSslCerts'] = True
        chrome_capabilities['acceptInsecureCerts'] = True

        # establece el directorio al cual se redireccionara el log generado por el chromedriver
        if mandar_log_a_dev_null:
            param_service_log_path = config_constantes.DEV_NULL
        else:
            param_service_log_path = None

        try:
            webdriver_chrome = webdriver.Chrome(
                self.ruta_web_driver,
                chrome_options=opciones_chrome,
                desired_capabilities=chrome_capabilities,
                service_log_path=param_service_log_path)

        except FileNotFoundError as e:
            print('Sucedio un error al intentar configurar el webdriver: {}'.
                  format(e))
            sys.exit()

        except Exception as e:
            print(
                'Sucedio una excepcion al intentar configurar el webdriver {}'.
                format(e))
            sys.exit()

        return webdriver_chrome
    def ingreso_pagina_principal_claro_drive(webdriver: WebDriver, json_eval):
        tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
        fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

        try:
            url_claro_drive = FormatUtils.lector_archivo_ini().get(
                'Driver', 'url_claro_drive')
            webdriver.get(url_claro_drive)

            # localiza boton de inicio en la pagina principal
            HtmlActions.webdriver_wait_presence_of_element_located(
                webdriver,
                15,
                id=const_claro_drive.INGRESO_PAGINA_PRINCIPAL_ID_INPUT_LOGIN)

            json_eval = UtilsEvaluaciones.establecer_output_status_step(
                json_eval, 0, 0, True,
                const_claro_drive.MSG_OUTPUT_INGRESO_PAGINA_PRINCIPAL_EXITOSO)

        except ElementNotInteractableException as e:
            msg_output = const_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 = const_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 = const_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 InvalidArgumentException as e:
            msg_output = const_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 = const_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 ejecucion_validaciones_drop_box(webdriver, argumento_script_json):
    nombre_de_imagen_sin_extension = Path(
        argumento_script_json['pathImage']).stem
    nombre_de_imagen_con_extension = path.basename(
        argumento_script_json['pathImage'])
    config_constantes.NOMBRE_IMAGEN_POR_CARGAR_CON_EXTENSION = path.basename(
        argumento_script_json['pathImage'])
    archivo_config = FormatUtils.lector_archivo_ini()
    url_login = archivo_config.get('Dropbox_config', 'url_login')

    # establece los datetime de inicio para la prueba UX
    tiempo_inicial_ejecucion_prueba = Temporizador.obtener_tiempo_timer()
    fecha_prueba_inicial = Temporizador.obtener_fecha_tiempo_actual()

    # se genera el json de evaluacion
    json_evaluacion_drop_box = GeneradorJsonBaseEvaluacion.generar_nuevo_template_json(
    )

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.ingreso_pagina_principal_dropbox(
        webdriver, json_evaluacion_drop_box)

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.inicio_sesion_dropbox(
        webdriver, json_evaluacion_drop_box, argumento_script_json)

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.cargar_archivo_dropbox(
        webdriver, json_evaluacion_drop_box, argumento_script_json,
        nombre_de_imagen_sin_extension, nombre_de_imagen_con_extension)

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.descargar_archivo_dropbox(
        webdriver, json_evaluacion_drop_box, nombre_de_imagen_con_extension)

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.eliminar_archivo_dropbox(
        webdriver, json_evaluacion_drop_box, nombre_de_imagen_con_extension)

    json_evaluacion_drop_box = EvaluacionesDropBoxDriveSteps.cerrar_sesion_dropbox(
        webdriver, json_evaluacion_drop_box)

    tiempo_final_ejecucion_prueba = Temporizador.obtener_tiempo_timer(
    ) - tiempo_inicial_ejecucion_prueba
    fecha_prueba_final = Temporizador.obtener_fecha_tiempo_actual()

    json_evaluacion_drop_box['start'] = fecha_prueba_inicial
    json_evaluacion_drop_box['end'] = fecha_prueba_final
    json_evaluacion_drop_box['time'] = tiempo_final_ejecucion_prueba
    json_evaluacion_drop_box['status'] = verificacion_estatus_final(
        json_evaluacion_drop_box)

    json_padre = {}
    json_padre.update({'body': json_evaluacion_drop_box})

    time.sleep(2)

    webdriver.close()
    webdriver.quit()

    return json_padre
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:
        btn_crear = webdriver_test_ux.find_element_by_class_name(
            'button-create-resource')
        btn_crear.click()
        time.sleep(10)

        WebDriverWait(webdriver_test_ux, 20).until(
            EC.presence_of_element_located((By.ID, 'file_upload_start')))

        input_file = webdriver_test_ux.find_element_by_id('file_upload_start')

        time.sleep(4)
        input_file.send_keys(path_archivo_carga)

        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 selExcep.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 selExcep.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'

    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 inicializar_webdriver_firefox(self):

        archivo_config_ini = FormatUtils.lector_archivo_ini()
        modo_headless = archivo_config_ini.getboolean('Driver', 'headless')
        mandar_log_a_dev_null = archivo_config_ini.getboolean('Driver', 'log_path_dev_null')

        mime_types = 'application/zip,application/octet-stream,image/jpeg,application/vnd.ms-outlook,' \
                     'text/html,application/pdf'

        # ruta para deshabilitar log inecesario del geckodriver
        opciones_firefox = webdriver.FirefoxOptions()
        perfil_firefox = webdriver.FirefoxProfile()

        firefox_capabilities = webdriver.DesiredCapabilities().FIREFOX.copy()
        firefox_capabilities.update({'acceptInsecureCerts': True, 'acceptSslCerts': True})
        firefox_capabilities['acceptSslCerts'] = True

        # ignora las certificaciones de seguridad, esto solamente se realiza para la experiencia de usuario
        opciones_firefox.add_argument('--ignore-certificate-errors')
        opciones_firefox.accept_insecure_certs = True
        perfil_firefox.accept_untrusted_certs = True
        perfil_firefox.assume_untrusted_cert_issuer = False
        perfil_firefox.set_preference("browser.download.folderList", 2)
        perfil_firefox.set_preference("browser.download.dir", config_constantes.PATH_CARPETA_DESCARGA)
        perfil_firefox.set_preference("browser.download.manager.showWhenStarting", False)
        perfil_firefox.set_preference("browser.helperApps.alwaysAsk.force", False)
        perfil_firefox.set_preference("browser.helperApps.neverAsk.saveToDisk", mime_types)

        opciones_firefox.headless = modo_headless

        if mandar_log_a_dev_null:
            param_log_path = config_constantes.DEV_NULL
        else:
            param_log_path = None

        try:
            webdriver_firefox = webdriver.Firefox(executable_path=self.ruta_web_driver,
                                                  firefox_options=opciones_firefox,
                                                  firefox_profile=perfil_firefox,
                                                  capabilities=firefox_capabilities,
                                                  log_path=param_log_path)

        except FileNotFoundError as e:
            print('Sucedio un error al intentar configurar el webdriver: {}'.format(e))
            sys.exit()

        except Exception as e:
            print('Sucedio una excepcion al intentar configurar el webdriver {}'.format(e))
            sys.exit()

        return webdriver_firefox
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
Esempio n. 9
0
    def finalizar_tiempos_en_step(json_eval, indice: int, tiempo_step_inicio,
                                  fecha_inicio):

        if tiempo_step_inicio is None:
            tiempo_step_inicio = Temporizador.obtener_tiempo_timer()

        tiempo_step_final = Temporizador.obtener_tiempo_timer(
        ) - tiempo_step_inicio
        fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
        json_eval["steps"][indice]["time"] = FormatUtils.truncar_float_cadena(
            tiempo_step_final)
        json_eval["steps"][indice]["start"] = fecha_inicio
        json_eval["steps"][indice]["end"] = fecha_fin

        return json_eval
def inicio_sesion_claro_drive(webdriver_test_ux: webdriver, jsonEval, jsonArgs):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        webdriver_test_ux.get('https://www.clarodrive.com/')
        btn_inicio_sesion = WebDriverWait(webdriver_test_ux, 6).until(EC.presence_of_element_located((By.ID, 'login')))
        btn_inicio_sesion.click()

        input_email = WebDriverWait(webdriver_test_ux, 6).until(
            EC.presence_of_element_located((By.CLASS_NAME, 'InputEmail')))
        input_email.send_keys(jsonArgs['user'])

        input_password = WebDriverWait(webdriver_test_ux, 6).until(
            EC.presence_of_element_located((By.CLASS_NAME, 'InputPassword')))
        input_password.send_keys(jsonArgs['password'])

        btn_ingreso_cuenta = WebDriverWait(webdriver_test_ux, 6).until(
            EC.presence_of_element_located((By.XPATH, '//button[text()="INICIAR SESI\u00D3N"]')))
        btn_ingreso_cuenta.click()

        WebDriverWait(webdriver_test_ux, 120).until(
            EC.element_to_be_clickable((By.XPATH, '//span[text()="Folder "][@class="name-without-extension"]')))

        jsonEval["steps"][0]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][0]["output"][0]["output"] = 'Se ingresa correctamente al portal Claro Drive'

    except ElementNotInteractableException as e:
        jsonEval["steps"][0]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["output"][0]["output"] = 'fue imposible ingresar al portal Claro Drive'
    except NoSuchElementException as e:
        jsonEval["steps"][0]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["output"][0]["output"] = 'fue imposible ingresar al portal Claro Drive'
    except TimeoutException as e:
        jsonEval["steps"][0]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][0]["output"][0]["output"] = 'fue imposible ingresar al portal Claro Drive'

    tiempo_step_final = Temporizador.obtener_tiempo_timer() - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][0]["time"] = FormatUtils.truncar_float_cadena(tiempo_step_final)
    jsonEval["steps"][0]["start"] = fecha_inicio
    jsonEval["steps"][0]["end"] = fecha_fin

    return jsonEval
Esempio n. 11
0
    def generar_carpeta_descarga_dinamica(path_imagen_prueba_claro_drive):
        path_descarga_hija = '{}_{}_{}'
        archivo_config_ini = FormatUtils.lector_archivo_ini()
        path_descarga_raiz = archivo_config_ini.get('Driver', 'folder_descargas')
        nombre_archivo_sin_extension = Path(path_imagen_prueba_claro_drive).stem
        datetime_fecha_actual = datetime.datetime.today()
        cadena_fecha_hora_actual = '{}_{}_{}_{}_{}_{}'.format(
            datetime_fecha_actual.day, datetime_fecha_actual.month, datetime_fecha_actual.year,
            datetime_fecha_actual.hour, datetime_fecha_actual.minute, datetime_fecha_actual.second)

        path_descarga_hija = path_descarga_hija.format(nombre_archivo_sin_extension, cadena_fecha_hora_actual,
                                                       UtilsMain.generar_cadena_alafanumerica_aleatoria(6))

        path_descarga_hija = join(path_descarga_raiz, path_descarga_hija)

        return path_descarga_hija
def borrar_archivo_claro_drive(webdriver_test_ux: webdriver, jsonEval, nombre_archivo_sin_ext: str, ext_archivo: str):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:

        webdriver_test_ux.refresh()

        archivo_por_eliminar = WebDriverWait(webdriver_test_ux, 20).until(
            EC.element_to_be_clickable(
                (By.XPATH, '//span[@class="name-without-extension"][text()="{} "]'.format(nombre_archivo_sin_ext))))

        archivo_por_eliminar.click()

        btn_borrar = WebDriverWait(webdriver_test_ux, 20).until(EC.element_to_be_clickable(
            (By.XPATH, '//input[@type="button"][@class="menuItem svg deleteImage icon-delete icon-32"]')))

        btn_borrar.click()

        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][3]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][3]["output"][0]["output"] = 'Se realiza el borrado del archivo correctamente'
    except NoSuchElementException as e:
        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["output"][0][
            "output"] = 'No fue posible realizar el borrado del archivo correctamente: {}'.format(e.msg)

    except ElementClickInterceptedException as e:
        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["output"][0][
            "output"] = 'No fue posible realizar el borrado del archivo correctamente: {}'.format(e.msg)

    except TimeoutException as e:
        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["output"][0][
            "output"] = 'No fue posible realizar el borrado del archivo correctamente: {}'.format(e.msg)

    tiempo_step_final = Temporizador.obtener_tiempo_timer() - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][3]["time"] = FormatUtils.truncar_float_cadena(tiempo_step_final)
    jsonEval["steps"][3]["start"] = fecha_inicio
    jsonEval["steps"][3]["end"] = fecha_fin

    return jsonEval
def cerrar_sesion_claro_drive(webdriver_test_ux: webdriver, jsonEval):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        webdriver_test_ux.refresh()
        boton_ajustes = WebDriverWait(webdriver_test_ux, 10).until(EC.element_to_be_clickable((By.ID, 'expand')))
        boton_ajustes.click()

        boton_cerrar_sesion = WebDriverWait(webdriver_test_ux, 20).until(
            EC.element_to_be_clickable((By.XPATH, '//li[@data-id="logout"]/a')))

        boton_cerrar_sesion.click()
        WebDriverWait(webdriver_test_ux, 10).until(EC.presence_of_element_located((By.ID, 'login')))

        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][4]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][4]["output"][0]["output"] = 'Se cierra sesion correctamente'

    except NoSuchElementException as e:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0]["output"] = 'No fue posible realizar el cierre de sesion: {}'.format(e.msg)

    except ElementClickInterceptedException as e:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0]["output"] = 'No fue posible realizar el cierre de sesion: {}'.format(e.msg)

    except TimeoutException as e:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0]["output"] = 'No fue posible realizar el cierre de sesion: {}'.format(e.msg)

    except ElementNotInteractableException as e:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0]["output"] = 'No fue posible realizar el cierre de sesion: {}'.format(e.msg)

    tiempo_step_final = Temporizador.obtener_tiempo_timer() - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][4]["time"] = FormatUtils.truncar_float_cadena(tiempo_step_final)
    jsonEval["steps"][4]["start"] = fecha_inicio
    jsonEval["steps"][4]["end"] = fecha_fin

    return jsonEval
def descarga_archivo_claro_drive(webdriver_test_ux: webdriver,
                                 nombre_archivo_sin_ext: str, jsonEval):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        time.sleep(5)
        img_por_descargar = webdriver_test_ux.find_element_by_xpath(
            '//span[@class="name-without-extension"][text()="{} "]'.format(
                nombre_archivo_sin_ext))
        img_por_descargar.click()
        time.sleep(4)

        btn_descarga = webdriver_test_ux.find_element_by_xpath(
            '//input[@class="menuItem svg downloadImage icon-download icon-32"]'
        )
        btn_descarga.click()
        time.sleep(4)

        jsonEval["steps"][2]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][2]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][2]["output"][0][
            "output"] = 'Se realiza la descarga del archivo correctamente'
    except selExcep.NoSuchElementException:
        jsonEval["steps"][2]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][2]["status"] = jsonConst.FAILED
        jsonEval["steps"][2]["output"][0][
            "output"] = 'No fue posible realizar la descarga del archivo correctamente'
    except selExcep.ElementClickInterceptedException:
        jsonEval["steps"][2]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][2]["status"] = jsonConst.FAILED
        jsonEval["steps"][2]["output"][0][
            "output"] = 'No fue posible realizar la descarga del archivo correctamente'

    tiempo_step_final = Temporizador.obtener_tiempo_timer(
    ) - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][2]["time"] = FormatUtils.truncar_float_cadena(
        tiempo_step_final)
    jsonEval["steps"][2]["start"] = fecha_inicio
    jsonEval["steps"][2]["end"] = fecha_fin

    return jsonEval
Esempio n. 15
0
    def generar_json_inicio_de_sesion_incorrecta(json_eval, tiempo_step_inicio,
                                                 fecha_inicio, indice: int,
                                                 msg_output: str):

        if tiempo_step_inicio is None:
            tiempo_step_inicio = Temporizador.obtener_tiempo_timer()

        json_eval["steps"][indice]["output"][0]["status"] = json_const.FAILED
        json_eval["steps"][indice]["status"] = json_const.FAILED
        json_eval["steps"][indice]["output"][0]["output"] = msg_output

        tiempo_step_final = Temporizador.obtener_tiempo_timer(
        ) - tiempo_step_inicio
        fecha_fin = Temporizador.obtener_fecha_tiempo_actual()

        json_eval["steps"][indice]["time"] = FormatUtils.truncar_float_cadena(
            tiempo_step_final)
        json_eval["steps"][indice]["start"] = fecha_inicio
        json_eval["steps"][indice]["end"] = fecha_fin

        return json_eval
def cerrar_sesion_claro_drive(webdriver_test_ux: webdriver, jsonEval):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        boton_ajustes = webdriver_test_ux.find_element_by_id('expand')
        boton_ajustes.click()

        time.sleep(4)
        boton_cerrar_sesion = webdriver_test_ux.find_element_by_xpath(
            '//li[@data-id="logout"]')
        boton_cerrar_sesion.click()
        time.sleep(10)

        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][4]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][4]["output"][0][
            "output"] = 'Se cierra sesion correctamente'

    except selExcep.NoSuchElementException:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0][
            "output"] = 'No fue posible realizar el cierre de sesion'

    except selExcep.ElementClickInterceptedException:
        jsonEval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["status"] = jsonConst.FAILED
        jsonEval["steps"][4]["output"][0][
            "output"] = 'No fue posible realizar el cierre de sesion'

    tiempo_step_final = Temporizador.obtener_tiempo_timer(
    ) - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][4]["time"] = FormatUtils.truncar_float_cadena(
        tiempo_step_final)
    jsonEval["steps"][4]["start"] = fecha_inicio
    jsonEval["steps"][4]["end"] = fecha_fin

    return jsonEval
def borrar_archivo_claro_drive(webdriver_test_ux: webdriver, jsonEval):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        btn_borrar = webdriver_test_ux.find_element_by_xpath(
            '//input[@class="menuItem svg deleteImage icon-delete icon-32"]')
        btn_borrar.click()
        time.sleep(10)
        btn_cerrar = webdriver_test_ux.find_element_by_xpath(
            '//input[@class="svg exit icon-close icon-32"]')
        time.sleep(4)
        btn_cerrar.click()
        time.sleep(4)

        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][3]["status"] = jsonConst.SUCCESS
        jsonEval["steps"][3]["output"][0][
            "output"] = 'Se realiza el borrado del archivo correctamente'
    except selExcep.NoSuchElementException:
        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["output"][0][
            "output"] = 'No fue posibles realizar el borrado del archivo correctamente'

    except selExcep.ElementClickInterceptedException:
        jsonEval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["status"] = jsonConst.FAILED
        jsonEval["steps"][3]["output"][0][
            "output"] = 'No fue posibles realizar el borrado del archivo correctamente'

    tiempo_step_final = Temporizador.obtener_tiempo_timer(
    ) - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    jsonEval["steps"][3]["time"] = FormatUtils.truncar_float_cadena(
        tiempo_step_final)
    jsonEval["steps"][3]["start"] = fecha_inicio
    jsonEval["steps"][3]["end"] = fecha_fin

    return jsonEval
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 ingreso_pagina_principal_dropbox(webdriver_test_ux: WebDriver,
                                         json_eval):
        tiempo_step_inicio = None
        fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

        try:
            url_pagina_principal = FormatUtils.lector_archivo_ini().get(
                'Dropbox_config', 'url_login')
            webdriver_test_ux.get(url_pagina_principal)

            tiempo_step_inicio = Temporizador.obtener_tiempo_timer()

            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 InvalidArgumentException 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 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
Esempio n. 21
0
    def inicializar_webdriver_chrome(self):

        archivo_config_ini = FormatUtils.lector_archivo_ini()
        modo_headless = archivo_config_ini.getboolean('Driver', 'headless')
        mandar_log_a_dev_null = archivo_config_ini.getboolean(
            'Driver', 'log_path_dev_null')
        directorio_de_descargas = archivo_config_ini.get(
            'Driver', 'folder_descargas')
        profile_data = archivo_config_ini.get('Driver', 'data_profile')
        dir_json_propiedades = archivo_config_ini.get('Driver',
                                                      'dir_json_propiedades')

        opciones_chrome = webdriver.ChromeOptions()

        # obtiene el json de propiedades del perfil, para cambiar el path de la carpeta de descargas
        if dir_json_propiedades:
            FormatUtils.establecer_path_de_descarga(
                config_constantes.PATH_CARPETA_DESCARGA, dir_json_propiedades)

        # se verifica que se haya establecido el perfil/sesion de usuario a utilizar en el navegador
        if profile_data:
            opciones_chrome.add_argument(
                'user-data-dir={}'.format(profile_data))

        # ignora las certificaciones de seguridad, esto solamente se realiza para la experiencia de usuario
        opciones_chrome.add_argument('--ignore-certificate-errors')
        opciones_chrome.add_argument('--allow-running-insecure-content')
        opciones_chrome.add_argument("--enable-javascript")
        opciones_chrome.add_argument('window-size=1920x1080')
        opciones_chrome.add_argument('--no-sandbox')
        opciones_chrome.add_argument('--enable-sync')
        opciones_chrome.add_argument('--profile-directory=Profile 1')

        # establece el modo headless, esto dependiendo de la opcion que se tenga en el archivo config.ini
        if modo_headless:
            opciones_chrome.add_argument("--headless")

        opciones_chrome.add_experimental_option('excludeSwitches',
                                                ['enable-logging'])
        # opciones_chrome.add_experimental_option('prefs', {'download.default_directory':
        #     config_constantes.PATH_CARPETA_DESCARGA})

        prefs = {
            "profile.default_content_settings.popups": 0,
            "download.default_directory": config_constantes.
            PATH_CARPETA_DESCARGA,  # IMPORTANT - ENDING SLASH V IMPORTANT
            "directory_upgrade": True
        }

        opciones_chrome.add_experimental_option("prefs", prefs)

        chrome_capabilities = webdriver.DesiredCapabilities().CHROME.copy()
        chrome_capabilities['acceptSslCerts'] = True
        chrome_capabilities['acceptInsecureCerts'] = True

        # establece el directorio al cual se redireccionara el log generado por el chromedriver
        if mandar_log_a_dev_null:
            param_service_log_path = config_constantes.DEV_NULL
        else:
            param_service_log_path = None

        try:
            webdriver_chrome = webdriver.Chrome(
                self.ruta_web_driver,
                chrome_options=opciones_chrome,
                desired_capabilities=chrome_capabilities,
                service_log_path=param_service_log_path)

        except FileNotFoundError as e:
            print('Sucedio un error al intentar configurar el webdriver: {}'.
                  format(e))
            sys.exit()

        except Exception as e:
            print(
                'Sucedio una excepcion al intentar configurar el webdriver {}'.
                format(e))
            sys.exit()

        return webdriver_chrome
def main():

    file_config = FormatUtils.lector_archivo_ini()

    path_web_driver = file_config.get('Driver', 'ruta')
    web_driver_por_usar = file_config.get('Driver', 'driverPorUtilizar')

    tiempo_inicial_ejecucion_prueba = Temporizador.obtener_tiempo_timer()
    fecha_prueba_inicial = Temporizador.obtener_fecha_tiempo_actual()

    # verifica que el usuario haya establecido el path de la imagen a subir
    args = sys.argv[1:]

    if len(args) == 0:
        print('Favor de establecer el parametro json')
        sys.exit()

    json_args = args[0]

    if not FormatUtils.cadena_a_json_valido(json_args):
        sys.exit()
    else:
        json_args = json.loads(json_args)

    if not FormatUtils.verificar_keys_json(json_args):
        sys.exit()

    if not path.exists(json_args['pathImage']):
        print(
            'La imagen/archivo por cargar no existe o no se localiza, favor de corregir el path del archivo'
        )
        sys.exit()
    elif not path.isfile(json_args['pathImage']):
        print(
            'La ruta establecida no corresponde a un archivo o imagen valido, favor de corregir el path del archivo'
        )
        sys.exit()

    nombre_archivo_imagen_sin_ext = Path(json_args['pathImage']).stem

    # se establece el navegador (por defecto firefox)
    webdriver_config = ConfiguracionWebDriver(path_web_driver,
                                              web_driver_por_usar)
    webdriver_ux_test = webdriver_config.configurar_obtencion_web_driver()

    # se genera el json de evaluacion
    json_evaluacion_claro_drive = GeneradorJsonBaseEvaluacion.generar_nuevo_template_json(
    )

    json_evaluacion_claro_drive = inicio_sesion_claro_drive(
        webdriver_ux_test, json_evaluacion_claro_drive, json_args)

    json_evaluacion_claro_drive = carga_archivo_claro_drive(
        webdriver_ux_test, json_args['pathImage'],
        nombre_archivo_imagen_sin_ext, json_evaluacion_claro_drive)

    json_evaluacion_claro_drive = descarga_archivo_claro_drive(
        webdriver_ux_test, nombre_archivo_imagen_sin_ext,
        json_evaluacion_claro_drive)
    json_evaluacion_claro_drive = borrar_archivo_claro_drive(
        webdriver_ux_test, json_evaluacion_claro_drive)

    json_evaluacion_claro_drive = cerrar_sesion_claro_drive(
        webdriver_ux_test, json_evaluacion_claro_drive)

    tiempo_final_ejecucion_prueba = Temporizador.obtener_tiempo_timer(
    ) - tiempo_inicial_ejecucion_prueba
    fecha_prueba_final = Temporizador.obtener_fecha_tiempo_actual()

    json_evaluacion_claro_drive['start'] = fecha_prueba_inicial
    json_evaluacion_claro_drive['end'] = fecha_prueba_final
    json_evaluacion_claro_drive['time'] = tiempo_final_ejecucion_prueba
    json_evaluacion_claro_drive['status'] = verificacion_estatus_final(
        json_evaluacion_claro_drive)

    #json_evaluacion_claro_drive = GeneradorJsonBaseEvaluacion. \
    #    establecer_estructura_principal_json(json_args['user'], json_evaluacion_claro_drive)

    time.sleep(2)

    webdriver_ux_test.close()
    webdriver_ux_test.quit()

    print(json.dumps(json_evaluacion_claro_drive))
def cerrar_sesion_dropbox(webdriver_test_ux: WebDriver, json_eval):
    tiempo_step_inicio = Temporizador.obtener_tiempo_timer()
    fecha_inicio = Temporizador.obtener_fecha_tiempo_actual()

    try:
        boton_imagen_perfil = WebDriverWait(webdriver_test_ux, 12).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'dig-Menu')))

        boton_imagen_perfil.click()

        boton_salir_sesion = WebDriverWait(webdriver_test_ux, 12).until(
            EC.element_to_be_clickable((By.XPATH, '//span[text()="Salir"]')))

        boton_salir_sesion.click()

        WebDriverWait(webdriver_test_ux, 12).until(
            EC.element_to_be_clickable((By.NAME, 'login_email')))

        WebDriverWait(webdriver_test_ux, 12).until(
            EC.element_to_be_clickable((By.NAME, 'login_password')))

        json_eval["steps"][4]["output"][0]["status"] = jsonConst.SUCCESS
        json_eval["steps"][4]["status"] = jsonConst.SUCCESS
        json_eval["steps"][4]["output"][0][
            "output"] = 'Se cierra sesion correctamente dentro del portal Drop Box'

    except ElementNotInteractableException as e:
        json_eval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["output"][0][
            "output"] = 'fue imposible cerrar sesion dentro del portal Drop Box: {}'.format(
                e.msg)

    except NoSuchElementException as e:
        json_eval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["output"][0][
            "output"] = 'fue imposible cerrar sesion dentro del portal Drop Box: {}'.format(
                e.msg)

    except TimeoutException as e:
        json_eval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["output"][0][
            "output"] = 'fue imposible cerrar sesion dentro del portal Drop Box: {}'.format(
                e.msg)

    except ElementClickInterceptedException as e:
        json_eval["steps"][4]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["status"] = jsonConst.FAILED
        json_eval["steps"][4]["output"][0][
            "output"] = 'fue imposible cerrar sesion 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"][4]["time"] = FormatUtils.truncar_float_cadena(
        tiempo_step_final)
    json_eval["steps"][4]["start"] = fecha_inicio
    json_eval["steps"][4]["end"] = fecha_fin

    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 eliminar_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:

        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_eliminar = WebDriverWait(webdriver_test_ux, 20).until(
            EC.element_to_be_clickable((By.CLASS_NAME, 'action-delete')))

        btn_eliminar.click()

        btn_eliminar_modal = WebDriverWait(webdriver_test_ux, 20).until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//span[@class="mc-button-content"][text()="Eliminar"]')))

        btn_eliminar_modal.click()

        WebDriverWait(webdriver_test_ux, 30).until(
            EC.element_to_be_clickable((
                By.XPATH,
                '//p[@class="mc-snackbar-title"][text()="Se elimin\u00F3 1 elemento."]'
            )))

        json_eval["steps"][3]["output"][0]["status"] = jsonConst.SUCCESS
        json_eval["steps"][3]["status"] = jsonConst.SUCCESS
        json_eval["steps"][3]["output"][0][
            "output"] = 'Se elimina archivo correctamente dentro del portal Drop Box'

    except ElementNotInteractableException as e:
        json_eval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["output"][0][
            "output"] = 'fue imposible eliminar el archivo dentro del portal Drop Box: {}'.format(
                e)
    except NoSuchElementException as e:
        json_eval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["output"][0][
            "output"] = 'fue imposible eliminar el archivo dentro del portal Drop Box: {}'.format(
                e)
    except TimeoutException as e:
        json_eval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["output"][0][
            "output"] = 'fue imposible eliminar el archivo dentro del portal Drop Box: {}'.format(
                e)
    except ElementClickInterceptedException as e:
        json_eval["steps"][3]["output"][0]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["status"] = jsonConst.FAILED
        json_eval["steps"][3]["output"][0][
            "output"] = 'fue imposible eliminar el archivo dentro del portal Drop Box: {}'.format(
                e)

    tiempo_step_final = Temporizador.obtener_tiempo_timer(
    ) - tiempo_step_inicio
    fecha_fin = Temporizador.obtener_fecha_tiempo_actual()
    json_eval["steps"][3]["time"] = FormatUtils.truncar_float_cadena(
        tiempo_step_final)
    json_eval["steps"][3]["start"] = fecha_inicio
    json_eval["steps"][3]["end"] = fecha_fin

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