Skip to main content

multi-tab Scenario 1 — Click Link Opening New Tab, Extract, Switch Back

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Switch between browser tabs

Real-World Use Case

Automating multi-tab workflows

LIVE DEMO

New Tab and Main Page

A link opens a second tab; extract there, then switch back.

Multi-Tab Demo

Clicking the link below opens a new tab containing additional product details. The main page table remains available in its original tab.

Open Product Details in New Tab
ProductPriceStock
Wireless Mouse$24.99In Stock
USB-C Hub$39.99In Stock
Mechanical Keyboard$89.99Low Stock
EXPECTED OUTPUT

Tab and Main Data

{
  "main_data": [
    {
      "product": "Wireless Mouse",
      "price": "$24.99",
      "stock": "In Stock"
    },
    {
      "product": "USB-C Hub",
      "price": "$39.99",
      "stock": "In Stock"
    },
    {
      "product": "Mechanical Keyboard",
      "price": "$89.99",
      "stock": "Low Stock"
    }
  ],
  "tab_data": [
    {
      "username": "techguru42",
      "email": "tech@example.com",
      "role": "Admin",
      "posts": "142"
    }
  ]
}
RTILA X PROJECT JSON

RTILA X Automation Project

extract-new-tab-and-main.json
{
  "name": "Extract_New_Tab_And_Main",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/multi-tab/1"
    ]
  },
  "datasets": {
    "main_data": {
      "item_selector": "css=table.main-data tbody tr",
      "properties": [
        {
          "name": "product",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "price",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "stock",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        }
      ]
    },
    "tab_data": {
      "item_selector": "css=table.user-info tbody tr",
      "properties": [
        {
          "name": "field",
          "type": "text",
          "selector": "css=th"
        },
        {
          "name": "value",
          "type": "text",
          "selector": "css=td"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "click",
      "params": {
        "selector": "css=.new-tab-link"
      }
    },
    {
      "command": "switch_to_tab",
      "params": {
        "index": 1
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.second-tab-content"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "tab_data"
      }
    },
    {
      "command": "switch_to_tab",
      "params": {
        "index": 0
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=table.main-data"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "main_data"
      }
    }
  ]
}

The switch_to_tab command moves between browser tabs. After extracting data from the new tab, the automation returns to the original tab to extract its table.

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 1 learning article.

Continue Learning

Was this helpful?