Skip to main content

Close Window

Closes the specified browser window.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • Page Id - The id of the page in which you want to close the window. This ID is generated by the Open Browser node.

Note that even you close the last window, the browser process still runs, you need to use the Close Browser node to end the browser process.

How It Works

  1. The node receives the Page ID and validates it is not empty
  2. It waits for any configured delay before execution
  3. It retrieves the page session using the provided Page ID
  4. The node gets a list of all open windows in the browser session
  5. It identifies the currently active window
  6. It finds the next available window (if any) to switch focus to
  7. The node closes the current window associated with the Page ID
  8. If there are remaining windows, it automatically switches focus to the next window
  9. The node applies any configured delay after execution

Requirements

  • An active browser session created by the Open Browser node
  • A valid Page ID from the Open Browser node
  • The browser window must still be open and not already closed

Error Handling

Error CodeDescription
Core.Browser.CloseWindow.ErrOnCreateConfiguration parsing error during node creation
Core.Browser.CloseWindow.OnMessageError parsing incoming message data
Core.Browser.CloseWindow.ErrPageIdPage ID is empty or not provided
Core.Browser.CloseWindow.ErrSessionInvalid Page ID, session not found, or error closing window

Usage Examples

Example 1: Closing Popup Window

When automating a workflow that opens popup windows:

1. Use Open Browser to start the main browser session
2. Use Click Element to trigger action that opens a popup window
3. Use Switch Window to switch to the popup window (get new page_id)
4. Perform actions on the popup (read data, fill forms, etc.)
5. Use Close Window with the popup's page_id to close it
6. Continue working with the main window

Example 2: Managing Multiple Tabs

When working with multiple tabs and closing them selectively:

1. Use Open Browser to create initial session
2. Use Open Link multiple times to open several tabs (store each page_id)
3. Perform tasks on different tabs by switching between them
4. Use Close Window with specific page_id values to close completed tabs
5. The browser automatically focuses on remaining tabs
6. Use Close Browser to terminate when all work is done

Example 3: Cleanup After Data Extraction

When extracting data from multiple sources in separate windows:

1. Open browser and navigate to a data source
2. Open additional windows/tabs for different data sources
3. Loop through each window:
- Switch to the window
- Extract the needed data
- Use Close Window to close the current window
4. After processing all windows, use Close Browser to cleanup

Usage Notes

  • Close Window only closes the specific window/tab, not the entire browser
  • The browser process continues running even if you close the last window
  • After closing a window, the browser automatically switches to another open window if available
  • The Page ID becomes invalid after the window is closed
  • If you try to use a Page ID of a closed window, subsequent operations will fail
  • To completely terminate the browser, use the Close Browser node
  • Closing a window does not affect other windows or tabs in the same browser session

Tips

  • Always track which windows are open to avoid trying to close already-closed windows
  • Use Close Window for individual tab/window management in multi-tab workflows
  • Store Page IDs in variables or arrays to manage multiple windows efficiently
  • Consider using Continue On Error when closing windows that might already be closed
  • Switch to a specific window before closing it to ensure you're closing the right one
  • For cleanup operations, close windows in a loop starting from the most recently opened
  • Use Close Browser instead of Close Window when you want to terminate the entire session