Switch Page
Switch Page
Section titled “Switch Page”Type: browser-switch-page · Package: Browser v1.0.9 · Output: ZoanPageSession
Takes a tab that is already open and returns its page session, so you can keep working on it. It is the activity for tabs the playbook didn’t open: the one that appears when you click a link that opens in another tab, a login pop-up window or a PDF viewer.
How it works
Section titled “How it works”- Among the open tabs of the same browser, it looks for the one matching
url,titleorindex(at least one is required). - If it doesn’t exist yet, it keeps looking (every 200 ms) until
timeoutruns out: a tab opened by a click takes a moment to appear. Withtimeout = 0it looks only once. - It brings it to the front (unless you turn off
bringToFront) and returns aZoanPageSessionthat represents it.
Pass that session as page to the activities that must act on the tab found. If you leave session empty inside the body of Open Browser or Attach Browser, it searches the browser of that body.
How matches are found
Section titled “How matches are found”urlandtitlelook for text contained in the URL or title, case-insensitive. If you use both, the tab must match both.- With
*the text becomes a pattern that must cover the whole value:"*/invoices*"finds any URL containing/invoices, but"invoices*"only one that starts withinvoices. indexis the position of the tab in opening order, counting from 1. On its own, it counts among all open tabs; together withurlortitle, it chooses among the matching ones.- Without
index, if several tabs match, the first in opening order is taken.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanPageSession | — | Any page session of the browser (from Open Browser, Attach Browser, New Page…). The tab is looked up in that same browser. Empty inside a body: the browser of that body. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | — | Matches tabs whose URL contains this text. Supports * as a wildcard. |
title | string | — | Matches tabs whose title contains this text. Supports * as a wildcard. |
index | int | — | Tab position, starting at 1. Use it alone, or with url/title to choose among several matches. |
timeout | int | 10000 | Maximum time in ms to wait for a matching tab to appear. |
bringToFront | bool | true | Brings the tab to the front. |
Output
Section titled “Output”Returns a ZoanPageSession that represents the tab found, tied to the same browser. If no tab matches in time, the activity fails (it doesn’t return an empty value).
Example
Section titled “Example”A portal link opens an invoice detail in another tab; the total is read and the tab is closed:
Open Browser browser = chrome url = "https://portal.example.com" → output: pagePage Click page = page selector = (#verFactura)Switch Page session = page url = "*/invoices/*" → output: detallePage Get Text page = detalle selector = (.total) → output: totalClose Page page = detalleTwo tabs of the same report are open and you want the second one:
Switch Page session = page title = "Sales report" index = 2 → output: reporteCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
At least one of 'url', 'title' or 'index' is required. | You didn’t set any search criterion. |
No open tab matches the given url + title (3 tab(s) open). | No tab matched before timeout. The message says which criteria you used (url, title, index=N) and how many tabs were open. Check the pattern (remember that with * it must cover the whole value) or raise timeout. |
'session' must be a ZoanPageSession or ZoanBrowserSession. | session is empty outside a body, or the variable doesn’t hold a browser session. |
Related activities
Section titled “Related activities”- Click — with
expectNewTab, returns the tab the click opens directly. - New Page — open a new tab yourself.
- Close Page — close the tab when you’re done.
- Open Browser — get the browser session.