メインコンテンツへスキップ

ループ

loop 定義を持つステップは、ネストされた steps を複数回繰り返します。whileforEach の2種類のループをサポートしています。

while ループ

条件が truthy の間繰り返します:
steps:
  - ordinal: 0
    description: "次へボタンがなくなるまでページを処理"
    action:
      type: click
      selector:
        tagName: button
        innerText: "Next"
    url: "https://app.example.com/list"
    riskLevel: low
    requiresConfirmation: false
    loop:
      condition: "{{hasNextPage}}"
      maxIterations: 50
      counterVariable: pageIndex
    steps:
      - ordinal: 0
        description: "現在のページからデータを抽出"
        action:
          type: extract
          script: "document.querySelector('.data').textContent"
        url: "https://app.example.com/list"
        riskLevel: low
        requiresConfirmation: false
        captures:
          - name: hasNextPage
            strategy: evaluate
            expression: "!!document.querySelector('button:has-text(\"Next\")')"

forEach ループ

JSON 配列変数またはメモリコレクションのアイテムを反復処理します:
steps:
  - ordinal: 0
    description: "各ユーザーを処理"
    action:
      type: navigate
      url: "https://app.example.com/users"
    url: "https://app.example.com/users"
    riskLevel: low
    requiresConfirmation: false
    loop:
      forEach: "{{userList}}"
      itemVariable: currentUser
      indexVariable: userIndex
      maxIterations: 100
    steps:
      - ordinal: 0
        description: "ユーザープロフィールに遷移"
        action:
          type: navigate
          url: "https://app.example.com/users/{{currentUser}}"
        url: "https://app.example.com/users/{{currentUser}}"
        riskLevel: low
        requiresConfirmation: false
メモリコレクションを反復処理するには、collection: プレフィックスを使用します:
loop:
  forEach: "collection:products"
  itemVariable: product

ループフィールド

フィールド必須説明
conditionstringいずれかwhile ループのテンプレート式
forEachstringいずれかテンプレート変数(JSON 配列)または collection:name
itemVariablestringNo現在のアイテムの変数名(forEach のみ)
indexVariablestringNo現在のインデックスの変数名(forEach のみ)
maxIterationsintegerNo最大反復回数(安全制限)
counterVariablestringNoループカウンタの変数名
ループには conditionforEach のいずれか1つだけを指定する必要があります。両方は不可。

分岐

branches を持つステップは、変数の値に基づいて異なるステップセットを実行します:
steps:
  - ordinal: 0
    description: "アカウントタイプで分岐"
    action:
      type: navigate
      url: "https://app.example.com/account"
    url: "https://app.example.com/account"
    riskLevel: low
    requiresConfirmation: false
    branches:
      value: "{{accountType}}"
      cases:
        - match: "personal"
          steps:
            - ordinal: 0
              description: "個人フォームに入力"
              action:
                type: input
                value: "{{name}}"
                selector:
                  tagName: input
                  name: "fullName"
              url: "https://app.example.com/account"
              riskLevel: low
              requiresConfirmation: false
        - match: "business"
          steps:
            - ordinal: 0
              description: "法人フォームに入力"
              action:
                type: input
                value: "{{companyName}}"
                selector:
                  tagName: input
                  name: "company"
              url: "https://app.example.com/account"
              riskLevel: low
              requiresConfirmation: false
      default:
        steps:
          - ordinal: 0
            description: "未認識のタイプをスキップ"
            action:
              type: wait
            url: "https://app.example.com/account"
            riskLevel: low
            requiresConfirmation: false

分岐フィールド

フィールド必須説明
valuestringYes評価するテンプレート式
casesBranchCase[]Yes最低1つのケース
defaultobjectNosteps 配列を持つデフォルトケース

BranchCase フィールド

フィールド必須説明
matchstringYesマッチする値
stepsStep[]Yesマッチ時に実行するステップ(最低1つ)

条件付きステップ

任意のステップに condition フィールドを設定できます。条件が falsy に評価されると、ステップはスキップされます:
steps:
  - ordinal: 0
    description: "合計が0より大きい場合のみ確認をクリック"
    condition: "{{totalAmount}}"
    action:
      type: click
      selector:
        tagName: button
        innerText: "Confirm"
    url: "https://app.example.com/checkout"
    riskLevel: medium
    requiresConfirmation: true
1つのステップに loopbranches を同時に設定することはできません。