サンプル 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 フラグを使用します。