Use Case: Switch Windows

In this use case, a robot must complete work in several pop-up windows, including a pop-up window that is launched from another pop-up window. Explore how the window action supports this workflow.

Scenario

A robot completes the following tasks:

  1. Opens a web application and completes a task that opens a pop-up window (child window 1).

  2. Completes a task in child window 1. The task opens another pop-up window (child window 2).

  3. Closes the two child windows, and returns to the main window.

Workflow

This workflow focuses on the steps that require the window action.

Task More information

Create variables for storing the titles of the windows that the robot interacts with

For example, create the following string variables to store the handles for the windows that the robot interacts with:

  • mainWindowHandle

  • childWindowHandle1

  • childWindowHandle2

Additionally, create the following string collection variables to hold all window handles and titles:

  • windowHandles

  • windowTitles

See Create a Variable.

Add actions that open the web application and open child window 1

Add robot actions as needed.

See Add an Action to a Robot.

Add a window action that switches the robot's focus to child window 1

The following action switches to child window 1 by specifying NEW for the Window Id.

The dialog for defining a window action appears. The Name is Open child window 1. The Operation is Switch To. The Window Id is NEW. The Timeout is 5.

On the Output tab, the handle for the main window is saved to a variable. The variable lets the robot easily return to the main window later in the flow. See Add a Window Action.

The Output tab for the window action appears. The Save to field is ${$VARIABLE.mainWindowHandle}.

Interact with child window 1, prompting child window 2 to open

Add robot actions as needed.

See Add an Action to a Robot.

Add a window action that switches the robot's focus from child window 1 to child window 2

The following action switches to child window 2 by specifying NEW for the Window Id.

The dialog for defining a window action appears. The Name is Open child window 2. The Operation is Switch To. The Window Id is NEW. The Timeout is 5.

On the Output tab, the handle for child window 1 is saved to a variable. The variable lets the robot easily return to the window later in the flow. See Add a Window Action.

The Output tab for the window action appears. The Save to field is ${$VARIABLE.childWindowHandle1}.

Interact with child window 2

Add robot actions as needed.

See Add an Action to a Robot.

Get and log the window handles and titles of all the windows that the robot has interacted with up until now

Add two window actions. The first action gets the handles and saves them in a string collection variable. The second action gets the titles and saves them in a string collection variable. See Add a Window Action.

The dialog for defining a window action appears. The Name is Get window handles. The Operation is Get Window Handles. The Save to value is ${$VARIABLE.windowHandles}.

The dialog for defining a window action appears. The Name is Get window titles. The Operation is Get Window Titles. The Save to value is ${$VARIABLE.windowTitles}.

Additionally, add two log actions to log the values to the activity stream. See Add a Log Action.

Close child window 2, and switch the focus to child window 1

Add two window actions. The first action closes child window 2. See Add a Window Action.

The dialog for defining a window action appears. The Name is Close child window 2. The Operation is Close Window.

The second action switches focus to child window 1 by specifying the variable for this window.

The dialog for defining a window action appears. The Name is Switch to child window 1. The Operation is Switch To. The Window Id is ${$VARIABLE.childWindowHandle1}. The Timeout is 5.

Close child window 1, and switch the focus to the main window

Add two window actions. The first action closes child window 1. See Add a Window Action.

The dialog for defining a window action appears. The Name is Close child window 1. The Operation is Close Window.

The second action switches focus to the main window by specifying its variable.

The dialog for defining a window action appears. The Name is Switch to main window. The Operation is Switch To. The Window Id is ${$VARIABLE.mainWindowHandle}. The Timeout is 5.