サンプル CLI スクリプトファイル

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

このトピックでは、あなた自身の作業に役立つサンプルを提供します。これらのスクリプトやその中のいくつかの関数を使用することができます。

注意: Windows プラットフォームでは、bash プロンプトから CLI コマンドを組み込んだシェルスクリプトを、UNIX 上でシェルのコマンドプロンプトからコマンドを実行するのと同じように簡単に実行できます。

スタータースクリプトまたはテンプレート 以下のテンプレートまたはスタータースクリプトを使用して、簡単な CLI スクリプトの作成を始めることができます。

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

サンプル - カートに商品を追加する

次のサンプルでは、ウェブサイトhttp://webtestingcourse.dequecloud.com/にアクセスし、ページを分析し、購入する特定のラップトップを検索し、購入するラップトップの数を指定し、それからカートにラップトップを追加することができます。カスタムタイトルでページを分析したい場合は analyze with title コマンドを使用してください。指定されたジョブが完了するのを待ち、待機されたコマンドの終了ステータスを返すには wait コマンドを使用してください。

{
    "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\""
            ]
          }
        ]
      }
    ]
  }

サンプル - 分析ステップなしのスクリプト

以下のサンプルは、分析アクションなしでセッション確立タスクのためのスクリプトを作成したい場合です。例として、ユーザーがウェブサイトにログインしたい場合があります。

{
         "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"
             }
           ]
         }]
       }

注意: 「analyze」アクションなしでファイルをテストするには、axe DevTools CLI で --no-analyze フラグを使用します。