Skip to main content

ecommerce Scenario 3 — Category with Pagination and Detail Pages

Written by RTILA X Engineering Team

Intermediate ~6 min
Prerequisites: ecommerce/1 ecommerce/2

What You'll Learn

Add items to cart and proceed to checkout

Real-World Use Case

Automating end-to-end purchase flows

LIVE DEMO

Wireless Noise-Cancelling Headphones

$249.99 View Details

4K Ultra HD Monitor

$499.99 View Details

Mechanical Gaming Keyboard

$129.99 View Details

USB-C Docking Station

$159.99 View Details

Portable SSD 1TB

$99.99 View Details

Smart Home Hub

$79.99 View Details
EXPECTED OUTPUT

RTILA X PROJECT JSON

    {
  "name": "Category_Pagination_And_Details",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/ecommerce/3"
    ],
    "headless": false,
    "navigation_timeout": 30000,
    "max_concurrent_workers": 1,
    "humanoidEnabled": true,
    "humanoidSensitivity": "medium"
  },
  "datasets": {
    "category_products": {
      "item_selector": "css=.cat-product",
      "properties": [
        {
          "name": "name",
          "type": "text",
          "selector": "css=.cat-name"
        },
        {
          "name": "price",
          "type": "text",
          "selector": "css=.cat-price"
        },
        {
          "name": "url",
          "type": "attribute",
          "selector": "css=a.cat-detail-link",
          "attribute": "href"
        }
      ]
    },
    "product_details": {
      "item_selector": "css=.product-detail",
      "properties": [
        {
          "name": "description",
          "type": "text",
          "selector": "css=.product-detail-desc"
        },
        {
          "name": "reviews",
          "type": "text",
          "selector": "css=.product-reviews"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "goto",
      "params": {
        "url": "https://learn.rtila.com/scenarios/ecommerce/3"
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.cat-product"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "category_products"
      }
    },
    {
      "command": "while",
      "params": {
        "condition": {
          "type": "element_visible",
          "selector": "css=a.cat-next:not(.disabled)"
        },
        "do": [
          {
            "command": "click",
            "params": {
              "selector": "css=a.cat-next"
            }
          },
          {
            "command": "wait_for_load_state",
            "params": {
              "state": "networkidle"
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "category_products"
            }
          }
        ]
      }
    },
    {
      "command": "for_each",
      "params": {
        "source_type": "dataset",
        "dataset": "category_products",
        "as": "product",
        "do": [
          {
            "command": "goto",
            "params": {
              "url": "${product.url}"
            }
          },
          {
            "command": "wait_for_selector",
            "params": {
              "selector": "css=.product-detail"
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "product_details"
            }
          }
        ]
      }
    }
  ]
}
  

Category pages often use pagination and separate product detail pages. A while loop collects every page, then a for_each loop visits each product URL.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 3 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?