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

Category Pagination

Paginate the category and visit each product detail page.

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

Category Products

name price
Wireless Noise-Cancelling Headphones $249.99
4K Ultra HD Monitor $499.99
Mechanical Gaming Keyboard $129.99
USB-C Docking Station $159.99
Portable SSD 1TB $99.99
Smart Home Hub $79.99
Wireless Charging Pad $29.99
Bluetooth Speaker $59.99
Classic Cotton T-Shirt $19.99
Slim Fit Jeans $69.99
Waterproof Rain Jacket $119.99
Running Sneakers $129.99
Wool Blend Sweater $89.99
Leather Belt $39.99
Sun Hat $24.99
Sport Socks Pack $9.99
JavaScript: The Good Parts $16.95
Design Patterns Explained $28.99
RTILA X PROJECT JSON

RTILA X Automation Project

category-pagination-and-details.json
{
  "name": "Category_Pagination_And_Details",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/ecommerce/3"
    ]
  },
  "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": "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": "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?