Archivos de Script CLI de Muestra

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard
Not for use with personal data

Este tema proporciona muestras que serán útiles para tu propio trabajo. Puedes usar algunos de estos scripts o algunas de las funciones dentro de ellos.

Nota: Puedes ejecutar scripts de shell que incorporen comandos CLI desde el símbolo del sistema de bash en la plataforma Windows tan fácilmente como ejecutas el comando desde el símbolo del sistema en UNIX.

Script Inicial o Plantilla Puedes usar la siguiente plantilla o script inicial para comenzar a trabajar en un script CLI simple:

  {
            "projects": [
                {
                    "name": "example-name",
                    "id": "example-id",
                    "pageList": [
                        {
                            "name": "Page 1",
                            "url": "https://changeme.com",
                            "actions": [
                                "action 1",
                                "action 2",
                                "action 3"
                            ]
                        }
                    ]
                }
            ]
        }

Ejemplo - Añadir Productos a un Carrito

El siguiente ejemplo te permite ir al sitio web, http://webtestingcourse.dequecloud.com/, analizar las páginas, buscar un portátil específico para comprar, especificar la cantidad de portátiles a comprar y luego añadir los portátiles al carrito. Usa el comando analyze with title si deseas analizar la página con un título personalizado. Usa el comando wait para esperar a que la tarea dada se complete y devuelva el estado de salida del comando esperado.

{
    "projects": [
      {
        "name": "Project Name",
        "id": "project-name",
        "pageList": [
          {
            "name": "Page 1",
            "url": "http://webtestingcourse.dequecloud.com/",
            "actions": [
              "wait for 1s",
              "analyze with title \"home-page\"",
              "select element \"fieldset > input[type='text'][name='q']\"",
              "change the value of \"fieldset > input[type='text'][name='q']\" to \"laptop\"",
              "select element \"#go\"",
              "wait for 1s",
              "analyze with title \"search-results\"",
  ​
              "select element \"li:nth-child(1) > a[href$='laptop1.php']\"",
              "wait for 1s",
              "analyze with title \"laptop\"",
              
              "select element \"a > img[src$='addToCartButton.gif']\"",
              "wait for 1s",
              "analyze with title \"add-to-cart\""
            ]
          }
        ]
      }
    ]
  }

Ejemplo - Script sin Pasos de Análisis

El siguiente ejemplo es cuando deseas crear scripts para tareas de establecimiento de sesiones sin ninguna acción de análisis. Un ejemplo es cuando un usuario quiere iniciar sesión en un sitio web.

{
         "projects": [{
           "name": "Project Name",
           "id": "project-name",
           "pageList": [{
               "name": "Page 1",
               "url": "https://phptravels.net/login",
               "actions": [
       ​
                 "select element \".form-group > input[type='email'][name='email']\"",
                 "change the value of \".form-group > input[type='email'][name='email']\" to \"supplier@phptravels.com\"",
                 "select element \".form-group.mb-2 > input[type='password'][name='password']\"",
                 "change the value of \".form-group.mb-2 > input[type='password'][name='password']\" to \"demosupplier\"",
                 "select element \"#fadein > .container > div > .modal-content.align-self-center > .modal-body > .contact-form-action > form > div:nth-child(3) > button\"",
                                         "wait for 5s"			
               ]
             },
             {
               "name": "Page 2",
               "url": "https://phptravels.net/account/dashboard"
             }
           ]
         }]
       }

Nota: Para probar un archivo sin ninguna acción 'analyze', usa la opción --no-analyze con axe DevTools CLI.