サンプル CLI スクリプトファイル
Not for use with personal data
このトピックでは、自分の作業に役立つサンプルを提供します。これらのスクリプト、またはその中のいくつかの関数を使用することができます。
注意: bash プロンプトから CLI コマンドを組み込んだシェルスクリプトを Windows プラットフォームで実行する方法は、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 フラグを使用してください。
