Switch or Close Tab
This is a revised version of Switch or Close Tab block, available in upcoming 1.1.54 release.
The Switch or Close Tab building block allows you to:
Switch to a specific tab using different criteria.
Close a tab.
Actions
Switch to Tab
Switch to a tab based on the criteria you select:
Latest tab: Switch to the last tab on the farthest right.
Previous tab: Switch to the tab directly to the left of the current tab.
Next tab: Switch to the tab directly to the right of the current tab.
Tab URL matching: Match a tab based on its URL or part of it. If there are multiple matching tabs, the first one will be picked. Examples:
A full URL (e.g.,
google.com
).A partial URL (e.g.,
/subpage
).For advanced matching: A regular expression entered between slashes with or without a flag (e.g.,
/^https:\/\/google\.com$/i
or/^https:\/\/google\.com$/
). If your regular expression is invalid, no error will be thrown and TaskBot will assume it is a non-regex value. To ensure that your expression is correct, use regex validator beforehand (e.g. https://regex101.com/).
Tab number: Switch to a tab by its position in the browser. For example:
Tab number 1: First tab on the farthest left.
Tab number 2: Second tab from the left, and so on.
Be cautious with options other than Tab URL matching. TaskBot determines the order of tabs based on their creation time. If you manually rearrange tabs during the TaskBot's run, the tab number may no longer match the visual order displayed in the browser.
Close Tab
Close a specific tab based on the same criteria as described above.
What happens if an active tab is closed?
If you close the currently active tab:
The next tab to the right will become active.
If no tabs exist on the right, the next tab to the left becomes active.
If no tabs remain, the browser application will close.
If the tab that is closed is not active, the active tab will remain as it is.
If this default behavior does not meet your needs, you can add another Switch or Close Tab building block to define which tab should become active.
If the browser application closes because all tabs are closed, TaskBot will continue running. However, if subsequent actions require a browser (such as a Click Web Element building block), TaskBot will stop, generate an error, and report the run as failed. To prevent this, you can add an Open Link building block to re-launch the browser.
Last updated