Close Browser Tab

Closes the currently active tab in the browser.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Closes an active browser tab, setting the following tab as the new active tab in the browser.
You can use the Automatic closing parameter to close a tab without closing the browser.

Script syntax

IBM RPA's proprietary scripting language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

webCloseTab [--windowhasbeenclosed(Boolean)]

Dependencies

Use the Start Browser (webStart) command to start a browser or use the Find Internet Explorer Browser (findBrowser) command to attach the Microsoft Internet Explorer before using Close Browser Tab (webCloseTab) command.

The browser needs at least two active tabs for this command to work properly.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Automatic closing windowhasbeenclosed Optional Boolean Enable this option to disregard the command if the window is automatically closed by an external factor.

Example

The browser starts and navigates to the Google homepage. Then, a javascript code runs to open a new tab on the IBM homepage while the Google homepage is still focused. Then, the Close Browser Tab (webCloseTab) command is used to close the active Google tab.

// Starts the browser.
webStart --name browser --type "Chrome"
// Navigate to google.com.
webNavigate --url "google.com"
// Executes a java script to open the IBM home page.
webExecuteJavaScript --script "window.open(\'https://www.ibm.com\');\r\n"
// Closes the tab where the Google page is.
webCloseTab
// Close browser.
webClose --name browser --leavebrowseropen