サンプル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"
             }
           ]
         }]
       }

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