Skip to main content

ecommerce Scenario 2 — Extract All Product Variants

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Assert stock availability

Real-World Use Case

Alerting when a product comes back in stock

LIVE DEMO

Product Variants

Every size and color combination in the variant table.

Classic Cotton T-Shirt

S M L XL
White Black Navy
SizeColorPriceStock
S White $29.99 15
S Black $29.99 15
S Navy $34.99 15
M White $29.99 23
M Black $29.99 23
M Navy $34.99 23
L White $29.99 8
L Black $29.99 8
L Navy $34.99 8
XL White $29.99 0
XL Black $29.99 0
XL Navy $34.99 0
EXPECTED OUTPUT

Variants

size color price stock
S White $29.99 15
S Black $29.99 15
S Navy $34.99 15
M White $29.99 23
M Black $29.99 23
M Navy $34.99 23
L White $29.99 8
L Black $29.99 8
L Navy $34.99 8
XL White $29.99 0
XL Black $29.99 0
XL Navy $34.99 0
RTILA X PROJECT JSON

RTILA X Automation Project

extract-product-variants.json
{
  "name": "Extract_Product_Variants",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/ecommerce/2"
    ]
  },
  "datasets": {
    "variants": {
      "item_selector": "css=table.variant-table tbody tr",
      "properties": [
        {
          "name": "size",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "color",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "price",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        },
        {
          "name": "stock",
          "type": "text",
          "selector": "css=td:nth-child(4)"
        }
      ]
    }
  }
}

Variant tables are ideal for dataset extraction. Each row is one purchasable combination of size and color.

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 2 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?